/**
  * @Created By	: Mahipal Singh Adhikari
  * @Created On	: 7-Dec-2010
  * @Description	: Manage featured plasec/cities
  */
 public function indexAction()
 {
     $this->view->title = "Manage Featured Places";
     $this->view->headTitle(" - " . $this->view->title);
     $this->view->msg = base64_decode($this->_getParam('msg', ''));
     $form = new Admin_Form_Featuredcity();
     //clear form element decorators
     $elements = $form->getElements();
     $form->clearDecorators();
     foreach ($elements as $element) {
         $element->removeDecorator('label');
         $element->removeDecorator('td');
         $element->removeDecorator('tr');
         $element->removeDecorator('row');
         $element->removeDecorator('HtmlTag');
         $element->removeDecorator('class');
         $element->removeDecorator('placement');
         $element->removeDecorator('data');
     }
     $this->view->form = $form;
     //get featured Cities
     $cityM = new Application_Model_City();
     $cityArr = $cityM->fetchAll("featured_top=1 OR featured_other=1");
     //get existing records to populate filled/selected in form
     $featuredOther = array();
     foreach ($cityArr as $row) {
         if ($row->featuredTop == 1) {
             //$options['featured_top']	=	$row->id;
         } else {
             $featuredOther[$row->id] = $row->id;
         }
     }
     //$form->getElement('featured_other')->setMultiOptions($featuredOther);
     $options['featured_other'] = $featuredOther;
     //get existing featured countries
     $countryM = new Application_Model_Country();
     $countryArr = $countryM->fetchAll("featured=1");
     $featuredCountry = array();
     foreach ($countryArr as $country) {
         $featuredCountry[$country->id] = $country->id;
     }
     $options['featured_country'] = $featuredCountry;
     $form->populate($options);
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             //re-set all values of featured_top and featured_other fileds in city table
             $resetFeaturedCity = $cityM->resetUpdateFeatured();
             $resetFeaturedCountry = $countryM->resetUpdateFeatured();
             if ($resetFeaturedCity && $resetFeaturedCountry) {
                 //update top featued city
                 //$cityM->setUpdateFeaturedTop($formData['featured_top']);
                 //update other featured cities
                 $cityM->setUpdateFeaturedOther($formData['featured_other']);
                 //update featured countries
                 $countryM->setUpdateFeatured($formData['featured_country']);
                 //set update message and redirect user
                 $this->_redirect("/admin/featured-city/index/msg/" . base64_encode("Featured places information has been updated."));
             }
         } else {
             $form->populate($formData);
         }
     }
 }