Mage_Adminhtml_TagController Class Reference

Inheritance diagram for Mage_Adminhtml_TagController:

Mage_Adminhtml_Controller_Action Mage_Core_Controller_Varien_Action

List of all members.

Public Member Functions

 indexAction ()
 newAction ()
 editAction ()
 saveAction ()
 deleteAction ()
 pendingAction ()
 productAction ()
 customerAction ()
 massDeleteAction ()
 massStatusAction ()

Protected Member Functions

 _initAction ()
 _isAllowed ()


Detailed Description

Definition at line 34 of file TagController.php.


Member Function Documentation

_initAction (  )  [protected]

Definition at line 37 of file TagController.php.

00038     {
00039         $this->loadLayout()
00040             ->_setActiveMenu('catalog/tag')
00041             ->_addBreadcrumb(Mage::helper('adminhtml')->__('Catalog'), Mage::helper('adminhtml')->__('Catalog'))
00042             ->_addBreadcrumb(Mage::helper('adminhtml')->__('Tags'), Mage::helper('adminhtml')->__('Tags'))
00043         ;
00044         return $this;
00045     }

_isAllowed (  )  [protected]

Reimplemented from Mage_Adminhtml_Controller_Action.

Definition at line 266 of file TagController.php.

00267     {
00268         switch ($this->getRequest()->getActionName()) {
00269             case 'pending':
00270                 return Mage::getSingleton('admin/session')->isAllowed('catalog/tag/pending');
00271                 break;
00272             case 'all':
00273                 return Mage::getSingleton('admin/session')->isAllowed('catalog/tag/all');
00274                 break;
00275             default:
00276                 return Mage::getSingleton('admin/session')->isAllowed('catalog/tag');
00277                 break;
00278         }
00279     }

customerAction (  ) 

Customers

Definition at line 207 of file TagController.php.

00208     {
00209         Mage::register('tagId', $this->getRequest()->getParam('tag_id'));
00210 
00211         $this->_initAction()
00212             ->_addBreadcrumb(Mage::helper('adminhtml')->__('Customers'), Mage::helper('adminhtml')->__('Customers'))
00213             ->_setActiveMenu('catalog/tag/customer')
00214             ->_addContent($this->getLayout()->createBlock('adminhtml/tag_customer'))
00215             ->renderLayout();
00216     }

deleteAction (  ) 

Definition at line 131 of file TagController.php.

00132     {
00133         if ($id = $this->getRequest()->getParam('tag_id')) {
00134 
00135             switch( $this->getRequest()->getParam('ret') ) {
00136                 case 'all':
00137                     $url = $this->getUrl('*/*/', array(
00138                         'customer_id' => $this->getRequest()->getParam('customer_id'),
00139                         'product_id' => $this->getRequest()->getParam('product_id'),
00140                     ));
00141                     break;
00142 
00143                 case 'pending':
00144                     $url = $this->getUrl('*/tag/pending', array(
00145                         'customer_id' => $this->getRequest()->getParam('customer_id'),
00146                         'product_id' => $this->getRequest()->getParam('product_id'),
00147                     ));
00148                     break;
00149 
00150                 default:
00151                     $url = $this->getUrl('*/*/', array(
00152                         'customer_id' => $this->getRequest()->getParam('customer_id'),
00153                         'product_id' => $this->getRequest()->getParam('product_id'),
00154                     ));
00155             }
00156 
00157             try {
00158                 $model = Mage::getModel('tag/tag');
00159                 $model->setId($id);
00160                 $model->delete();
00161                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Tag was successfully deleted'));
00162                 $this->getResponse()->setRedirect($url);
00163                 return;
00164             }
00165             catch (Exception $e) {
00166                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00167                 $this->_redirect('*/*/edit', array('tag_id' => $this->getRequest()->getParam('tag_id')));
00168                 return;
00169             }
00170         }
00171         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Unable to find a tag to delete'));
00172         $this->getResponse()->setRedirect($url);
00173     }

editAction (  ) 

Definition at line 61 of file TagController.php.

00062     {
00063         $id = $this->getRequest()->getParam('tag_id');
00064         $model = Mage::getModel('tag/tag');
00065 
00066         if ($id) {
00067             $model->load($id);
00068         }
00069 
00070         // set entered data if was error when we do save
00071         $data = Mage::getSingleton('adminhtml/session')->getTagData(true);
00072         if (! empty($data)) {
00073             $model->setData($data);
00074         }
00075 
00076         Mage::register('tag_tag', $model);
00077 
00078         $this->_initAction()
00079             ->_addBreadcrumb($id ? Mage::helper('adminhtml')->__('Edit Tag') : Mage::helper('adminhtml')->__('New Tag'), $id ? Mage::helper('adminhtml')->__('Edit Tag') : Mage::helper('adminhtml')->__('New Tag'))
00080             ->_addContent($this->getLayout()->createBlock('adminhtml/tag_tag_edit')->setData('action', $this->getUrl('*/tag_edit/save')))
00081             ->renderLayout();
00082     }

indexAction (  ) 

Definition at line 47 of file TagController.php.

00048     {
00049         $this->_initAction()
00050             ->_addBreadcrumb(Mage::helper('adminhtml')->__('All Tags'), Mage::helper('adminhtml')->__('All Tags'))
00051             ->_setActiveMenu('catalog/tag/all')
00052             ->_addContent($this->getLayout()->createBlock('adminhtml/tag_tag'))
00053             ->renderLayout();
00054     }

