示例#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;
 }
示例#2
0
 public function addAction()
 {
     $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');
     }
     $model = new Application_Model_Page();
     $page_id = $this->_getParam('id');
     $this->view->msg = "";
     if ($this->_getParam('m') == 's') {
         $this->view->msg = "Page saved successfully";
     } else {
         if ($this->_getParam('m') == 'e') {
             $this->view->msg = "Page identifire already exist";
         }
     }
     //submit form
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $params = $form->getValues();
             $params['status'] = 1;
             if ($options["savePublish"] != "Save and Publish") {
                 $params['status'] = 0;
             }
             $usersNs = new Zend_Session_Namespace("members");
             $params['userId'] = $usersNs->userId;
             //Set SEO page URL START, added by Mahipal on 23-Feb-2011
             $sanitize = new Base_Sanitize();
             if (trim($params['identifire']) == "") {
                 $params['identifire'] = $params['title'];
             }
             if (trim($params['identifire']) != "") {
                 $params['identifire'] = $sanitize->clearInputs($params['identifire']);
                 $params['identifire'] = $sanitize->sanitize($params['identifire']);
                 $seo_url_title = $params['identifire'];
                 $actual_url = "/index/page/identifire/{$seo_url_title}";
                 $seo_url = "/{$seo_url_title}";
                 if ($seo_url != "") {
                     $seoUrl = new Application_Model_SeoUrl();
                     $seoUrl->setActualUrl($actual_url);
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             }
             //Set SEO page URL END
             $model = new Application_Model_Page($params);
             try {
                 $page_id = $model->save();
                 //$this->_helper->redirector('add','page','admin',array('id'=>$page_id,'m'=>'s'));
                 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 {
                         //$this->_helper->redirector('edit','page','admin',array('id'=>$page_id,'preview'=>'true'));
                         $identifire = $params['identifire'];
                         $this->_helper->redirector('edit', 'page', 'admin', array('id' => $page_id, 'identifire' => $identifire, 'preview' => 'true'));
                     }
                 }
             } catch (Exception $e) {
                 $this->_helper->redirector('add', 'page', 'admin', array('id' => $page_id, 'm' => 'e'));
             }
         }
     }
     $this->view->form = $form;
 }