public function editAction()
 {
     $this->view->title = "Url Rewrite Management - Edit";
     $this->view->headTitle(" -  " . $this->view->title);
     $id = $this->_getParam('id');
     $model1 = new Application_Model_SeoUrl();
     $model = $model1->find($id);
     $options['actualUrl'] = $model->getActualUrl();
     $options['seoUrl'] = $model->getSeoUrl();
     $request = $this->getRequest();
     $form = new Admin_Form_SeoUrl();
     $form->populate($options);
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($form->isValid($options)) {
             $model->setOptions($options);
             $model->save($model);
             $this->view->successMsg = "Seo Url Id : {$model->getId()}' has been updated successfully!";
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
Exemple #2
0
 public function seoUrl($string)
 {
     //$request=Zend_Controller_Request_Abstract::getControllerName();
     //echo $this->view->controllerName;
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     if ($config->seofriendlyurl == "1") {
         $stringSearchArr = explode("?", $string);
         $string = $stringSearchArr[0];
         $seoUrlM = new Application_Model_SeoUrl();
         $seoUrl = $seoUrlM->fetchRow("actual_url='{$string}'");
         if (false !== $seoUrl) {
             if (isset($stringSearchArr[1])) {
                 return $seoUrl->getSeoUrl() . "?" . $stringSearchArr[1];
             } else {
                 return $seoUrl->getSeoUrl();
             }
         }
         return $string;
     } else {
         return $string;
     }
 }
Exemple #3
0
 public function routeStartup(Zend_Controller_Request_Abstract $request)
 {
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     if ($config->site_maintenance == "1") {
         $appNs = new Zend_Session_Namespace("app");
         if ($appNs->userName == "" && $appNs->password == "") {
             $request->setRequestUri('/index/app-login/');
         }
     }
     if ($config->seofriendlyurl == "1") {
         $seoUrlM = new Application_Model_SeoUrl();
         $stringURI = $request->getRequestUri();
         $stringSearchArr = explode("?", $stringURI);
         $stringSeoUrl = $stringSearchArr[0];
         $seoUrl = $seoUrlM->fetchRow("seo_url='{$stringSeoUrl}'");
         if (false !== $seoUrl) {
             if (isset($stringSearchArr[1])) {
                 $request->setRequestUri($seoUrl->getActualUrl() . "?" . $stringSearchArr[1]);
             } else {
                 $request->setRequestUri($seoUrl->getActualUrl());
             }
         }
     }
 }
Exemple #4
0
 public function editPageAction()
 {
     $id = $this->_getParam('id');
     $this->view->user_id = $id;
     $model1 = new Application_Model_Page();
     $model = $model1->find($id);
     if (false === $model) {
         $this->_flashMessenger->addMessage(array('error' => 'Invalid request! Please try again.'));
         $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/hr/employees'));
     }
     $options = array('title' => $model->getTitle(), 'identifire' => $model->getIdentifire(), 'content' => $model->getContent(), 'metaTitle' => $model->getMetaTitle(), 'metaDescription' => $model->getMetaDescription(), 'metaKeyword' => $model->getMetaKeyword(), 'status' => $model->getStatus());
     $request = $this->getRequest();
     $form = new Application_Form_Page();
     $form->populate($options);
     $options = $request->getPost();
     if ($request->isPost()) {
         if ($form->isValid($options)) {
             $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";
                 $actual_url = "/employee/page/identifire/{$model->getIdentifire()}";
                 $new_actual_url = "/employee/page/identifire/{$seo_url_title}";
                 $seo_url = "/{$seo_url_title}";
                 $seoUrlM = new Application_Model_SeoUrl();
                 $soeUrl = $seoUrlM->fetchRow("actual_url='{$actual_url}'");
                 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();
                     }
                 }
             }
             $model->setOptions($options);
             $model->save();
             $this->_flashMessenger->addMessage(array('success' => 'Page has been updated successfully!'));
             $this->_helper->_redirector->gotoUrl($this->view->seoUrl('/cms/edit-page/id/' . $id));
         } else {
             $this->_flashMessenger->addMessage(array('error' => 'Unable to save the data. Please provide valid inputs and try again.'));
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
 public function editAction()
 {
     $id = $this->_getParam('id');
     $preview = false;
     $preview = $this->_getParam('preview');
     //echo "diana==>".base64_encode(85);
     $this->view->id = $id;
     $this->view->preview = $preview;
     $page = new Application_Model_Advice();
     $page = $page->find($id);
     $options = array('categoryId' => $page->getCategoryId(), 'title' => $page->getTitle(), 'identifire' => $page->getIdentifire(), 'name' => $page->getName(), 'content' => $page->getContent(), 'synopsis' => $page->getSynopsis(), 'metaTitle' => $page->getMetaTitle(), 'metaDescription' => $page->getMetaDescription(), 'metaKeyword' => $page->getMetaKeyword(), 'status' => $page->getStatus(), 'name' => $page->getName(), 'userId' => $page->getUserId());
     $request = $this->getRequest();
     $form = new Admin_Form_Advice();
     //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->type = $page->getType();
     $this->view->imgName = $page->getName();
     $form->populate($options);
     if ($request->isPost()) {
         $options = $request->getPost();
         if (trim($options['identifire']) == "") {
             $sanitize = new Base_Sanitize();
             $options['identifire'] = $options['title'];
         }
         if (trim($options['identifire']) != "") {
             $sanitize = new Base_Sanitize();
             $options['identifire'] = $sanitize->clearInputs($options['identifire']);
             $options['identifire'] = $sanitize->sanitize($options['identifire']);
             //update seo url table
             $seo_url_title = $options['identifire'];
             $adviceM = new Application_Model_Advice();
             $advice = $adviceM->find($id);
             $seo_url = "";
             $actual_url = "/advice/detail/id/{$id}";
             if (false !== $advice) {
                 $sanitizeM = new Base_Sanitize();
                 //$category_id	=	$advice->getCategoryId();
                 $category_id = $options['categoryId'];
                 $categoryM = new Application_Model_Category();
                 $category = $categoryM->find($category_id);
                 if (false !== $category) {
                     $seo_url = "/advice/" . $sanitizeM->sanitize($category->getName()) . "/" . $seo_url_title;
                 }
             }
             $seoUrlM = new Application_Model_SeoUrl();
             $soeUrl = $seoUrlM->fetchRow("actual_url='{$actual_url}'");
             if (false !== $soeUrl) {
                 if ($seo_url != "") {
                     $soeUrl->setSeoUrl($seo_url);
                     $soeUrl->save();
                 }
             } else {
                 if ($seo_url != "") {
                     $seoUrl = new Application_Model_SeoUrl();
                     $seoUrl->setActualUrl($actual_url);
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             }
         }
         //save data
         if ($form->isValid($options)) {
             //set previous image name if not uploaded new one
             $options['name'] = $page->getName();
             /*------------------------------ Image Upload START ---------------------------*/
             $upload = new Zend_File_Transfer_Adapter_Http();
             if ($upload->isValid()) {
                 $upload->setDestination("images/advice/");
                 try {
                     $upload->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 //unlink previous uploaded image files
                 unlink("images/advice/" . $page->getName());
                 unlink("images/advice/thumb_" . $page->getName());
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('name');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "advice_" . time() . ".{$ext}";
                 $targetPath = 'images/advice/' . $target_file_name;
                 $targetPathThumb = 'images/advice/thumb_' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(128, 84);
                 $thumb->save($targetPathThumb);
                 // file name
                 $options['name'] = $target_file_name;
             }
             /*------------------------------ Image Upload 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','advice',"admin",Array('msg'=>base64_encode("'{$page->getTitle()}' has been updated successfully!")));
             if ($options["savePublish"] == "Save and Publish") {
                 $_SESSION['errorMsg'] = "Article has been saved & published successfully.";
                 $this->_helper->redirector('index', 'advice', 'admin');
             } else {
                 if ($options["saveUnpublish"] == "Save and Unpublish") {
                     $_SESSION['errorMsg'] = "Article has been saved successfully.";
                     $this->_helper->redirector('index', 'advice', 'admin');
                 } else {
                     $this->_helper->redirector('edit', 'advice', 'admin', array('id' => $id, 'preview' => 'true'));
                 }
             }
         } else {
             $form->reset();
             $form->populate($options);
         }
     }
     $this->view->form = $form;
 }
 public function addAction()
 {
     $request = $this->getRequest();
     $form = new Admin_Form_Articles();
     //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_Articles();
     $page_id = $this->_getParam('id');
     $this->view->msg = "";
     if ($this->_getParam('m') == 's') {
         $this->view->msg = "Article has been saved successfully.";
     }
     //select logged in user as default seleted for Author
     $usersNs = new Zend_Session_Namespace("members");
     $author = array('userId' => $usersNs->userId);
     $form->populate($author);
     /*-----------------------------------------*/
     if ($this->getRequest()->isPost()) {
         $options = $request->getPost();
         if (trim($options['identifire']) == "") {
             $options['identifire'] = $options['title'];
         }
         if (trim($options['identifire']) != "") {
             $sanitize = new Base_Sanitize();
             $options['identifire'] = $sanitize->clearInputs($options['identifire']);
             $options['identifire'] = $sanitize->sanitize($options['identifire']);
         }
         if ($form->isValid($options)) {
             /*------------------------------Image Upload ---------------------------*/
             $upload = new Zend_File_Transfer_Adapter_Http();
             $target_file_name = "";
             if ($upload->isValid()) {
                 $upload->setDestination("images/articles/");
                 try {
                     $upload->receive();
                 } catch (Zend_File_Transfer_Exception $e) {
                     $msg = $e->getMessage();
                 }
                 $upload->setOptions(array('useByteString' => false));
                 $file_name = $upload->getFileName('image');
                 $cardImageTypeArr = explode(".", $file_name);
                 $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]);
                 $target_file_name = "art_" . time() . ".{$ext}";
                 $targetPath = 'images/articles/' . $target_file_name;
                 $targetPathThumb = 'images/articles/thumb_' . $target_file_name;
                 $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true));
                 $filterFileRename->filter($file_name);
                 $thumb = Base_Image_PhpThumbFactory::create($targetPath);
                 $thumb->resize(100, 64);
                 $thumb->save($targetPathThumb);
             }
             //end if
             /*------------------------------Image Upload ---------------------------*/
             $params = $options;
             $params['status'] = 1;
             if ($options["savePublish"] != "Save and Publish") {
                 $params['status'] = 0;
             }
             //commented by mahipal on 29-dec-2010 and replaced with user dropdown list
             //$usersNs = new Zend_Session_Namespace("members");
             //$params['userId']		=	$usersNs->userId;
             $params['image'] = $target_file_name;
             // file name
             $model = new Application_Model_Articles($params);
             $id = $page_id = $model->save();
             $seo_url_title = $options['identifire'];
             $articleM = new Application_Model_Articles();
             $article = $articleM->find($id);
             $seo_url = "";
             $actual_url = "/work-study-volunteer/article-detail/id/{$id}";
             if (false !== $article) {
                 $sanitizeM = new Base_Sanitize();
                 $category_id = $article->getCategoryId();
                 $categoryM = new Application_Model_Category();
                 $category = $categoryM->find($category_id);
                 if (false !== $category) {
                     //$seo_url="/work-study-volunteer/".$category->getType()."/".$sanitizeM->sanitize($category->getName())."/".$seo_url_title;
                     $seo_url = "/work-study-volunteer/" . $sanitizeM->sanitize($category->getName()) . "/" . $seo_url_title;
                 }
             }
             $seoUrlM = new Application_Model_SeoUrl();
             $seoUrl = $seoUrlM->fetchRow("actual_url='{$actual_url}'");
             if (false !== $seoUrl) {
                 if ($seo_url != "") {
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             } else {
                 if ($seo_url != "") {
                     $seoUrl = new Application_Model_SeoUrl();
                     $seoUrl->setActualUrl($actual_url);
                     $seoUrl->setSeoUrl($seo_url);
                     $seoUrl->save();
                 }
             }
             //$this->_helper->redirector('add','articles','admin',array('id'=>$page_id,'m'=>'s'));
             if ($options["savePublish"] == "Save and Publish") {
                 $_SESSION['errorMsg'] = "Article has been saved & published successfully.";
                 $this->_helper->redirector('index', 'articles', 'admin');
             } else {
                 if ($options["saveUnpublish"] == "Save and Unpublish") {
                     $_SESSION['errorMsg'] = "Article has been saved successfully.";
                     $this->_helper->redirector('index', 'articles', 'admin');
                 } else {
                     $this->_helper->redirector('edit', 'articles', 'admin', array('id' => $page_id, 'preview' => 'true'));
                 }
             }
         }
         //end if
     }
     //end if
     $this->view->form = $form;
 }
Exemple #7
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;
 }
Exemple #8
0
 public function blocks($region, $path = "/modules/block/views/blocks")
 {
     //var_dump ($this->request);
     $request_uri = $_SERVER['REQUEST_URI'];
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
     if ($config->seofriendlyurl == "1") {
         $seoUrlM = new Application_Model_SeoUrl();
         $seoUrl = $seoUrlM->fetchRow("seo_url='{$request_uri}'");
         if (false !== $seoUrl) {
             $request_uri = $seoUrl->getActualUrl();
         }
     }
     $regionM = new Block_Model_BlockRegion();
     $regionO = $regionM->fetchRow("alias='{$region}'");
     if ($regionO === false) {
         return false;
     }
     $blockM = new Block_Model_Block();
     $where = " (block_region_id='{$regionO->getId()}' || block_region_id='0')   and status='1'";
     $order = "weight desc";
     $blocks = $blockM->fetchAll($where, $order);
     if (count($blocks) > 0) {
         $requestUrl = trim($request_uri);
         $path = APPLICATION_PATH . $path . "/" . $region;
         $this->view->addScriptPath($path);
         foreach ($blocks as $_block) {
             $flag = false;
             $arrPaths = unserialize($_block->getVisibilityPaths());
             foreach ($arrPaths as $_path) {
                 $_path = trim($_path);
                 if ($_path == $requestUrl) {
                     $flag = true;
                     break;
                     //break the path loop
                 } else {
                     if (false !== strpos($_path, "*")) {
                         $_path = substr($_path, 0, -2);
                         if ($_path != "") {
                             if (false !== strpos($requestUrl, $_path)) {
                                 $flag = true;
                                 break;
                                 //break the path loop
                             }
                         } else {
                             $flag = true;
                             break;
                             //break the path loop
                         }
                     }
                 }
             }
             //end of path loop
             if ($flag == true) {
                 if (trim($_block->getBody()) == "") {
                     if ($_block->getAlias() == "recent-blog" && ($requestUrl == "/journal/my-journals" || $requestUrl == "/journal/journal-settings")) {
                         //no need to display the block
                     } else {
                         echo $this->view->render($_block->getAlias() . ".phtml");
                     }
                 } else {
                     echo $_block->getBody();
                 }
             }
         }
     }
 }
Exemple #9
0
 private function setModel($row)
 {
     $model = new Application_Model_SeoUrl();
     $model->setId($row->id)->setActualUrl($row->actual_url)->setSeoUrl($row->seo_url);
     return $model;
 }