Mage_Adminhtml_Block_Rating_Edit_Tab_Form Class Reference

Inheritance diagram for Mage_Adminhtml_Block_Rating_Edit_Tab_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.

Protected Member Functions

 _prepareForm ()
 _setRatingCodes ($ratingCodes)
 _toHtml ()
 _getWarningHtml ()


Detailed Description

Definition at line 35 of file Form.php.


Member Function Documentation

_getWarningHtml (  )  [protected]

Definition at line 144 of file Form.php.

00145     {
00146         return '<div>
00147 <ul class="messages">
00148     <li class="notice-msg">
00149         <ul>
00150             <li>'.Mage::helper('rating')->__('If you do not specify a rating title for a store, the default value will be used.').'</li>
00151         </ul>
00152     </li>
00153 </ul>
00154 </div>';
00155     }

_prepareForm (  )  [protected]

Prepare form before rendering HTML

Returns:
Mage_Adminhtml_Block_Widget_Form

Reimplemented from Mage_Adminhtml_Block_Widget_Form.

Definition at line 37 of file Form.php.

00038     {
00039         $form = new Varien_Data_Form();
00040         $this->setForm($form);
00041         $defaultStore = Mage::app()->getStore(0);
00042 
00043         $fieldset = $form->addFieldset('rating_form', array(
00044             'legend'=>Mage::helper('rating')->__('Rating Title')
00045         ));
00046 
00047         $fieldset->addField('rating_code', 'text', array(
00048             'name'      => 'rating_code',
00049             'label'     => Mage::helper('rating')->__('Default Value'),
00050             'class'     => 'required-entry',
00051             'required'  => true,
00052 
00053         ));
00054 
00055 //        if (!Mage::app()->isSingleStoreMode()) {
00056             foreach(Mage::getSingleton('adminhtml/system_store')->getStoreCollection() as $store) {
00057                 $fieldset->addField('rating_code_' . $store->getId(), 'text', array(
00058                     'label'     => $store->getName(),
00059                     'name'      => 'rating_codes['. $store->getId() .']',
00060                 ));
00061             }
00062 //        }
00063 
00064         if (Mage::getSingleton('adminhtml/session')->getRatingData()) {
00065             $form->setValues(Mage::getSingleton('adminhtml/session')->getRatingData());
00066             $data = Mage::getSingleton('adminhtml/session')->getRatingData();
00067             if (isset($data['rating_codes'])) {
00068                $this->_setRatingCodes($data['rating_codes']);
00069             }
00070             Mage::getSingleton('adminhtml/session')->setRatingData(null);
00071         }
00072         elseif (Mage::registry('rating_data')) {
00073             $form->setValues(Mage::registry('rating_data')->getData());
00074             if (Mage::registry('rating_data')->getRatingCodes()) {
00075                $this->_setRatingCodes(Mage::registry('rating_data')->getRatingCodes());
00076             }
00077         }
00078 
00079         if (Mage::registry('rating_data')) {
00080             $collection = Mage::getModel('rating/rating_option')
00081                 ->getResourceCollection()
00082                 ->addRatingFilter(Mage::registry('rating_data')->getId())
00083                 ->load();
00084 
00085             $i = 1;
00086             foreach ($collection->getItems() as $item) {
00087                 $fieldset->addField('option_code_' . $item->getId() , 'hidden', array(
00088                     'required'  => true,
00089                     'name'      => 'option_title[' . $item->getId() . ']',
00090                     'value'     => ($item->getCode()) ? $item->getCode() : $i,
00091                 ));
00092 
00093                 $i ++;
00094             }
00095         }
00096         else {
00097             for ($i=1; $i<=5; $i++ ) {
00098                 $fieldset->addField('option_code_' . $i, 'hidden', array(
00099                     'required'  => true,
00100                     'name'      => 'option_title[add_' . $i . ']',
00101                     'value'     => $i,
00102                 ));
00103             }
00104         }
00105 
00106 //        if (!Mage::app()->isSingleStoreMode()) {
00107             $fieldset = $form->addFieldset('visibility_form', array(
00108                 'legend'    => Mage::helper('rating')->__('Rating Visibility'))
00109             );
00110             $fieldset->addField('stores', 'multiselect', array(
00111                 'label'     => Mage::helper('rating')->__('Visible In'),
00112 //                'required'  => true,
00113                 'name'      => 'stores[]',
00114                 'values'    => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm()
00115             ));
00116 
00117             if (Mage::registry('rating_data')) {
00118                 $form->getElement('stores')->setValue(Mage::registry('rating_data')->getStores());
00119             }
00120 //        }
00121 //        else {
00122 //            $fieldset->addField('stores', 'hidden', array(
00123 //                'name'      => 'stores[]',
00124 //                'value'     => Mage::app()->getStore(true)->getId()
00125 //            ));
00126 //        }
00127 
00128         return parent::_prepareForm();
00129     }

_setRatingCodes ( ratingCodes  )  [protected]

Definition at line 131 of file Form.php.

00131                                                      {
00132         foreach($ratingCodes as $store=>$value) {
00133             if($element = $this->getForm()->getElement('rating_code_' . $store)) {
00134                $element->setValue($value);
00135             }
00136         }
00137     }

_toHtml (  )  [protected]

Render block HTML

Returns:
string

Reimplemented from Mage_Core_Block_Template.

Definition at line 139 of file Form.php.

00140     {
00141         return $this->_getWarningHtml() . parent::_toHtml();
00142     }


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

Generated on Sat Jul 4 17:22:54 2009 for Magento by  doxygen 1.5.8