Mage_Adminhtml_Catalog_SearchController Class Reference

Inheritance diagram for Mage_Adminhtml_Catalog_SearchController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 newAction ()
 editAction ()
 saveAction ()
 deleteAction ()
 massDeleteAction ()

Protected Member Functions

 _initAction ()
 _isAllowed ()


Detailed Description

Definition at line 28 of file SearchController.php.


Member Function Documentation

_initAction (  )  [protected]

Definition at line 30 of file SearchController.php.

00031     {
00032         $this->loadLayout()
00033             ->_setActiveMenu('catalog/search')
00034             ->_addBreadcrumb(Mage::helper('catalog')->__('Search'), Mage::helper('catalog')->__('Search'))
00035         ;
00036         return $this;
00037     }

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 166 of file SearchController.php.

00167     {
00168         return Mage::getSingleton('admin/session')->isAllowed('catalog/search');
00169     }

deleteAction (  ) 

Definition at line 121 of file SearchController.php.

00122     {
00123         if ($id = $this->getRequest()->getParam('id')) {
00124             try {
00125                 $model = Mage::getModel('catalogsearch/query');
00126                 $model->setId($id);
00127                 $model->delete();
00128                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('catalog')->__('Search was successfully deleted'));
00129                 $this->_redirect('*/*/');
00130                 return;
00131             }
00132             catch (Exception $e) {
00133                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00134                 $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
00135                 return;
00136             }
00137         }
00138         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('Unable to find a search term to delete'));
00139         $this->_redirect('*/*/');
00140     }

editAction (  ) 

Definition at line 52 of file SearchController.php.

00053     {
00054         $id = $this->getRequest()->getParam('id');
00055         $model = Mage::getModel('catalogsearch/query');
00056 
00057         if ($id) {
00058             $model->load($id);
00059             if (! $model->getId()) {
00060                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('This search no longer exists'));
00061                 $this->_redirect('*/*');
00062                 return;
00063             }
00064         }
00065 
00066         // set entered data if was error when we do save
00067         $data = Mage::getSingleton('adminhtml/session')->getPageData(true);
00068         if (!empty($data)) {
00069             $model->addData($data);
00070         }
00071 
00072         Mage::register('current_catalog_search', $model);
00073 
00074         $block = $this->getLayout()->createBlock('adminhtml/catalog_search_edit')
00075             ->setData('action', $this->getUrl('*/catalog_search/save'));
00076 
00077         $this->_initAction();
00078 
00079         $this->getLayout()->getBlock('head')->setCanLoadRulesJs(true);
00080 
00081         $this
00082             ->_addBreadcrumb($id ? Mage::helper('catalog')->__('Edit Search') : Mage::helper('catalog')->__('New Search'), $id ? Mage::helper('catalog')->__('Edit Search') : Mage::helper('catalog')->__('New Search'))
00083             ->_addContent($block)
00084             ->renderLayout();
00085 
00086     }

indexAction (  ) 

Definition at line 39 of file SearchController.php.

00040     {
00041         $this->_initAction()
00042             ->_addBreadcrumb(Mage::helper('catalog')->__('Catalog'), Mage::helper('catalog')->__('Catalog'))
00043             ->_addContent($this->getLayout()->createBlock('adminhtml/catalog_search'))
00044             ->renderLayout();
00045     }

massDeleteAction (  ) 

Definition at line 142 of file SearchController.php.

00143     {
00144         $searchIds = $this->getRequest()->getParam('search');
00145         if(!is_array($searchIds)) {
00146              Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select catalog searches'));
00147         } else {
00148             try {
00149                 foreach ($searchIds as $searchId) {
00150                     $model = Mage::getModel('catalogsearch/query')->load($searchId);
00151                     $model->delete();
00152                 }
00153                 Mage::getSingleton('adminhtml/session')->addSuccess(
00154                     Mage::helper('adminhtml')->__(
00155                         'Total of %d record(s) were successfully deleted', count($searchIds)
00156                     )
00157                 );
00158             } catch (Exception $e) {
00159                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00160             }
00161         }
00162 
00163         $this->_redirect('*/*/index');
00164     }

newAction (  ) 

Definition at line 47 of file SearchController.php.

00048     {
00049         $this->_forward('edit');
00050     }

saveAction (  ) 

Definition at line 88 of file SearchController.php.

00089     {
00090         if ($data = $this->getRequest()->getPost()) {
00091             $model = Mage::getModel('catalogsearch/query');
00092 
00093             if ($queryText = $this->getRequest()->getParam('query_text')) {
00094                 $model->load($queryText);
00095                 if ($model->getId() && $this->getRequest()->getParam('query_id') != $model->getId()) {
00096                     Mage::getSingleton('adminhtml/session')->addError(Mage::helper('catalog')->__('Search Term with such search query already exist.'));
00097                     Mage::getSingleton('adminhtml/session')->setPageData($data);
00098                     $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('query_id')));
00099                     return;
00100                 }
00101             }
00102 
00103             $model->addData($data);
00104             Mage::getSingleton('adminhtml/session')->setPageData($model->getData());
00105             try {
00106                 $model->save();
00107                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('catalog')->__('Search Term was successfully saved'));
00108                 Mage::getSingleton('adminhtml/session')->setPageData(false);
00109                 $this->_redirect('*/*/');
00110                 return;
00111             } catch (Exception $e) {
00112                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00113                 Mage::getSingleton('adminhtml/session')->setPageData($data);
00114                 $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
00115                 return;
00116             }
00117         }
00118         $this->_redirect('*/*/');
00119     }


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