Mage_Adminhtml_Block_System_Store_Edit_Form Class Reference

Inheritance diagram for Mage_Adminhtml_Block_System_Store_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 (  ) 

Class constructor

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 41 of file Form.php.

00042     {
00043         parent::__construct();
00044         $this->setId('coreStoreForm');
00045     }


Member Function Documentation

_prepareForm (  )  [protected]

Prepare form data

return Mage_Adminhtml_Block_Widget_Form

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 52 of file Form.php.

00053     {
00054         if (Mage::registry('store_type') == 'website') {
00055             $websiteModel = Mage::registry('store_data');
00056             $showWebsiteFieldset = true;
00057             $showGroupFieldset = $showStoreFieldset = false;
00058         } elseif (Mage::registry('store_type') == 'group') {
00059             $groupModel = Mage::registry('store_data');
00060             $showGroupFieldset = true;
00061             $showWebsiteFieldset = $showStoreFieldset = false;
00062         } elseif (Mage::registry('store_type') == 'store') {
00063             $storeModel = Mage::registry('store_data');
00064             $showWebsiteFieldset = $showGroupFieldset = false;
00065             $showStoreFieldset = true;
00066         }
00067 
00068         /* @var $websiteModel Mage_Core_Model_Website */
00069         /* @var $groupModel Mage_Core_Model_Store_Group */
00070         /* @var $storeModel Mage_Core_Model_Store */
00071 
00072         $form = new Varien_Data_Form(array(
00073             'id'        => 'edit_form',
00074             'action'    => $this->getData('action'),
00075             'method'    => 'post'
00076         ));
00077 
00078         if ($showWebsiteFieldset) {
00079             if ($postData = Mage::registry('store_post_data')) {
00080                 $websiteModel->setData($postData['website']);
00081             }
00082             $fieldset = $form->addFieldset('website_fieldset', array(
00083                 'legend' => Mage::helper('core')->__('Website Information')
00084             ));
00085             /* @var $fieldset Varien_Data_Form */
00086 
00087             $fieldset->addField('website_name', 'text', array(
00088                 'name'      => 'website[name]',
00089                 'label'     => Mage::helper('core')->__('Name'),
00090                 'value'     => $websiteModel->getName(),
00091                 'required'  => true,
00092                 'disabled'  => $websiteModel->isReadOnly(),
00093             ));
00094 
00095             $fieldset->addField('website_code', 'text', array(
00096                 'name'      => 'website[code]',
00097                 'label'     => Mage::helper('core')->__('Code'),
00098                 'value'     => $websiteModel->getCode(),
00099                 'required'  => true,
00100                 'disabled'  => $websiteModel->isReadOnly(),
00101             ));
00102 
00103             $fieldset->addField('website_sort_order', 'text', array(
00104                 'name'      => 'website[sort_order]',
00105                 'label'     => Mage::helper('core')->__('Sort order'),
00106                 'value'     => $websiteModel->getSortOrder(),
00107                 'required'  => false,
00108                 'disabled'  => $websiteModel->isReadOnly(),
00109             ));
00110 
00111             if (Mage::registry('store_action') == 'edit') {
00112                 $groups = Mage::getModel('core/store_group')->getCollection()->addWebsiteFilter($websiteModel->getId())->toOptionArray();
00113                 //array_unshift($groups, array('label'=>'', 'value'=>0));
00114                 $fieldset->addField('website_default_group_id', 'select', array(
00115                     'name'      => 'website[default_group_id]',
00116                     'label'     => Mage::helper('core')->__('Default Store'),
00117                     'value'     => $websiteModel->getDefaultGroupId(),
00118                     'values'    => $groups,
00119                     'required'  => false,
00120                     'disabled'  => $websiteModel->isReadOnly(),
00121                 ));
00122             }
00123 
00124             if (!$websiteModel->getIsDefault() && $websiteModel->getStoresCount()) {
00125                 $fieldset->addField('is_default', 'checkbox', array(
00126                     'name'      => 'website[is_default]',
00127                     'label'     => Mage::helper('core')->__('Set as default'),
00128                     'value'     => 1,
00129                     'disabled'  => $websiteModel->isReadOnly(),
00130                 ));
00131             }
00132             else {
00133                 $fieldset->addField('is_default', 'hidden', array(
00134                     'name'      => 'website[is_default]',
00135                     'value'     => $websiteModel->getIsDefault()
00136                 ));
00137             }
00138 
00139             $fieldset->addField('website_website_id', 'hidden', array(
00140                 'name'  => 'website[website_id]',
00141                 'value' => $websiteModel->getId()
00142             ));
00143         }
00144 
00145         if ($showGroupFieldset) {
00146             if ($postData = Mage::registry('store_post_data')) {
00147                 $groupModel->setData($postData['group']);
00148             }
00149             $fieldset = $form->addFieldset('group_fieldset', array(
00150                 'legend' => Mage::helper('core')->__('Store Information')
00151             ));
00152 
00153             if (Mage::registry('store_action') == 'edit'
00154                 || (Mage::registry('store_action') == 'add' && Mage::registry('store_type') == 'group')) {
00155                 $websites = Mage::getModel('core/website')->getCollection()->toOptionArray();
00156                 $fieldset->addField('group_website_id', 'select', array(
00157                     'name'      => 'group[website_id]',
00158                     'label'     => Mage::helper('core')->__('Website'),
00159                     'value'     => $groupModel->getWebsiteId(),
00160                     'values'    => $websites,
00161                     'required'  => true,
00162                     'disabled'  => $groupModel->isReadOnly(),
00163                 ));
00164 
00165                 if ($groupModel->getId() && $groupModel->getWebsite()->getDefaultGroupId() == $groupModel->getId()) {
00166                     if ($groupModel->getWebsite()->getIsDefault() || $groupModel->getWebsite()->getGroupsCount() == 1) {
00167                         $form->getElement('group_website_id')->setDisabled(true);
00168 
00169                         $fieldset->addField('group_hidden_website_id', 'hidden', array(
00170                             'name'      => 'group[website_id]',
00171                             'no_span'   => true,
00172                             'value'     => $groupModel->getWebsiteId()
00173                         ));
00174                     }
00175                     else {
00176                         $fieldset->addField('group_original_website_id', 'hidden', array(
00177                             'name'      => 'group[original_website_id]',
00178                             'no_span'   => true,
00179                             'value'     => $groupModel->getWebsiteId()
00180                         ));
00181                     }
00182                 }
00183             }
00184 
00185             $fieldset->addField('group_name', 'text', array(
00186                 'name'      => 'group[name]',
00187                 'label'     => Mage::helper('core')->__('Name'),
00188                 'value'     => $groupModel->getName(),
00189                 'required'  => true,
00190                 'disabled'  => $groupModel->isReadOnly(),
00191             ));
00192 
00193             $categories = Mage::getModel('adminhtml/system_config_source_category')->toOptionArray();
00194 
00195             $fieldset->addField('group_root_category_id', 'select', array(
00196                 'name'      => 'group[root_category_id]',
00197                 'label'     => Mage::helper('core')->__('Root Category'),
00198                 'value'     => $groupModel->getRootCategoryId(),
00199                 'values'    => $categories,
00200                 'required'  => true,
00201                 'disabled'  => $groupModel->isReadOnly(),
00202             ));
00203 
00204             if (Mage::registry('store_action') == 'edit') {
00205                 $stores = Mage::getModel('core/store')->getCollection()->addGroupFilter($groupModel->getId())->toOptionArray();
00206                 //array_unshift($stores, array('label'=>'', 'value'=>0));
00207                 $fieldset->addField('group_default_store_id', 'select', array(
00208                     'name'      => 'group[default_store_id]',
00209                     'label'     => Mage::helper('core')->__('Default Store View'),
00210                     'value'     => $groupModel->getDefaultStoreId(),
00211                     'values'    => $stores,
00212                     'required'  => false,
00213                     'disabled'  => $groupModel->isReadOnly(),
00214                 ));
00215             }
00216 
00217             $fieldset->addField('group_group_id', 'hidden', array(
00218                 'name'      => 'group[group_id]',
00219                 'no_span'   => true,
00220                 'value'     => $groupModel->getId()
00221             ));
00222         }
00223 
00224         if ($showStoreFieldset) {
00225             if ($postData = Mage::registry('store_post_data')) {
00226                 $storeModel->setData($postData['store']);
00227             }
00228             $fieldset = $form->addFieldset('store_fieldset', array(
00229                 'legend' => Mage::helper('core')->__('Store View Information')
00230             ));
00231 
00232             if (Mage::registry('store_action') == 'edit'
00233                 || Mage::registry('store_action') == 'add' && Mage::registry('store_type') == 'store') {
00234                 $websites = Mage::getModel('core/website')->getCollection();
00235                 $allgroups = Mage::getModel('core/store_group')->getCollection();
00236                 $groups = array();
00237                 foreach ($websites as $website) {
00238                     $values = array();
00239                     foreach ($allgroups as $group) {
00240                         if ($group->getWebsiteId() == $website->getId()) {
00241                             $values[] = array('label'=>$group->getName(),'value'=>$group->getId());
00242                         }
00243                     }
00244                     $groups[] = array('label'=>$website->getName(),'value'=>$values);
00245                 }
00246                 $fieldset->addField('store_group_id', 'select', array(
00247                     'name'      => 'store[group_id]',
00248                     'label'     => Mage::helper('core')->__('Store'),
00249                     'value'     => $storeModel->getGroupId(),
00250                     'values'    => $groups,
00251                     'required'  => true,
00252                     'disabled'  => $storeModel->isReadOnly(),
00253                 ));
00254                 if ($storeModel->getId() && $storeModel->getGroup()->getDefaultStoreId() == $storeModel->getId()) {
00255                     if ($storeModel->getGroup() && $storeModel->getGroup()->getStoresCount() > 1) {
00256                         $form->getElement('store_group_id')->setDisabled(true);
00257 
00258                         $fieldset->addField('store_hidden_group_id', 'hidden', array(
00259                             'name'      => 'store[group_id]',
00260                             'no_span'   => true,
00261                             'value'     => $storeModel->getGroupId()
00262                         ));
00263                     }
00264                     else {
00265                         $fieldset->addField('store_original_group_id', 'hidden', array(
00266                             'name'      => 'store[original_group_id]',
00267                             'no_span'   => true,
00268                             'value'     => $storeModel->getGroupId()
00269                         ));
00270                     }
00271                 }
00272             }
00273 
00274             $fieldset->addField('store_name', 'text', array(
00275                 'name'      => 'store[name]',
00276                 'label'     => Mage::helper('core')->__('Name'),
00277                 'value'     => $storeModel->getName(),
00278                 'required'  => true,
00279                 'disabled'  => $storeModel->isReadOnly(),
00280             ));
00281             $fieldset->addField('store_code', 'text', array(
00282                 'name'      => 'store[code]',
00283                 'label'     => Mage::helper('core')->__('Code'),
00284                 'value'     => $storeModel->getCode(),
00285                 'required'  => true,
00286                 'disabled'  => $storeModel->isReadOnly(),
00287             ));
00288 
00289             $fieldset->addField('store_is_active', 'select', array(
00290                 'name'      => 'store[is_active]',
00291                 'label'     => Mage::helper('core')->__('Status'),
00292                 'value'     => $storeModel->getIsActive(),
00293                 'options'   => array(
00294                     0 => Mage::helper('adminhtml')->__('Disabled'),
00295                     1 => Mage::helper('adminhtml')->__('Enabled')),
00296                 'required'  => true,
00297                 'disabled'  => $storeModel->isReadOnly(),
00298             ));
00299 
00300             $fieldset->addField('store_sort_order', 'text', array(
00301                 'name'      => 'store[sort_order]',
00302                 'label'     => Mage::helper('core')->__('Sort order'),
00303                 'value'     => $storeModel->getSortOrder(),
00304                 'required'  => false,
00305                 'disabled'  => $storeModel->isReadOnly(),
00306             ));
00307 
00308             $fieldset->addField('store_is_default', 'hidden', array(
00309                 'name'      => 'store[is_default]',
00310                 'no_span'   => true,
00311                 'value'     => $storeModel->getIsDefault(),
00312             ));
00313 
00314             $fieldset->addField('store_store_id', 'hidden', array(
00315                 'name'      => 'store[store_id]',
00316                 'no_span'   => true,
00317                 'value'     => $storeModel->getId(),
00318                 'disabled'  => $storeModel->isReadOnly(),
00319             ));
00320         }
00321 
00322         $form->addField('store_type', 'hidden', array(
00323             'name'      => 'store_type',
00324             'no_span'   => true,
00325             'value'     => Mage::registry('store_type')
00326         ));
00327 
00328         $form->addField('store_action', 'hidden', array(
00329             'name'      => 'store_action',
00330             'no_span'   => true,
00331             'value'     => Mage::registry('store_action')
00332         ));
00333 
00334         $form->setAction($this->getUrl('*/*/save'));
00335         $form->setUseContainer(true);
00336         $this->setForm($form);
00337 
00338         return parent::_prepareForm();
00339     }


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

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