Mage_Adminhtml_Block_Urlrewrite_Edit Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Urlrewrite_Edit:

Mage_Adminhtml_Block_Widget_Container Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 getButtonsHtml ($area=null)
 getUrlrewriteId ()
 getProductId ()
 getCategoryId ()
 isMode ($mode)
 updateModeLayout ($mode=null)

Protected Member Functions

 _prepareLayout ()
 _setFormChild ()

Protected Attributes

 $_controller = 'urlrewrite'
 $_buttonsHtml


Detailed Description

Definition at line 34 of file Edit.php.


Member Function Documentation

_prepareLayout (  )  [protected]

Prepare page layout, basing on different registry and request variables

Generates layout of: creation modes selector, products grid, categories tree, urlrewrite edit form

Returns:
Mage_Adminhtml_Block_Urlrewrite_Edit

Reimplemented from Mage_Adminhtml_Block_Widget_Container.

Definition at line 56 of file Edit.php.

00057     {
00058         $this->setTemplate('urlrewrite/edit.phtml');
00059         $this->_addButton('back', array(
00060             'label'   => Mage::helper('adminhtml')->__('Back'),
00061             'onclick' => 'setLocation(\'' . Mage::helper('adminhtml')->getUrl('*/*/') . '\')',
00062             'class'   => 'back',
00063             'level'   => -1
00064         ));
00065 
00066         // links to products/categories (if any) selectors
00067         if ($this->getProductId()) {
00068             $this->setChild('product_link', $this->getLayout()->createBlock('adminhtml/urlrewrite_link')
00069                 ->setData(array(
00070                     'item_url' => Mage::helper('adminhtml')->getUrl('*/*/*') . 'product',
00071                     'item'     => Mage::registry('current_product'),
00072                     'label'    => Mage::helper('adminhtml')->__('Product:')
00073                 ))
00074             );
00075         }
00076         if ($this->getCategoryId()) {
00077             $itemUrl = Mage::helper('adminhtml')->getUrl('*/*/*') . 'category';
00078             if ($this->getProductId()) {
00079                 $itemUrl = Mage::helper('adminhtml')->getUrl('*/*/*', array('product' => $this->getProductId())) . 'category';
00080             }
00081             $this->setChild('category_link', $this->getLayout()->createBlock('adminhtml/urlrewrite_link')
00082                 ->setData(array(
00083                     'item_url' => $itemUrl,
00084                     'item'     => Mage::registry('current_category'),
00085                     'label'    => Mage::helper('adminhtml')->__('Category:')
00086                 ))
00087             );
00088         }
00089 
00090         $this->_headerText = Mage::helper('adminhtml')->__('Add New Urlrewrite');
00091 
00092         // edit form for existing urlrewrite
00093         if ($this->getUrlrewriteId()) {
00094             $this->_headerText = Mage::helper('adminhtml')->__('Edit Urlrewrite');
00095             $this->_setFormChild();
00096         }
00097         elseif ($this->getProductId()) {
00098             $this->_headerText = Mage::helper('adminhtml')->__('Add Urlrewrite for a Product');
00099 
00100             // edit form for product with or without category
00101             if ($this->getCategoryId() || !$this->isMode('category')) {
00102                 $this->_setFormChild();
00103             }
00104             // categories selector & skip categories button
00105             else {
00106                 $this->setChild('categories_tree', $this->getLayout()->createBlock('adminhtml/urlrewrite_category_tree'));
00107                 $this->setChild('skip_categories',
00108                     $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
00109                         'label'   => Mage::helper('adminhtml')->__('Skip category selection'),
00110                         'onclick' => 'window.location = \'' . Mage::helper('adminhtml')->getUrl('*/*/*', array(
00111                             'product' => $this->getProductId()
00112                         )) . '\'',
00113                         'class'   => 'save',
00114                         'level'   => -1
00115                     ))
00116                 );
00117                 $this->_updateButton('back', 'onclick', 'setLocation(\'' . Mage::helper('adminhtml')->getUrl('*/*/edit') . 'product\')');
00118             }
00119         }
00120         // edit form for category
00121         elseif ($this->getCategoryId()) {
00122             $this->_headerText = Mage::helper('adminhtml')->__('Add Urlrewrite for a Category');
00123             $this->_setFormChild();
00124         }
00125         // modes selector and products/categories selectors, as well as edit form for custom urlrewrite
00126         else {
00127             $this->setChild('selector', $this->getLayout()->createBlock('adminhtml/urlrewrite_selector'));
00128 
00129             if ($this->isMode('id')) {
00130                 $this->updateModeLayout('id');
00131             }
00132             elseif ($this->isMode('product')) {
00133                 $this->updateModeLayout('product');
00134             }
00135             elseif ($this->isMode('category')) {
00136                 $this->updateModeLayout('category');
00137             }
00138             else {
00139                 $this->updateModeLayout();
00140             }
00141         }
00142 
00143         return parent::_prepareLayout();
00144     }

