Beispiel #1
0
 /**
  * @Created By : Mahipal Singh Adhikari
  * @Created On : 28-Feb-2011
  * @Description: Edit Advice hom page content CMS
  */
 public function homeAction()
 {
     $identifire = "advice";
     $page = new Application_Model_Page();
     $page = $page->fetchRow("identifire='{$identifire}'");
     $options = array('title' => $page->getTitle(), 'identifire' => $page->getIdentifire(), 'content' => $page->getContent(), 'metaTitle' => $page->getMetaTitle(), 'metaDescription' => $page->getMetaDescription(), 'metaKeyword' => $page->getMetaKeyword(), 'status' => $page->getStatus());
     $request = $this->getRequest();
     $form = new Admin_Form_Page();
     //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');
     }
     $form->removeElement("identifire");
     $form->populate($options);
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($form->isValid($options)) {
             $page->setOptions($options);
             $resDB = $page->save();
             if ($resDB) {
                 $errorMsg = "Home page content has been been saved.";
             } else {
                 $errorMsg = "Error occured, please try again later.";
             }
             $this->view->errorMsg = $errorMsg;
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
Beispiel #2
0
 public function editAction()
 {
     $id = $this->_getParam('id');
     $preview = false;
     $preview = $this->_getParam('preview');
     $this->view->identifire = $this->_getParam('identifire');
     $this->view->preview = $preview;
     $form = new Admin_Form_Page();
     //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');
     }
     $page = new Application_Model_Page();
     $page = $page->find($id);
     $options = array('title' => $page->getTitle(), 'identifire' => $page->getIdentifire(), 'content' => $page->getContent(), 'metaTitle' => $page->getMetaTitle(), 'metaDescription' => $page->getMetaDescription(), 'metaKeyword' => $page->getMetaKeyword(), 'status' => $page->getStatus());
     $request = $this->getRequest();
     $form->populate($options);
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($form->isValid($options)) {
             //update SEO URL START
             /*
             $sanitize=  new Base_Sanitize();
             if(trim($options['identifire'])=="")
             {
             	$options['identifire']=$options['title'];
             }
             if(trim($options['identifire'])!="")
             {
             	$options['identifire']	=	$sanitize->clearInputs($options['identifire']);
             	$options['identifire']	=	$sanitize->sanitize($options['identifire']);
             
             	//update seo url table
             	$seo_url_title	=	$options['identifire'];
             	
             	$actual_url		=	"/index/contact";
             	$seo_url		=	"/contact";
             	if($page->getIdentifire()!="contact")
             	{
             		$actual_url		=	"/index/page/identifire/{$page->getIdentifire()}";
             		$new_actual_url	=	"/index/page/identifire/{$seo_url_title}";
             		$seo_url		=	"/{$seo_url_title}";
             	}
             	$seoUrlM	=	new Application_Model_SeoUrl();
             	$soeUrl		=	$seoUrlM->fetchRow("actual_url='{$actual_url}'");
             	//print_r($soeUrl);
             	//exit;
             	if(false!==$soeUrl)
             	{
             		if($seo_url<>"")
             		{ 
             			$soeUrl->setActualUrl($new_actual_url);
             			$soeUrl->setSeoUrl($seo_url);
             			$soeUrl->save();
             		}
             	}
             	else
             	{
             		if($seo_url<>"")
             		{
             			$seoUrl = new Application_Model_SeoUrl();
             			$seoUrl->setActualUrl($new_actual_url);
             			$seoUrl->setSeoUrl($seo_url);
             			$seoUrl->save();
             		}                       
             	}
             }
             //update SEO URL END
             */
             $options['status'] = $page->getStatus();
             if ($options["saveUnpublish"] == "Save and Unpublish") {
                 $options['status'] = 0;
             }
             if ($options["savePublish"] == "Save and Publish") {
                 $options['status'] = 1;
             }
             $page->setOptions($options);
             $page->save();
             //return $this->_helper->redirector('index','page',"admin",Array('msg'=>base64_encode("'{$page->getTitle()}' has been updated successfully!")));
             if ($options["savePublish"] == "Save and Publish") {
                 $_SESSION['errorMsg'] = "Page has been saved & published successfully.";
                 $this->_helper->redirector('index', 'page', 'admin');
             } else {
                 if ($options["saveUnpublish"] == "Save and Unpublish") {
                     $_SESSION['errorMsg'] = "Page has been saved successfully.";
                     $this->_helper->redirector('index', 'page', 'admin');
                 } else {
                     $identifire = $options['identifire'];
                     $this->_helper->redirector('edit', 'page', 'admin', array('id' => $id, 'identifire' => $identifire, 'preview' => 'true'));
                 }
             }
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
     $this->view->pageIdentifire = $page->getIdentifire();
     $this->view->fixedPages = $this->fixedPages;
 }