Пример #1
0
 /**
  * Prepare form before rendering HTML
  *
  * @return Mage_Adminhtml_Block_Widget_Form
  */
 protected function _prepareForm()
 {
     $form = new Varien_Data_Form(array('id' => 'edit_form', 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))), 'method' => 'post', 'enctype' => 'multipart/form-data'));
     $fieldset = $form->addFieldset('testimonial_form', array('legend' => Mage::helper('turnkeye_testimonial')->__('Testimonial'), 'class' => 'fieldset-wide'));
     $fieldset->addField('testimonial_position', 'text', array('name' => 'testimonial_position', 'label' => Mage::helper('turnkeye_testimonial')->__('Position'), 'style' => 'width:100px !important'));
     $fieldset->addField('testimonial_img', 'image', array('name' => 'testimonial_img', 'label' => Mage::helper('turnkeye_testimonial')->__('Image')));
     $fieldset->addField('testimonial_name', 'text', array('name' => 'testimonial_name', 'label' => Mage::helper('turnkeye_testimonial')->__('Name'), 'class' => 'required-entry', 'required' => true));
     $fieldset->addField('testimonial_text', 'editor', array('name' => 'testimonial_text', 'label' => Mage::helper('turnkeye_testimonial')->__('Text'), 'title' => Mage::helper('turnkeye_testimonial')->__('Text'), 'style' => 'width:100%;height:300px;', 'required' => true, 'config' => Mage::getSingleton('turnkeye_testimonial/wysiwyg_config')->getConfig()));
     $fieldset->addField('status', 'select', array('name' => 'status', 'label' => Mage::helper('turnkeye_testimonial')->__('Status'), 'required' => true, 'values' => Turnkeye_Testimonial_Model_Testimonial_Status::getOptions()));
     $fieldset->addField('testimonial_sidebar', 'select', array('label' => Mage::helper('turnkeye_testimonial')->__('Show in sidebox'), 'name' => 'testimonial_sidebar', 'values' => array(array('value' => 1, 'label' => Mage::helper('core')->__('Yes')), array('value' => 0, 'label' => Mage::helper('core')->__('No')))));
     if (Mage::registry('turnkeye_testimonial')) {
         $form->setValues(Mage::registry('turnkeye_testimonial')->getData());
     }
     $form->setUseContainer(true);
     $this->setForm($form);
     return parent::_prepareForm();
 }
Пример #2
0
 /**
  * Group change status action
  *
  * @return void
  */
 public function massChangeStatusAction()
 {
     $testimonialIds = $this->getMassTestimonialIds();
     $status = (string) $this->getRequest()->getParam('status');
     if (empty($testimonialIds)) {
         $this->_getSession()->addError($this->__('Please select testimonial(s).'));
     } else {
         if (!Turnkeye_Testimonial_Model_Testimonial_Status::isValidStatus($status)) {
             $this->_getSession()->addError($this->__('Selected status is not available.'));
         } else {
             try {
                 foreach ($testimonialIds as $id) {
                     Mage::getModel('turnkeye_testimonial/testimonial')->load($id)->setData('status', $status)->save();
                 }
                 $this->_getSession()->addSuccess($this->__('Total of %d record(s) have been updated.', count($testimonialIds)));
             } catch (Mage_Core_Exception $e) {
                 $this->_getSession()->addError($e->getMessage());
             } catch (Exception $e) {
                 $this->_getSession()->addException($e, $this->__('An error occurred while updating the testimonial(s) status.'));
             }
         }
     }
     $this->_redirect('*/*/' . $this->getRequest()->getParam('ret', 'index'));
 }