Mage_Adminhtml_Block_Urlrewrite_Edit_Form Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Urlrewrite_Edit_Form:

Mage_Adminhtml_Block_Widget_Form Mage_Adminhtml_Block_Widget Mage_Adminhtml_Block_Template Mage_Core_Block_Template Mage_Core_Block_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ()

Protected Member Functions

 _prepareForm ()


Detailed Description

Definition at line 34 of file Form.php.


Constructor & Destructor Documentation

__construct (  ) 

Set form id and title

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 40 of file Form.php.

00041     {
00042         parent::__construct();
00043         $this->setId('urlrewrite_form');
00044         $this->setTitle(Mage::helper('adminhtml')->__('Block Information'));
00045     }


Member Function Documentation

_prepareForm (  )  [protected]

Prepare the form layout

Returns:
Mage_Adminhtml_Block_Urlrewrite_Edit_Form

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 52 of file Form.php.

00053     {
00054         $model    = Mage::registry('current_urlrewrite');
00055         $product  = Mage::registry('current_product');
00056         $category = Mage::registry('current_category');
00057 
00058         $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getData('action'), 'method' => 'post'));
00059 
00060         // set form data either from model values or from session
00061         $formValues = array(
00062             'store_id'     => $model->getStoreId(),
00063             'id_path'      => $model->getIdPath(),
00064             'request_path' => $model->getRequestPath(),
00065             'target_path'  => $model->getTargetPath(),
00066             'options'      => $model->getOptions(),
00067             'description'  => $model->getDescription(),
00068         );
00069         if ($sessionData = Mage::getSingleton('adminhtml/session')->getData('urlrewrite_data', true)) {
00070             foreach ($formValues as $key => $value) {
00071                 if (isset($sessionData[$key])) {
00072                     $formValues[$key] = $sessionData[$key];
00073                 }
00074             }
00075         }
00076 
00077         $fieldset = $form->addFieldset('base_fieldset', array(
00078             'legend'    => Mage::helper('adminhtml')->__('Urlrewrite Information')
00079         ));
00080 
00081         $fieldset->addField('is_system', 'select', array(
00082             'label'     => Mage::helper('adminhtml')->__('Type'),
00083             'title'     => Mage::helper('adminhtml')->__('Type'),
00084             'name'      => 'is_system',
00085             'required'  => true,
00086             'options'   => array(
00087                 1 => Mage::helper('adminhtml')->__('System'),
00088                 0 => Mage::helper('adminhtml')->__('Custom')
00089             ),
00090             'disabled'  => true,
00091             'value'     => $model->getIsSystem()
00092         ));
00093 
00094         // get store switcher or a hidden field with its id
00095         if (!Mage::app()->isSingleStoreMode()) {
00096             $element = $fieldset->addField('store_id', 'select', array(
00097                 'label'     => Mage::helper('adminhtml')->__('Store'),
00098                 'title'     => Mage::helper('adminhtml')->__('Store'),
00099                 'name'      => 'store_id',
00100                 'required'  => true,
00101                 'values'    => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(),
00102                 'disabled'  => true,
00103                 'value'     => $formValues['store_id'],
00104             ));
00105             if (!$model->getIsSystem()) {
00106                 $element->unsetData('disabled');
00107             }
00108         }
00109         else {
00110             $fieldset->addField('store_id', ($model->getId() ? 'hidden' : 'select'), array(
00111                 'name'      => 'store_id',
00112                 'value'     => Mage::app()->getStore(true)->getId()
00113             ));
00114         }
00115 
00116         $idPath = $fieldset->addField('id_path', 'text', array(
00117             'label'     => Mage::helper('adminhtml')->__('ID Path'),
00118             'title'     => Mage::helper('adminhtml')->__('ID Path'),
00119             'name'      => 'id_path',
00120             'required'  => true,
00121             'disabled'  => true,
00122             'value'     => $formValues['id_path']
00123         ));
00124 
00125         $requestPath = $fieldset->addField('request_path', 'text', array(
00126             'label'     => Mage::helper('adminhtml')->__('Request Path'),
00127             'title'     => Mage::helper('adminhtml')->__('Request Path'),
00128             'name'      => 'request_path',
00129             'required'  => true,
00130             'value'     => $formValues['request_path']
00131         ));
00132 
00133         $targetPath = $fieldset->addField('target_path', 'text', array(
00134             'label'     => Mage::helper('adminhtml')->__('Target Path'),
00135             'title'     => Mage::helper('adminhtml')->__('Target Path'),
00136             'name'      => 'target_path',
00137             'required'  => true,
00138             'disabled'  => true,
00139             'value'     => $formValues['target_path'],
00140         ));
00141 
00142         // auto-generate paths for new urlrewrites
00143         if (!$model->getId()) {
00144             $_product  = null;
00145             $_category = null;
00146             if ($category->getId() || $product->getId()) {
00147                 $_category = $category;
00148             }
00149             if ($product->getId()) {
00150                 $_product = $product;
00151             }
00152             if ($_category || $_product) {
00153                 $catalogUrlModel = Mage::getSingleton('catalog/url');
00154                 $idPath->setValue($catalogUrlModel->generatePath('id', $_product, $_category));
00155                 if (!isset($sessionData['request_path'])) {
00156                     $requestPath->setValue($catalogUrlModel->generatePath('request', $_product, $_category, ''));
00157                 }
00158                 $targetPath->setValue($catalogUrlModel->generatePath('target', $_product, $_category));
00159             }
00160             else {
00161                 $idPath->unsetData('disabled');
00162                 $targetPath->unsetData('disabled');
00163             }
00164         }
00165         else {
00166             if (!$model->getProductId() && !$model->getCategoryId()) {
00167                 $idPath->unsetData('disabled');
00168                 $targetPath->unsetData('disabled');
00169             }
00170         }
00171 
00172         $fieldset->addField('options', 'select', array(
00173             'label'     => Mage::helper('adminhtml')->__('Redirect'),
00174             'title'     => Mage::helper('adminhtml')->__('Redirect'),
00175             'name'      => 'options',
00176             'options'   => array(
00177                 ''   => Mage::helper('adminhtml')->__('No'),
00178                 'R'  => Mage::helper('adminhtml')->__('Temporary (302)'),
00179                 'RP' => Mage::helper('adminhtml')->__('Permanent (301)'),
00180             ),
00181             'value'     => $formValues['options']
00182         ));
00183 
00184         $fieldset->addField('description', 'textarea', array(
00185             'label'     => Mage::helper('adminhtml')->__('Description'),
00186             'title'     => Mage::helper('adminhtml')->__('Description'),
00187             'name'      => 'description',
00188             'cols'      => 20,
00189             'rows'      => 5,
00190             'value'     => $formValues['description'],
00191             'wrap'      => 'soft'
00192         ));
00193 
00194         $form->setUseContainer(true);
00195         $form->setAction(Mage::helper('adminhtml')->getUrl('*/*/save', array(
00196             'id'       => $model->getId(),
00197             'product'  => $product->getId(),
00198             'category' => $category->getId(),
00199         )));
00200         $this->setForm($form);
00201 
00202         return parent::_prepareForm();
00203     }


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