public function addAction() { $userNs = new Zend_Session_Namespace("members"); $this->view->title = "City - Add"; $this->view->headTitle(" - " . $this->view->title); $form = new Admin_Form_City(); $this->view->form = $form; $this->view->successMsg = ""; if ($this->getRequest()->isPost()) { $formData = $this->getRequest()->getPost(); if ($form->isValid($formData)) { $upload = new Zend_File_Transfer_Adapter_Http(); //---main image if ($upload->isValid('logo')) { $upload->setDestination("images/logo/"); try { $upload->receive('logo'); } catch (Zend_File_Transfer_Exception $e) { $msg = $e->getMessage(); } $upload->setOptions(array('useByteString' => false)); $id = time(); $file_name = $upload->getFileName('logo'); $cardImageTypeArr = explode(".", $file_name); $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]); $target_file_name = "logo_" . $id . ".{$ext}"; $targetPath = 'media/picture/city/logo/' . $target_file_name; $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true)); $filterFileRename->filter($file_name); $formData['logo'] = $target_file_name; /*--- Generate Thumbnail ---*/ $thumb = Base_Image_PhpThumbFactory::create($targetPath); $thumb->resize(100, 100); $thumb->save($targetPath = 'media/picture/city/logo/thumb_' . $target_file_name); } $usersNs = new Zend_Session_Namespace("members"); $formData['userId'] = $usersNs->userId; $this->view->warningMsg = ''; $model = new Application_Model_City($formData); $id = $model->save($model); $form->reset(); $this->view->successMsg = "City added successfully. City Id : {$id}"; } else { $form->populate($formData); } } }
public function thumbAction() { $path = base64_decode($this->_getParam('path')); $size = $this->_getParam('size', 'small'); if ($size == "small") { $width = 80; $height = 80; } elseif ($size == "medium") { $width = 100; $height = 100; } elseif ($size == "large") { $width = 150; $height = 150; } else { $width = 200; $height = 200; } $thumb = Base_Image_PhpThumbFactory::create($path); $thumb->resize($width, $height); $thumb->show(); exit; }
public function thumbAction() { $path = base64_decode($this->_getParam('path')); $width = 70; $height = 70; $thumb = Base_Image_PhpThumbFactory::create($path); $thumb->resize($width, $height); $thumb->show(); exit; }
public function archiveAction() { $arrPostVal = $this->getRequest()->getParams(); $albumId = $arrPostVal['albumId']; $usersNs = new Zend_Session_Namespace("members"); $userName = $usersNs->userUsername; $fileName = PUBLIC_PATH . '/tmp/' . $userName . '.zip'; $downloadPath = '/tmp/' . $userName . '.zip'; $folderPath = PUBLIC_PATH . '/tmp/' . $userName; $this->deleteDirectory($folderPath); // Remove Folder if exist if (is_file($fileName)) { unlink($fileName); } mkdir($folderPath, 0777); $objModelAlbumPhoto = new Album_Model_AlbumPhoto(); $whereAlbumPhoto = "album_id='{$albumId}'"; $arrAlbumPhoto = $objModelAlbumPhoto->fetchAll($whereAlbumPhoto); foreach ($arrAlbumPhoto as $albumPhoto) { $filePath = PUBLIC_PATH . "/media/album/default/" . $albumPhoto->image; $targetPath = $folderPath . "/" . $albumPhoto->image; $fileTransfer = Base_Image_PhpThumbFactory::create($filePath); $fileTransfer->save($targetPath); } set_time_limit(0); $filter = new Zend_Filter_Compress(array('adapter' => 'zip', 'options' => array('archive' => $fileName))); $compressed = $filter->filter($folderPath); print $downloadPath; exit; }
public function thumb1Action() { $path = $this->_getParam('path'); $width = $this->_getParam('width'); $height = $this->_getParam('height'); $thumb = Base_Image_PhpThumbFactory::create($path); $thumb->resize($width, $height); //$thumb->rotateImageNDegrees(1, '0xFFFFFF'); $thumb->show(); exit; }
public function editAction() { $type = "module"; if ($this->_getParam('type') != "") { $type = $this->_getParam('type'); } $this->view->type = $type; $id = $this->_getParam('id'); $page = $this->_getParam('page'); $model = new Application_Model_Content(); $model = $model->find($id); $options['title'] = $model->getTitle(); $options['alias'] = $model->getAlias(); $options['body'] = $model->getBody(); $options['status'] = $model->getStatus(); $options['weight'] = $model->getWeight(); $request = $this->getRequest(); $form = new Admin_Form_Content(); /**************************** Show/Hide fields as per module structure START ***************/ //by default fields should be enabled $displayEditor = true; //remove form fields for fixed content if (in_array($model->getAlias(), $this->fixedTextMod)) { $form->removeElement('weight'); $form->removeElement('status'); $form->removeElement('whereText'); $form->removeElement('whereUrl'); $form->removeElement('whereUrlTarget'); $form->removeElement('whereBodyText'); $form->removeElement('whereBodyUrl'); $form->removeElement('whereBodyUrlTarget'); $form->removeElement('weekPhoto'); } else { if ($model->getAlias() == "home_login_where_i_am") { $form->removeElement('body'); $displayEditor = false; $arrBodyText = unserialize($model->getBody()); foreach ($arrBodyText as $key => $value) { $options[$key] = $value; } $form->removeElement('weekPhoto'); } else { if ($model->getAlias() == "home_journal" || $model->getAlias() == "home_advertise") { $form->removeElement('body'); $displayEditor = false; $form->removeElement('whereText'); $form->removeElement('whereUrl'); $form->removeElement('whereUrlTarget'); $form->removeElement('whereBodyText'); $form->removeElement('whereBodyUrl'); $form->removeElement('whereBodyUrlTarget'); $form->removeElement('weekPhoto'); } else { if ($model->getAlias() == "home_photo_week") { $form->removeElement('whereText'); $form->removeElement('whereUrl'); $form->removeElement('whereUrlTarget'); $form->removeElement('whereBodyText'); $form->removeElement('whereBodyUrl'); $form->removeElement('whereBodyUrlTarget'); $photoBodyArr = unserialize($model->getBody()); $target_file_name = $photoBodyArr["weekPhoto"]; //$options['weekPhoto'] = $photoBodyArr["weekPhoto"]; $this->view->weekPhoto = $target_file_name; $options['body'] = $photoBodyArr["body"]; } else { $form->removeElement('whereText'); $form->removeElement('whereUrl'); $form->removeElement('whereUrlTarget'); $form->removeElement('whereBodyText'); $form->removeElement('whereBodyUrl'); $form->removeElement('whereBodyUrlTarget'); $form->removeElement('weekPhoto'); } } } } //display editor as per module requirement $this->view->displayEditor = $displayEditor; /**************************** Show/Hide fields as per module structure END ***************/ //populate form options $form->populate($options); if ($this->getRequest()->isPost()) { $options = $request->getPost(); if ($form->isValid($options)) { //create array for module as per their structure and save in database as serialize array if ($options["alias"] == "home_login_where_i_am") { $bodyTextArr["whereText"] = $options["whereText"]; $bodyTextArr["whereUrl"] = $options["whereUrl"]; $bodyTextArr["whereUrlTarget"] = $options["whereUrlTarget"]; $bodyTextArr["whereBodyText"] = $options["whereBodyText"]; $bodyTextArr["whereBodyUrl"] = $options["whereBodyUrl"]; $bodyTextArr["whereBodyUrlTarget"] = $options["whereBodyUrlTarget"]; $options["body"] = serialize($bodyTextArr); } //upload photo image for Photo of The Week Module if ($options["alias"] == "home_photo_week") { //Upload image start here $upload = new Zend_File_Transfer_Adapter_Http(); if ($upload->isValid()) { $upload->setDestination("media/picture/home/"); try { $upload->receive(); } catch (Zend_File_Transfer_Exception $e) { $msg = $e->getMessage(); } $upload->setOptions(array('useByteString' => false)); $file_name = $upload->getFileName('weekPhoto'); $cardImageTypeArr = explode(".", $file_name); $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]); //unlink existing image if ($ext != "" && $target_file_name != "") { if (file_exists("media/picture/home/" . $target_file_name)) { unlink("media/picture/home/" . $target_file_name); unlink("media/picture/home/thumb_" . $target_file_name); } } //$target_file_name = "weekPhoto_".time().".{$ext}"; $target_file_name = "photo-of-the-week.{$ext}"; $targetPath = "media/picture/home/" . $target_file_name; $targetPathThumb = "media/picture/home/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(278, 129); $thumb->save($targetPathThumb); } //upload image Ends here $bodyTextArr["weekPhoto"] = $target_file_name; $bodyTextArr["body"] = $options["body"]; $options["body"] = serialize($bodyTextArr); } $model->setOptions($options); $model->save(); return $this->_helper->redirector('index', 'content', "admin", array('type' => $type, 'msg' => base64_encode("Content has been saved successfully!"))); } else { $form->reset(); $form->populate($options); } } $this->view->msg = base64_decode($this->getRequest()->getParam("msg")); // Assign the form to the view $this->view->form = $form; //render different view for Photo Of The Week module if ($model->getAlias() == "home_photo_week") { //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->render('edit-photo'); } }
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 homepageBottomContentAction() { $id = $this->_getParam('id', 1); $modelRes = new Application_Model_HomeBottomContent(); $modelRes = $modelRes->find($id); $options = array('leftTitle' => $modelRes->getLeftTitle(), 'leftText' => $modelRes->getLeftText(), 'rightText' => $modelRes->getRightText(), 'rightTitle' => $modelRes->getRightTitle(), 'backgroundImage' => $modelRes->getBackgroundImage(), 'status' => $modelRes->getStatus()); $form = new Admin_Form_HomeBottomContent(); $this->view->backgroundImage = $modelRes->getBackgroundImage(); $form->populate($options); //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'); } //submit form $request = $this->getRequest(); if ($request->isPost()) { $options = $request->getPost(); if ($form->isValid($options)) { //set previous image name if not uploaded new one $target_file_name = $modelRes->getBackgroundImage(); // Image Upload START $upload = new Zend_File_Transfer_Adapter_Http(); if ($upload->isValid()) { $upload->setDestination("media/picture/home/"); try { $upload->receive(); } catch (Zend_File_Transfer_Exception $e) { $msg = $e->getMessage(); } //unlink previous uploaded image file if exists if (file_exists("media/picture/home/" . $modelRes->getBackgroundImage())) { unlink("media/picture/home/" . $modelRes->getBackgroundImage()); unlink("media/picture/home/thumb_" . $modelRes->getBackgroundImage()); } $upload->setOptions(array('useByteString' => false)); $file_name = $upload->getFileName('backgroundImage'); $cardImageTypeArr = explode(".", $file_name); $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]); $target_file_name = "bottom_" . time() . ".{$ext}"; $targetPath = "media/picture/home/" . $target_file_name; $targetPathThumb = "media/picture/home/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(641, 299); $thumb->save($targetPathThumb); } //Image Upload END //set image $options['backgroundImage'] = $target_file_name; //set user id $usersNs = new Zend_Session_Namespace("members"); $options['userId'] = $usersNs->userId; $modelRes->setOptions($options); $updateRes = $modelRes->save(); if ($updateRes) { $_SESSION['errorMsg'] = "Content has been updated successfully."; $this->_helper->redirector('homepage-bottom-content', 'widgets', 'admin', array('id' => $id)); } else { $this->view->errorMsg = "Error occured, please try again later."; } } else { $form->reset(); $form->populate($options); } } //end if //set form $this->view->form = $form; //set message if (isset($_SESSION['errorMsg'])) { $this->view->errorMsg = $_SESSION['errorMsg']; unset($_SESSION['errorMsg']); } }
public function addCountryImageEXPAction() { $this->_helper->layout->disableLayout(); //$this->_helper->viewRenderer->setNoRender(true); //get request variables $id = $this->_getParam("id"); $page = $this->_getParam("page"); $selTab = $this->_getParam("tab", "tabs-7"); $this->view->cityId = $id; //create image upload form $uploadForm = new Admin_Form_CityImages(); $elements = $uploadForm->getElements(); $uploadForm->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); $element->removeDecorator('td'); $element->removeDecorator('tr'); $element->removeDecorator('row'); $element->removeDecorator('HtmlTag'); $element->removeDecorator('placement'); $element->removeDecorator('data'); } $this->view->uploadForm = $uploadForm; //selects country images to edit $oldImageArr = array(); $oldImageSortingArr = array(); $lonelyPlanetCountryM = new Application_Model_LonelyPlanetCountry(); $lonelyPlanetCountryM = $lonelyPlanetCountryM->find($id); if (false !== $lonelyPlanetCountryM) { $oldImageArr = unserialize($lonelyPlanetCountryM->getImages()); //echo "<pre>"; //print_r($oldImageArr); for ($oCnt = 0; $oCnt < count($oldImageArr); $oCnt++) { $imgArr = $oldImageArr[$oCnt]; $imgArr["alt_text"] = ""; $imgArr["slide_link_url"] = ""; $imgArr["slide_link_target"] = ""; $imgArr["weight"] = $oCnt + 1; $oldImageSortingArr[] = $imgArr; } //print_r($oldImageSortingArr); //echo "</pre>"; //exit; } $request = $this->getRequest(); if ($request->isPost()) { $options = $request->getPost(); if ($uploadForm->isValid($options)) { $target_file_name = ""; //Upload image strat here $upload = new Zend_File_Transfer_Adapter_Http(); if ($upload->isValid()) { $upload->setDestination("media/picture/country/"); try { $upload->receive(); } catch (Zend_File_Transfer_Exception $e) { $msg = $e->getMessage(); } $upload->setOptions(array('useByteString' => false)); $file_name = $upload->getFileName('countryImage'); $cardImageTypeArr = explode(".", $file_name); $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]); $target_file_name = "country{$country_id}_" . time() . ".{$ext}"; $targetPath = "media/picture/country/images/" . $target_file_name; $targetPathThumb = "media/picture/country/images/thumbs/" . $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(625, 330); $thumb->save($targetPathThumb); } //end if //upload image Ends here //set country Image array $addImageArr = array(); $addImageArr["image_caption"] = $options["slideTitle"]; $addImageArr["image_photographer"] = "Gap Daemon"; $addImageArr["image_filename"] = "/images/" . $target_file_name; $addImageArr["image_thumbnail_filename"] = "/images/thumbs/" . $target_file_name; $addImageArr["alt_text"] = $options["altText"]; $addImageArr["slide_link_url"] = $options["slideLinkUrl"]; $addImageArr["slide_link_target"] = $options["slideLinkTarget"]; $addImageArr["weight"] = $options["weight"]; $oldImageSortingArr[count($oldImageSortingArr)] = $addImageArr; $newCountryImageArr = serialize($oldImageSortingArr); $lonelyPlanetCountryM->setImages($newCountryImageArr); $resImg = $lonelyPlanetCountryM->save(); if ($resImg) { $_SESSION['errorMsg'] = "Images has been saved successfully."; echo "<script>window.opener.location='/admin/featured-city/edit-country/id/{$id}/page/{$page}/tab/{$selTab}';</script>"; echo "<script>window.close();</script>"; } else { $this->view->errorMsg = "Error occured, please try again later."; } } else { $uploadForm->reset(); $uploadForm->populate($options); } } //end if $this->render("add-city-image"); }
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; }
public function uploadCoverImage($id, $options) { $model = new Application_Model_Album(); $model = $model->find($id); $upload = new Zend_File_Transfer_Adapter_Http(); if ($upload->isValid('coverImage')) { $upload->setDestination("media/picture/album/"); try { $upload->receive('coverImage'); } catch (Zend_File_Transfer_Exception $e) { $msg = $e->getMessage(); } $upload->setOptions(array('useByteString' => false)); $file_name = $upload->getFileName('coverImage'); $cardImageTypeArr = explode(".", $file_name); $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]); $target_file_name = "album_cover_" . $id . ".{$ext}"; $targetPath = 'media/picture/album/' . $target_file_name; $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true)); $filterFileRename->filter($file_name); $options['coverImage'] = $target_file_name; /*--- Generate Profile Picture ---*/ $thumb = Base_Image_PhpThumbFactory::create($targetPath); $thumb->resize(150, 150); $thumb->save('media/picture/album/thumb_' . $target_file_name); $model->setCoverImage($options['coverImage']); return $model->save(); } }
public function editAction() { $this->view->type = $type = $this->_getParam('type', "other"); $this->view->title = ucfirst($type) . " Category - Edit"; $this->view->headTitle(" - " . $this->view->title); $id = $this->_getParam('id'); $model1 = new Application_Model_Category(); $model = $model1->find($id); $options['name'] = $model->getName(); $options['urlText'] = $model->getUrlText(); $options['urlLink'] = $model->getUrlLink(); $options['description'] = $model->getDescription(); $options['image'] = $model->getImage(); $options['status'] = $model->getStatus(); $options['weight'] = $model->getWeight(); $this->view->imgName = $model->getImage(); $request = $this->getRequest(); $form = new Admin_Form_Category(); $form->populate($options); //remove weight field for all type of categories except advice and wsv category if ($type == "album" || $type == "blog" || $type == "work" || $type == "study" || $type == "volunteer" || $type == "other") { $form->removeElement('weight'); } //Url Link and Url Text fields should appear for WSV categories only if ($type != "wsv") { $form->removeElement('urlText'); $form->removeElement('urlLink'); } $options = $request->getPost(); if ($request->isPost()) { if ($form->isValid($options)) { $category_id = $model->getId(); $upload = new Zend_File_Transfer_Adapter_Http(); //---main image if ($upload->isValid('image')) { $upload->setDestination("images/uploads/"); try { $upload->receive('image'); } catch (Zend_File_Transfer_Exception $e) { $msg = $e->getMessage(); } $upload->setOptions(array('useByteString' => false)); //delete existing files if ($model->getImage() != "" && file_exists("media/picture/category/" . $type . "/" . $model->getImage())) { unlink("media/picture/category/" . $type . "/" . $model->getImage()); unlink("media/picture/category/" . $type . "/thumb_" . $model->getImage()); } $id = $category_id; $file_name = $upload->getFileName('image'); $cardImageTypeArr = explode(".", $file_name); $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]); $target_file_name = "category_" . $id . ".{$ext}"; $targetPath = 'media/picture/category/' . $type . '/' . $target_file_name; $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true)); $filterFileRename->filter($file_name); $options['image'] = $target_file_name; /*--- Generate Thumbnail ---*/ $thumb = Base_Image_PhpThumbFactory::create($targetPath); $thumb->resize(100, 100); $thumb->save($targetPath = 'media/picture/category/' . $type . '/thumb_' . $target_file_name); } //----------- $model->setOptions($options); $model->save($model); $model->updateRelatedSeoUrls($id); $this->view->successMsg = "Category has been updated successfully!"; } else { $form->reset(); $form->populate($options); } } $this->view->form = $form; }
public function myProfileAction() { /*--- find user data and populate the edit form ----*/ $userNs = new Zend_Session_Namespace('members'); $userId = $userNs->userId; //$user = unserialize($userNs->userObj); //$userId = $user->getId(); $userM = new Application_Model_User(); $user = $userM->find($userId); $params['firstName'] = $user->getFirstName(); $params['lastName'] = $user->getLastName(); $params['email'] = $user->getEmail(); $params['countryPassport'] = $user->getCountryPassport(); $params['preferredLanguage'] = $user->getPreferredLanguage(); $params['otherLanguages'] = $user->getOtherLanguages(); $params['cityId'] = $user->getCityId(); $params['cityName'] = $user->getCityName(); $arrDob = explode("-", $user->getDob()); if (count($arrDob) > 0) { $params['year'] = $arrDob[0]; $params['month'] = $arrDob[1]; $params['day'] = $arrDob[2]; } $params['sex'] = $user->getSex(); $params['firstTimeTraveller'] = $user->getFirstTimeTraveller(); $params['mobileCountryCode'] = $user->getMobileCountryCode(); $params['mobile'] = $user->getMobile(); $params['dreamDestination'] = $user->getDreamDestination(); $params['wayToTravel'] = $user->getWayToTravel(); $params['travelGear'] = $user->getTravelGear(); $params['yearGoal'] = $user->getYearGoal(); $params['leaveHomeWithout'] = $user->getLeaveHomeWithout(); $params['interests'] = $user->getInterests(); $params['evenTakenGapYear'] = $user->getEvenTakenGapYear(); $params['nextTravelToDoList'] = $user->getNextTravelToDoList(); $params['favouriteTravelExperience'] = $user->getFavouriteTravelExperience(); $this->view->username = $user->getUsername(); /*-------------------------------------------------------*/ $form = new Application_Form_Profile(); $form->populate($params); $elements = $form->getElements(); $form->clearDecorators(); foreach ($elements as $element) { $element->removeDecorator('label'); } if ($this->getRequest()->isPost()) { $params = $this->getRequest()->getPost(); /*---- email validation ----*/ if ($params['email'] != $user->getEmail()) { $form->getElement('email')->addValidators(array(array('Db_NoRecordExists', false, array('table' => 'user', 'field' => 'email', 'messages' => 'Email already exists, Please choose another email address')))); } /*-------------------------*/ /*--- validations for change password -------*/ if (trim($params['currentPassword']) != "") { $params['currentPassword'] = md5($params['currentPassword']); $form->getElement('currentPassword')->addValidators(array(array('Db_RecordExists', false, array('table' => 'user', 'field' => 'password', 'messages' => 'Incorrect current password')))); $form->getElement('password')->setRequired(true); } if (trim($params['password']) != "" && $params['currentPassword'] == "") { $form->getElement('currentPassword')->setRequired(true); $form->getElement('currentPassword')->addValidators(array(array('NotEmpty', false, array('messages' => array('isEmpty' => 'You must enter the current password'))))); } /*--- validations for change password -------*/ if ($form->isValid($params)) { $upload = new Zend_File_Transfer_Adapter_Http(); //---main image if ($upload->isValid('image')) { //unlink existing images if ($user->getImage() != "" && file_exists("media/picture/profile/" . $user->getImage())) { unlink("media/picture/profile/" . $user->getImage()); //main uploaded image unlink("media/picture/profile/thumb_" . $user->getImage()); //thumb image } $upload->setDestination("images/uploads/"); try { $upload->receive('image'); } catch (Zend_File_Transfer_Exception $e) { $msg = $e->getMessage(); } $upload->setOptions(array('useByteString' => false)); $id = $userId; $file_name = $upload->getFileName('image'); $cardImageTypeArr = explode(".", $file_name); $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]); $target_file_name = "profile_" . $id . ".{$ext}"; $targetPath = 'media/picture/profile/' . $target_file_name; $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true)); $filterFileRename->filter($file_name); $params['image'] = $target_file_name; /*--- Generate Thumbnail ---*/ $thumb = Base_Image_PhpThumbFactory::create($targetPath); $thumb->resize(200, 200); $thumb->save($targetPath = 'media/picture/profile/thumb_' . $target_file_name); } //----------- $params['dob'] = $params['year'] . "-" . $params['month'] . "-" . $params['day']; $pass = $user->getPassword(); if (trim($params['password']) != "") { $params['password'] = md5($params['password']); } else { $params['password'] = $pass; } $user->setOptions($params); $user->save(); $this->view->msg = "Profile updated successfully!"; $userNs->userObj = serialize($user); } //$this->_helper->_redirector->gotoUrl($this->view->seoUrl("/gapper/my-profile")); //$this->_redirect($this->view->seoUrl("/gapper/my-profile")); } $this->view->thumbImage = $user->getThumbnail(); $this->view->image_name = $user->getImage(); $this->view->gender = $user->getSex(); $this->view->form = $form; }
public function addAction() { $request = $this->getRequest(); $form = new Admin_Form_User(); $options = $request->getPost(); if ($request->isPost()) { /*---- email validation ----*/ $form->getElement('email')->addValidators(array(array('Db_NoRecordExists', false, array('table' => 'user', 'field' => 'email', 'messages' => 'Email already exists, Please choose another email address.')))); /*-------------------------*/ if ($form->isValid($options)) { $model = new Application_Model_User(); $options['dob'] = $options['year'] . "-" . $options['month'] . "-" . $options['day']; $options['status'] = 'active'; $options['password'] = md5($options['password']); $options['preferredLanguage'] = 'English'; //$options['userLevelId'] =$options['userLevelId']; //$model->setOptions($options); // $id=$model->save(); /*--------- Upload image START -------------------------*/ $upload = new Zend_File_Transfer_Adapter_Http(); if ($upload->isValid('image')) { $upload->setDestination("media/picture/profile/"); try { $upload->receive('image'); } 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 = "profile_" . $id . ".{$ext}"; $targetPath = 'media/picture/profile/' . $target_file_name; $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true)); $filterFileRename->filter($file_name); $options['image'] = $target_file_name; /*--- Generate Thumbnail ---*/ $thumb = Base_Image_PhpThumbFactory::create($targetPath); $thumb->resize(100, 100); $thumb->save($targetPath = 'media/picture/profile/thumb_' . $target_file_name); $model->setOptions($options); $model->setId($id); $id = $model->save(); } /*--------- Upload image END -------------------------*/ //$options['dob'] = $options['year']."-".$options['month']."-".$options['day']; //$model->setOptions($options); //$model->save(); $user = new Application_Model_User($options); $user_id = $user->save(); if ($user_id > 0) { /*---- default permission settings ----*/ $user->setDefaultPermissions($user_id); $user->setDefaultJournal($user_id); } $this->view->msg = "'User has been inserted successfully!"; $form->reset(); } else { $form->reset(); $form->populate($options); } } $this->view->form = $form; }
public function uploadPicture($options) { $upload = new Zend_File_Transfer_Adapter_Http(); $albumId = $options['album_id']; $targetFolder = PUBLIC_PATH . "/media/picture/album/{$albumId}"; if (!is_dir($targetFolder)) { mkdir(str_replace('//', '/', $targetFolder), 0755, true); } if ($upload->isValid('Filedata')) { $upload->setDestination($targetFolder); try { $upload->receive('Filedata'); } catch (Zend_File_Transfer_Exception $e) { $msg = $e->getMessage(); } $upload->setOptions(array('useByteString' => false)); $file_name = $upload->getFileName('Filedata'); $model = new Application_Model_Pictures(); $model->setAlbumId($albumId); $model->setImage($file_name); $id = $model->save(); $cardImageTypeArr = explode(".", $file_name); $ext = strtolower($cardImageTypeArr[count($cardImageTypeArr) - 1]); $target_file_name = "album_picture_" . $id . ".{$ext}"; $targetPath = $targetFolder . '/' . $target_file_name; $filterFileRename = new Zend_Filter_File_Rename(array('target' => $targetPath, 'overwrite' => true)); $filterFileRename->filter($file_name); /*--- Generate Profile Picture ---*/ $thumb = Base_Image_PhpThumbFactory::create($targetPath); $thumb->resize(600, 600); $thumb->save($targetFolder . '/small_' . $target_file_name); $thumb = Base_Image_PhpThumbFactory::create($targetPath); $thumb->resize(150, 150); $thumb->save($targetFolder . '/thumb_' . $target_file_name); $model = new Application_Model_Pictures(); $model = $model->find($id); $model->setImage($target_file_name); $model->save(); $str = "<div class='album_pic_thumb_box' id='pic_container_" . $model->getId() . "'>"; $str .= '<a class="album_pic_slide" href="' . $model->getPictureSmallUrl() . '"><img class="album_pic_thumb" src="' . $model->getPictureThumbUrl() . '"/></a>'; $str .= '<br class="clear">'; $str .= "<a href=\"javascript: deletePic('" . $model->getId() . "');\">"; $str .= "<img src=\"/images/icons/cross_circle.png\" alt=\"Click here to delete!\">"; $str .= "</a>"; $str .= "</div>"; return $str; } }
public function processImageAction() { $this->_helper->layout()->disableLayout(); $arrPostVal = $this->getRequest()->getParams(); $fileName = $arrPostVal['fileName']; $fileSize = $arrPostVal['fileSize']; $fileType = $arrPostVal['fileType']; $album = $arrPostVal['album']; $quality = $arrPostVal['quality']; $this->view->uploading_type = $arrPostVal['uploadingType']; $this->view->review_edit = $arrPostVal['review_edit']; $uploadedCount = $arrPostVal['uploadedCount']; $newPhotoName = "album_" . time() . "_" . rand(10, 99) . $fileType; $imagePath = PUBLIC_PATH . "/images/album/default/" . $fileName; $targetPath = PUBLIC_PATH . "/images/album/default/" . $newPhotoName; $targetPathR = PUBLIC_PATH . "/images/album/custom/" . $newPhotoName; $targetPathT = PUBLIC_PATH . "/images/album/thumb/" . $newPhotoName; copy($imagePath, $targetPathR); rename($imagePath, $targetPath); $mageSize = $this->getImageSize($quality); $thumb = Base_Image_PhpThumbFactory::create($targetPath); $thumb->resize($mageSize['width'], $mageSize['height']); $thumb->save($targetPathR); $thumb->resize(131, 98); // Thumb Image $thumb->save($targetPathT); /*----------- GET LOGGEDIN USER INFORMATION ----------------------*/ $usersNs = new Zend_Session_Namespace("members"); $userId = $usersNs->userId; /*----------- CAPTURE TO DATABASE --------------------------------*/ $option['albumId'] = $album; $option['userId'] = $userId; $option['image'] = $newPhotoName; $option['name'] = $newPhotoName; $option['type'] = $fileType; $option['size'] = filesize($targetPathR); $option['status'] = 1; $option['permission'] = 1; $option['addedon'] = time(); $objModelAlbumPhoto = new Album_Model_AlbumPhoto($option); $objModelAlbumPhoto->save(); $objModelFriendGroup = new Application_Model_FriendGroup(); $arrFriendGroup = $objModelFriendGroup->getPermissions(); $this->view->arrFriendGroup = $arrFriendGroup; $this->view->uploadedCount = $uploadedCount; $this->view->album = $album; }