_setFormChild (  )  [protected]

Add edit form as child block and add appropriate buttons

Returns:
Mage_Adminhtml_Block_Urlrewrite_Edit

Definition at line 151 of file Edit.php.

00152     {
00153         $this->setChild('form', Mage::getBlockSingleton('adminhtml/urlrewrite_edit_form'));
00154         if ($this->getUrlrewriteId()) {
00155             $this->_addButton('reset', array(
00156                 'label'   => Mage::helper('adminhtml')->__('Reset'),
00157                 'onclick' => '$(\'edit_form\').reset()',
00158                 'class'   => 'scalable',
00159                 'level'   => -1
00160             ));
00161             $this->_addButton('delete', array(
00162                 'label'   => Mage::helper('adminhtml')->__('Delete'),
00163                 'onclick' => 'deleteConfirm(\'' . Mage::helper('adminhtml')->__('Are you sure you want to do this?')
00164                     . '\', \'' . Mage::helper('adminhtml')->getUrl('*/*/delete', array('id' => $this->getUrlrewriteId())) . '\')',
00165                 'class'   => 'scalable delete',
00166                 'level'   => -1
00167             ));
00168         }
00169         $this->_addButton('save', array(
00170             'label'   => Mage::helper('adminhtml')->__('Save'),
00171             'onclick' => 'editForm.submit()',
00172             'class'   => 'save',
00173             'level'   => -1
00174         ));
00175 
00176         // update back button link
00177         $params = array();
00178         $suffix = '';
00179         $action = '';
00180         if (!$this->getUrlrewriteId()) {
00181             $action = 'edit';
00182             if ($this->getProductId()) {
00183                 $suffix = 'category';
00184                 $params['product'] = $this->getProductId();
00185             }
00186             elseif ($this->getCategoryId()) {
00187                 $suffix = 'category';
00188             }
00189         }
00190         $this->_updateButton('back', 'onclick', 'setLocation(\'' . Mage::helper('adminhtml')->getUrl('*/*/' . $action, $params) . $suffix . '\')');
00191 
00192         return $this;
00193     }

getButtonsHtml ( area = null  ) 

Get container buttons HTML

Since buttons are set as children, we remove them as children after generating them not to duplicate them in future

Returns:
string

Reimplemented from Mage_Adminhtml_Block_Widget_Container.

Definition at line 203 of file Edit.php.

00204     {
00205         if (null === $this->_buttonsHtml) {
00206             $this->_buttonsHtml = parent::getButtonsHtml();
00207             foreach ($this->_children as $alias => $child) {
00208                 if (false !== strpos($alias, '_button')) {
00209                     $this->unsetChild($alias);
00210                 }
00211             }
00212         }
00213         return $this->_buttonsHtml;
00214     }

getCategoryId (  ) 

Return current category instance id

Returns:
int

Definition at line 241 of file Edit.php.

00242     {
00243         return Mage::registry('current_category')->getId();
00244     }

getProductId (  ) 

Get current product instance id

Returns:
int

Definition at line 231 of file Edit.php.

00232     {
00233         return Mage::registry('current_product')->getId();
00234     }

getUrlrewriteId (  ) 

Get current urlrewrite instance id

Returns:
int

Definition at line 221 of file Edit.php.

00222     {
00223         return Mage::registry('current_urlrewrite')->getId();
00224     }

isMode ( mode  ) 

Check whether specified selection mode is set in request

Parameters:
string $mode
Returns:
bool

Definition at line 252 of file Edit.php.

00253     {
00254         return $this->getRequest()->has($mode);
00255     }

updateModeLayout ( mode = null  ) 

Update layout by specified mode code

Parameters:
string $mode
Returns:
Mage_Adminhtml_Block_Urlrewrite_Edit
See also:
Mage_Adminhtml_Block_Urlrewrite_Selector

Definition at line 264 of file Edit.php.

00265     {
00266         if (!$mode) {
00267             $modes = array_keys(Mage::getBlockSingleton('adminhtml/urlrewrite_selector')->getModes());
00268             $mode  = array_shift($modes);
00269         }
00270 
00271         // edit form for new custom urlrewrite
00272         if ('id' === $mode) {
00273             $this->_setFormChild();
00274         }
00275         // products grid
00276         elseif ('product' === $mode) {
00277             $this->setChild('products_grid', $this->getLayout()->createBlock('adminhtml/urlrewrite_product_grid'));
00278         }
00279         // categories tree
00280         elseif ('category' === $mode) {
00281             $this->setChild('categories_tree', $this->getLayout()->createBlock('adminhtml/urlrewrite_category_tree'));
00282         }
00283         return $this;
00284     }


Member Data Documentation

$_buttonsHtml [protected]

Definition at line 48 of file Edit.php.

$_controller = 'urlrewrite' [protected]

Reimplemented from Mage_Adminhtml_Block_Widget_Container.

Definition at line 41 of file Edit.php.


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

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