massDeleteAction (  ) 

Definition at line 218 of file TagController.php.

00219     {
00220         $tagIds = $this->getRequest()->getParam('tag');
00221         if(!is_array($tagIds)) {
00222              Mage::getSingleton('adminhtml/session')->addError($this->__('Please select tag(s)'));
00223         } else {
00224             try {
00225                 foreach ($tagIds as $tagId) {
00226                     $tag = Mage::getModel('tag/tag')->load($tagId);
00227                     $tag->delete();
00228                 }
00229                 Mage::getSingleton('adminhtml/session')->addSuccess(
00230                     $this->__('Total of %d record(s) were successfully deleted', count($tagIds))
00231                 );
00232             } catch (Exception $e) {
00233                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00234             }
00235         }
00236         $ret = $this->getRequest()->getParam('ret') ? $this->getRequest()->getParam('ret') : 'index';
00237         $this->_redirect('*/*/'.$ret);
00238     }

massStatusAction (  ) 

Definition at line 240 of file TagController.php.

00241     {
00242         $tagIds = $this->getRequest()->getParam('tag');
00243         $storeId = (int)$this->getRequest()->getParam('store', 0);
00244         if(!is_array($tagIds)) {
00245             // No products selected
00246             Mage::getSingleton('adminhtml/session')->addError($this->__('Please select tag(s)'));
00247         } else {
00248             try {
00249                 foreach ($tagIds as $tagId) {
00250                     $tag = Mage::getModel('tag/tag')
00251                         ->load($tagId)
00252                         ->setStatus($this->getRequest()->getParam('status'));
00253                      $tag->save();
00254                 }
00255                 Mage::getSingleton('adminhtml/session')->addSuccess(
00256                     $this->__('Total of %d record(s) were successfully updated', count($tagIds))
00257                 );
00258             } catch (Exception $e) {
00259                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00260             }
00261         }
00262         $ret = $this->getRequest()->getParam('ret') ? $this->getRequest()->getParam('ret') : 'index';
00263         $this->_redirect('*/*/'.$ret);
00264     }

newAction (  ) 

Definition at line 56 of file TagController.php.

00057     {
00058         $this->_forward('edit');
00059     }

pendingAction (  ) 

Pending tags

Definition at line 179 of file TagController.php.

00180     {
00181         $this->_initAction()
00182             ->_addBreadcrumb(Mage::helper('adminhtml')->__('Pending Tags'), Mage::helper('adminhtml')->__('Pending Tags'))
00183             ->_setActiveMenu('catalog/tag/pending')
00184             ->_addContent($this->getLayout()->createBlock('adminhtml/tag_pending'))
00185             ->renderLayout();
00186     }

productAction (  ) 

Tagged products

Definition at line 192 of file TagController.php.

00193     {
00194         Mage::register('tagId', $this->getRequest()->getParam('tag_id'));
00195 
00196         $this->_initAction()
00197             ->_addBreadcrumb(Mage::helper('adminhtml')->__('Products'), Mage::helper('adminhtml')->__('Products'))
00198             ->_setActiveMenu('catalog/tag/product')
00199             ->_addContent($this->getLayout()->createBlock('adminhtml/tag_product'))
00200             ->renderLayout();
00201     }

saveAction (  ) 

Definition at line 84 of file TagController.php.

00085     {
00086         if ($data = $this->getRequest()->getPost()) {
00087             $data['name']=trim($data['name']);
00088             $model = Mage::getModel('tag/tag');
00089             $model->setData($data);
00090 
00091             switch( $this->getRequest()->getParam('ret') ) {
00092                 case 'all':
00093                     $url = $this->getUrl('*/*/index', array(
00094                         'customer_id' => $this->getRequest()->getParam('customer_id'),
00095                         'product_id' => $this->getRequest()->getParam('product_id'),
00096                     ));
00097                     break;
00098 
00099                 case 'pending':
00100                     $url = $this->getUrl('*/tag/pending', array(
00101                         'customer_id' => $this->getRequest()->getParam('customer_id'),
00102                         'product_id' => $this->getRequest()->getParam('product_id'),
00103                     ));
00104                     break;
00105 
00106                 default:
00107                     $url = $this->getUrl('*/*/index', array(
00108                         'customer_id' => $this->getRequest()->getParam('customer_id'),
00109                         'product_id' => $this->getRequest()->getParam('product_id'),
00110                     ));
00111             }
00112 
00113             // $tag->setStoreId(Mage::app()->getStore()->getId());
00114             try {
00115                 $model->save();
00116                 $model->aggregate();
00117                 Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Tag was successfully saved'));
00118                 Mage::getSingleton('adminhtml/session')->setTagData(false);
00119                 $this->getResponse()->setRedirect($url);
00120                 return;
00121             } catch (Exception $e) {
00122                 Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
00123                 Mage::getSingleton('adminhtml/session')->setTagData($data);
00124                 $this->_redirect('*/*/edit', array('tag_id' => $this->getRequest()->getParam('tag_id')));
00125                 return;
00126             }
00127         }
00128         $this->getResponse()->setRedirect($url);
00129     }


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