public function editPhotoAction() { $id = $this->_request->getParam('photo_id'); $form = new Application_Form_GalleryForm(); $this->view->photo_id = $id; if (isset($id)) { $this->user_session->photo_id = $id; } if (isset($id) || isset($this->user_session->photo_id)) { $result = $this->photos->getPhoto($this->user_session->photo_id); //var_dump($result); //return; $this->view->photo_id = $result->photo_id; $this->view->photo_name = $result->photo_name; $form->photo_name->setValue($result->photo_name); $this->user_session->photo_name = $result->photo_name; $this->view->form = $form; } if (!$this->_request->isPost()) { $this->view->form = $form; return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { $this->view->form = $form; return; } //For Image upload $file_name = NULL; $photo_name = $_FILES["photo_name"]["name"]; if (isset($photo_name) && strlen($photo_name) > 0) { try { if (isset($this->user_session->photo_name)) { unlink(SYSTEM_PATH . "/images/gallery-images/originals/" . $result->photo_name); unlink(SYSTEM_PATH . "/images/gallery-images/200X200/" . $result->photo_name); unlink(SYSTEM_PATH . "/images/gallery-images/500X500/" . $result->photo_name); } $photo_name = $_FILES['photo_name']['name']; $random = rand(10, 10000); $time = time() + 7 * 24 * 60 * 60; $file_name = $time . $random . $photo_name; $formData["photo_name"] = $file_name; move_uploaded_file($_FILES["photo_name"]['tmp_name'], SYSTEM_PATH . "/images/gallery-images/originals/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "/images/gallery-images/originals/" . $file_name); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . '/images/gallery-images/500X500/' . $file_name); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . '/images/gallery-images/200X200/' . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['photo_name'] = $this->user_session->photo_name; } $formData['photo_id'] = $this->user_session->photo_id; $result = $this->photos->editPhoto($formData); $this->_redirect("/admin/gallery/photo-list"); }
public function editPhotoAction() { $id = $this->_request->getParam('id'); if (!isset($id)) { $this->_redirect('admin/gallery/index'); } $form = new Application_Form_GalleryForm(); // get photo data from photos table $result = $this->photos->getPhotoByID($id); $this->view->id = $result->photo_id; $form->photo_name->setValue($result->photo_name); $this->view->photo = $result->photo_name; $form->link->setValue($result->link); $form->caption->setValue($result->caption); $form->category->setValue($result->pg_cat_id); $form->description->setValue($result->description); $this->view->form = $form; if (!$this->_request->isPost()) { return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { return; } //For Image upload $file_name = NULL; $image_name = $_FILES["photo_name"]["name"]; if (isset($image_name) && strlen($image_name) > 0) { try { if (isset($result->photo_name)) { $image_file = SYSTEM_PATH . "/images/user/photo_gallery/500X500/" . $result->photo_name; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/photo_gallery/" . $result->photo_name); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/photo_gallery/200X200/" . $result->photo_name); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/photo_gallery/500X500/" . $result->photo_name); } } $photo_name = $_FILES['photo_name']['name']; $random = rand(9, 999999); $file_name = $random . $photo_name; $formData["photo_name"] = $file_name; move_uploaded_file($_FILES["photo_name"]['tmp_name'], SYSTEM_PATH . "images/user/photo_gallery/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/photo_gallery/" . $file_name); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/photo_gallery/500X500/" . $file_name); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/photo_gallery/200X200/" . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['photo_name'] = $result->photo_name; } $formData['photo_id'] = $id; $result = $this->photos->editPhoto($formData); $this->view->msg = $result; $this->_redirect("/admin/gallery/edit-photo/id/" . $id); }
public function editAction() { $id = $this->_request->getParam('id'); if (!isset($id)) { $this->_redirect('admin/image-blocks/index'); } $form = new Application_Form_ImageBlockForm(); // get image block data from image_blocks table $result = $this->image_blocks->getImageBlockByID($id); // var_dump($result);// $this->view->id = $result->ib_id; $form->block->setValue($result->block); $this->view->block = $result->block; $form->name->setValue($result->name); $this->view->name = $result->name; $form->link->setValue($result->link); $form->caption->setValue($result->caption); $form->disable_link->setValue($result->disable_link); $this->view->form = $form; if (!$this->_request->isPost()) { return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { return; } //For Image upload $file_name = NULL; $image_name = $_FILES["block"]["name"]; if (isset($image_name) && strlen($image_name) > 0) { try { if (isset($result->block)) { $image_file = SYSTEM_PATH . "/images/user/image-blocks/" . $result->block; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/image-blocks/" . $result->block); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/image-blocks/200X200/" . $result->block); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/image-blocks/500X500/" . $result->block); } } $block = $_FILES['block']['name']; $random = rand(9, 999999); $file_name = $random . $block; $formData["block"] = $file_name; move_uploaded_file($_FILES["block"]['tmp_name'], SYSTEM_PATH . "images/user/image-blocks/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/image-blocks/" . $file_name); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/image-blocks/500X500/" . $file_name); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/image-blocks/200X200/" . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['block'] = $result->block; } $formData['ib_id'] = $id; $result = $this->image_blocks->editBlockImage($formData); $this->view->msg = $result; $this->_redirect("/admin/image-blocks/edit/id/" . $id); }
public function editAction() { $id = $this->_request->getParam('id'); if (!isset($id)) { $this->_redirect('admin/photo-categories/index'); } $form = new Application_Form_PhotoCategoryForm(); $result = $this->category->getCategoryByID($id); $this->view->id = $result->pg_cat_id; $form->banner->setValue($result->banner); $this->view->banner = $result->banner; $form->category_name->setValue($result->category_name); $this->view->name = $result->category_name; $form->submit->setLabel("Update"); $this->view->form = $form; if (!$this->_request->isPost()) { $this->view->form = $form; return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { $this->view->form = $form; return; } //For Image upload $file_name = NULL; $image_name = $_FILES["banner"]["name"]; if (isset($image_name) && strlen($image_name) > 0) { try { if (isset($result->banner)) { $image_file = SYSTEM_PATH . "/images/user/photo_gallery/categories/500X500/" . $result->banner; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/photo_gallery/categories/" . $result->banner); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/photo_gallery/categories/500X500/" . $result->banner); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/photo_gallery/categories/200X200/" . $result->banner); } } $banner = $_FILES['banner']['name']; $random = rand(9, 999999); $file_name = $random . $banner; $formData["banner"] = $file_name; move_uploaded_file($_FILES["banner"]['tmp_name'], SYSTEM_PATH . "images/user/photo_gallery/categories/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/photo_gallery/categories/" . $file_name); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/photo_gallery/categories/500X500/" . $file_name); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/photo_gallery/categories/200X200/" . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['banner'] = $result->banner; } $formData['pg_cat_id'] = $id; $result = $this->category->editCategory($formData); $this->view->msg = $result; $this->_redirect("/admin/photo-categories/edit/id/" . $id); }
public function editAction() { $id = $this->_request->getParam('page_id'); $form = new Application_Form_NewPageForm(); $results = $this->url->getUrls(); $this->view->page_url = $results->page_url; $this->view->page_id = $id; if (isset($id)) { $this->user_session->page_id = $id; } if (isset($id) || isset($this->user_session->page_id)) { $result = $this->page->getPageByID($this->user_session->page_id); //var_dump($result); //return; $this->view->page_id = $result->page_id; $form->title->setValue($result->title); $form->url_slug->setValue($result->url_slug); $form->image->setValue($result->image); $form->description->setValue($result->description); $form->submit->setLabel("Update"); $this->view->url_slug = $result->url_slug; $this->user_session->image = $result->image; $this->view->image = $result->image; $this->view->form = $form; } if (!$this->_request->isPost()) { $this->view->form = $form; return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { $this->view->form = $form; return; } //For Image upload $file_name = NULL; $image_name = $_FILES["image"]["name"]; if (isset($image_name) && strlen($image_name) > 0) { try { if (isset($this->user_session->image)) { unlink(SYSTEM_PATH . "/images/pages/original/" . $result->image); unlink(SYSTEM_PATH . "/images/pages/500X500/" . $result->image); unlink(SYSTEM_PATH . '/images/pages/800/' . $result->image); } $image = $_FILES['image']['name']; $random = rand(10, 10000); $time = time() + 7 * 24 * 60 * 60; $file_name = $time . $random . $image; $formData["image"] = $file_name; move_uploaded_file($_FILES["image"]['tmp_name'], SYSTEM_PATH . "/images/pages/original/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "/images/pages/original/" . $file_name); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . '/images/pages/500X500/' . $file_name); $thumb->resize(800, 800); $thumb->save(SYSTEM_PATH . '/images/posts/800/' . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['image'] = $this->user_session->image; } $formData['page_id'] = $this->user_session->page_id; $formData['is_in_draft'] = $formData['submit']; $slug = $formData['url_slug']; $formData['url_slug'] = str_replace("-", "", $slug); /*check from database if the slug is already in db $data = array ("url"=>$formData["url_slug"]); $data["url"]=$formData["url_slug"]; if($this->page->checkPageSlug($data)){ $this->view->msg = "<div class='alert alert-danger'>Url Slug Is Already Exist. Please change to another.</div>"; return; } */ if ($formData['submit'] == "0") { $formData['is_in_draft'] = 0; $result = $this->page->updatePage($formData); $this->view->msg = $result; //$this->_redirect("/admin/page/lists"); } else { if ($formData['submit'] == "1") { $formData['is_in_draft'] = 1; $result = $this->page->updateDraftPage($formData); $this->view->msg = $result; //$this->_redirect("/admin/page/lists"); } } }
public function editAction() { $id = $this->_request->getParam('page_id'); $form = new Application_Form_NewPageForm(); $results = $this->url->getUrls(); $this->view->page_url = $results->page_url; $this->view->page_id = $id; if (isset($id)) { $this->user_session->page_id = $id; } if (isset($id) || isset($this->user_session->page_id)) { $result = $this->page->getPageByID($this->user_session->page_id); //var_dump($result); //return; $this->view->page_id = $result->page_id; $form->title->setValue($result->title); $form->url_slug->setValue($result->url_slug); $form->image->setValue($result->image); $form->description->setValue($result->description); $this->view->save_description = $result->draft_content; $form->submit->setLabel("Update"); $this->view->url_slug = $result->url_slug; $this->user_session->image = $result->image; $this->view->image = $result->image; $this->view->form = $form; } if (!$this->_request->isPost()) { $this->view->form = $form; return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { $this->view->form = $form; return; } //For Image upload $file_name = NULL; $image_name = $_FILES["image"]["name"]; if (isset($image_name) && strlen($image_name) > 0) { try { if (isset($this->user_session->image)) { unlink(SYSTEM_PATH . "/images/user/pages/" . $result->image); unlink(SYSTEM_PATH . "/images/user/pages/500X500/" . $result->image); unlink(SYSTEM_PATH . '/images/user/pages/200X200/' . $result->image); } $image = $_FILES['image']['name']; $random = rand(10, 10000); $time = time() + 7 * 24 * 60 * 60; $file_name = $time . $random . $image; $formData["image"] = $file_name; move_uploaded_file($_FILES["image"]['tmp_name'], SYSTEM_PATH . "/images/user/pages/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "/images/user/pages/" . $file_name); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . '/images/user/pages/500X500/' . $file_name); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . '/images/user/pages/200X200/' . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['image'] = $this->user_session->image; } $formData['page_id'] = $this->user_session->page_id; //$slug= $formData['url_slug']; //$formData['url_slug']= str_replace("-","", $slug); $formData['date_published'] = date("Y-m-d H:i:s"); if ($formData['submit'] == "0") { $formData['is_in_draft'] = 0; $formData['draft_content'] = $formData['description']; } else { $formData['is_in_draft'] = 1; $formData['draft_content'] = $formData['description']; } $result = $this->page->updatePage($formData); $this->view->msg = $result; }
public function editBannerAction() { $id = $this->_request->getParam('banner_id'); $form = new Application_Form_AddMainBannerForm(); $this->view->banner_id = $id; if (isset($id)) { $this->user_session->banner_id = $id; } if (isset($id) || isset($this->user_session->banner_id)) { $result = $this->banner->getBanner($this->user_session->banner_id); //var_dump($result); //return; $this->view->banner_id = $result->banner_id; $form->banner_img->setValue($result->banner_img); $form->target_url->setValue($result->target_url); $form->is_main->setValue($result->is_main); $this->user_session->banner_img = $result->banner_img; $this->view->form = $form; } if (!$this->_request->isPost()) { $this->view->form = $form; return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { $this->view->form = $form; return; } //For Image upload $file_name = NULL; $image_name = $_FILES["banner_img"]["name"]; if (isset($image_name) && strlen($image_name) > 0) { try { if (isset($this->user_session->video_image)) { unlink(SYSTEM_PATH . "/images/admin/banners/original/" . $result->banner_img); unlink(SYSTEM_PATH . "/images/admin/banners/200X200/" . $result->banner_img); unlink(SYSTEM_PATH . '/images/admin/banners/1600/' . $result->banner_img); } $banner_img = $_FILES['banner_img']['name']; $random = rand(10, 10000); $time = time() + 7 * 24 * 60 * 60; $file_name = $time . $random . $banner_img; $formData["banner_img"] = $file_name; move_uploaded_file($_FILES["banner_img"]['tmp_name'], SYSTEM_PATH . "/images/admin/banners/original/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "/images/admin/banners/original/" . $file_name); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . '/images/admin/banners/200X200/' . $file_name); $thumb->resize(1600, 1600); $thumb->save(SYSTEM_PATH . '/images/admin/banners/1600/' . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['banner_img'] = $this->user_session->banner_img; } $formData['banner_id'] = $this->user_session->banner_id; $result = $this->banner->editBanner($formData); $this->_redirect("/admin/banner/banner-list"); }
public function editTestimonialAction() { $id = $this->_request->getParam('id'); $form = new Application_Form_AddTestimonialForm(); $this->view->t_id = $id; if (isset($id)) { $this->user_session->test_id = $id; } if (isset($id) || isset($this->user_session->test_id)) { $result = $this->testimonial->getTestimonial($this->user_session->test_id); //var_dump($result); $this->view->id = $result->test_id; $form->email->setValue($result->email); $form->first_name->setValue($result->first_name); $form->last_name->setValue($result->last_name); $form->short_description->setValue($result->short_description); $form->is_featured->setValue($result->is_featured); $this->view->image = $result->image1; $this->user_session->image = $result->image1; $this->view->form = $form; } if (!$this->_request->isPost()) { $this->view->form = $form; return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { $this->view->form = $form; return; } //For Image upload $file_name = NULL; $image_name = $_FILES["image1"]["name"]; if (isset($image_name) && strlen($image_name) > 0) { // var_dump("herer"); // return; try { if (isset($this->user_session->image)) { unlink(SYSTEM_PATH . "/images/testimonial-images/originals/" . $result->image1); unlink(SYSTEM_PATH . "/images/testimonial-images/200X200/" . $result->image1); } $image1 = $_FILES['image1']['name']; $random = rand(10, 10000); $time = time() + 7 * 24 * 60 * 60; $file_name = $time . $random . $image1; $formData["image1"] = $file_name; move_uploaded_file($_FILES["image1"]['tmp_name'], SYSTEM_PATH . "/images/testimonial-images/originals/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "/images/testimonial-images/originals/" . $file_name); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . '/images/testimonial-images/200X200/' . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['image1'] = $this->user_session->image; } $formData['t_id'] = $this->user_session->test_id; /*var_dump($formData); return;*/ $result = $this->testimonial->editTestimonial($formData); $this->_redirect('/admin/index/testimonial-list'); }
public function editAction() { $id = $this->_request->getParam('id'); if (!isset($id)) { $this->_redirect('admin/videos/index'); } $form = new Application_Form_VideoLinkForm(); // get video data from video table $result = $this->video->getVideo($id); // var_dump($result);// $this->view->id = $result->v_id; $form->title->setValue($result->title); $this->view->title = $result->title; $form->url_video->setValue($result->url_video); $form->short_description->setValue($result->short_description); $form->is_featured->setValue($result->is_featured); $form->is_main->setValue($result->is_main); //$form->video_img = $result->video_img; $this->view->image = $result->video_img; $form->submit->setLabel("Update"); $this->view->form = $form; if (!$this->_request->isPost()) { return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { return; } //For Image upload $file_name = NULL; $image_name = $_FILES["video_img"]["name"]; if (isset($image_name) && strlen($image_name) > 0) { try { if (isset($result->video_img)) { $image_file = SYSTEM_PATH . "/images/user/videos/500X500/" . $result->video_img; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/videos/" . $result->video_img); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/videos/200X200/" . $result->video_img); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/videos/500X500/" . $result->video_img); } } $video_img = $_FILES['video_img']['name']; $random = rand(9, 999999); $file_name = $random . $video_img; $formData["video_img"] = $file_name; move_uploaded_file($_FILES["video_img"]['tmp_name'], SYSTEM_PATH . "images/user/videos/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/videos/" . $file_name); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/videos/500X500/" . $file_name); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/videos/200X200/" . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['video_img'] = $result->video_img; } $formData['v_id'] = $id; $result = $this->video->updateVideo($formData); $this->view->msg = $result; $this->_redirect("/admin/videos/edit/id/" . $id); }
public function editAction() { $id = $this->_request->getParam('id'); if (!isset($id)) { $this->_redirect('admin/testimonial/index'); } $form = new Application_Form_TestimonialForm(); // get testimonial data from testimonial table $result = $this->testimonial->getTestimonial($id); // var_dump($result);// $this->view->id = $result->test_id; $form->image1->setValue($result->image1); $this->view->image = $result->image1; $form->first_name->setValue($result->first_name); $this->view->name = $result->first_name; $form->last_name->setValue($result->last_name); $form->email->setValue($result->email); $form->short_description->setValue($result->short_description); $form->is_featured->setValue($result->is_featured); $form->submit->setLabel("Update"); $this->view->form = $form; if (!$this->_request->isPost()) { return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { return; } //For Image upload $file_name = NULL; $image_name = $_FILES["image1"]["name"]; if (isset($image_name) && strlen($image_name) > 0) { try { if (isset($result->image1)) { $image_file = SYSTEM_PATH . "/images/user/testimonials/500X500/" . $result->image1; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/testimonials/" . $result->image1); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/testimonials/200X200/" . $result->image1); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/testimonials/500X500/" . $result->image1); } } $image1 = $_FILES['image1']['name']; $random = rand(9, 999999); $file_name = $random . $image1; $formData["image1"] = $file_name; move_uploaded_file($_FILES["image1"]['tmp_name'], SYSTEM_PATH . "images/user/testimonials/" . $file_name); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/testimonials/" . $file_name); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/testimonials/500X500/" . $file_name); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/testimonials/200X200/" . $file_name); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['image1'] = $result->image1; } $formData['test_id'] = $id; $result = $this->testimonial->edit($formData); $this->view->msg = $result; $this->_redirect("/admin/testimonial/edit/id/" . $id); }
public function editAction() { $id = $this->_request->getParam('id'); if (!isset($id)) { $this->_redirect('admin/slider/index'); } $form = new Application_Form_SliderForm(); $result = $this->sliders->getSliderByID($id); //var_dump($result);return; $this->view->id = $result->slider_id; $form->name->setValue($result->name); $this->view->name = $result->name; $form->slide1->setValue($result->slide1); $this->view->slide1 = $result->slide1; $form->link1->setValue($result->link1); $form->slide2->setValue($result->slide2); $this->view->slide2 = $result->slide2; $form->link2->setValue($result->link2); $form->slide3->setValue($result->slide3); $this->view->slide3 = $result->slide3; $form->link3->setValue($result->link3); $form->slide4->setValue($result->slide4); $this->view->slide4 = $result->slide4; $form->link4->setValue($result->link4); $form->slide5->setValue($result->slide5); $this->view->slide5 = $result->slide5; $form->link5->setValue($result->link5); $form->slide6->setValue($result->slide6); $this->view->slide6 = $result->slide6; $form->link6->setValue($result->link6); $this->view->form = $form; if (!$this->_request->isPost()) { return; } $formData = $this->_request->getPost(); if (!$form->isValid($formData)) { return; } //var_dump($formData); return; //For upload slide 1 $file_name1 = null; $image_name1 = $_FILES["slide1"]["name"]; if (isset($image_name1) && strlen($image_name1) > 0) { try { if (isset($result->slide1)) { $image_file = SYSTEM_PATH . "/images/user/slides/" . $result->slide1; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/" . $result->slide1); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/200X200/" . $result->slide1); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/500X500/" . $result->slide1); } } $slide = $_FILES['slide1']['name']; $random = rand(9, 999999); $file_name1 = $random . $slide; $formData["slide1"] = $file_name1; move_uploaded_file($_FILES["slide1"]['tmp_name'], SYSTEM_PATH . "images/user/slides/" . $file_name1); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/slides/" . $file_name1); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/slides/500X500/" . $file_name1); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/slides/200X200/" . $file_name1); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['slide1'] = $result->slide1; } //For upload slide 2 $file_name2 = null; $image_name2 = $_FILES["slide2"]["name"]; if (isset($image_name2) && strlen($image_name2) > 0) { try { if (isset($result->slide2)) { $image_file = SYSTEM_PATH . "/images/user/slides/" . $result->slide2; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/" . $result->slide2); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/200X200/" . $result->slide2); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/500X500/" . $result->slide2); } } $slide = $_FILES['slide2']['name']; $random = rand(9, 999999); $file_name2 = $random . $slide; $formData["slide2"] = $file_name2; move_uploaded_file($_FILES["slide2"]['tmp_name'], SYSTEM_PATH . "images/user/slides/" . $file_name2); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/slides/" . $file_name2); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/slides/500X500/" . $file_name2); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/slides/200X200/" . $file_name2); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['slide2'] = $result->slide2; } //For upload slide 3 $file_name3 = null; $image_name3 = $_FILES["slide3"]["name"]; if (isset($image_name3) && strlen($image_name3) > 0) { try { if (isset($result->slide3)) { $image_file = SYSTEM_PATH . "/images/user/slides/" . $result->slide3; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/" . $result->slide3); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/200X200/" . $result->slide3); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/500X500/" . $result->slide3); } } $slide = $_FILES['slide3']['name']; $random = rand(9, 999999); $file_name3 = $random . $slide; $formData["slide3"] = $file_name3; move_uploaded_file($_FILES["slide3"]['tmp_name'], SYSTEM_PATH . "images/user/slides/" . $file_name3); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/slides/" . $file_name3); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/slides/500X500/" . $file_name3); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/slides/200X200/" . $file_name3); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['slide3'] = $result->slide3; } //For upload slide 4 $file_name4 = null; $image_name4 = $_FILES["slide4"]["name"]; if (isset($image_name4) && strlen($image_name4) > 0) { try { if (isset($result->slide4)) { $image_file = SYSTEM_PATH . "/images/user/slides/" . $result->slide4; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/" . $result->slide4); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/200X200/" . $result->slide4); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/500X500/" . $result->slide4); } } $slide = $_FILES['slide4']['name']; $random = rand(9, 999999); $file_name4 = $random . $slide; $formData["slide4"] = $file_name4; move_uploaded_file($_FILES["slide4"]['tmp_name'], SYSTEM_PATH . "images/user/slides/" . $file_name4); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/slides/" . $file_name4); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/slides/500X500/" . $file_name4); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/slides/200X200/" . $file_name4); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['slide4'] = $result->slide4; } //For upload slide 5 $file_name5 = null; $image_name5 = $_FILES["slide5"]["name"]; if (isset($image_name5) && strlen($image_name5) > 0) { try { if (isset($result->slide5)) { $image_file = SYSTEM_PATH . "/images/user/slides/" . $result->slide5; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/" . $result->slide5); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/200X200/" . $result->slide5); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/500X500/" . $result->slide5); } } $slide = $_FILES['slide5']['name']; $random = rand(9, 999999); $file_name5 = $random . $slide; $formData["slide5"] = $file_name5; move_uploaded_file($_FILES["slide5"]['tmp_name'], SYSTEM_PATH . "images/user/slides/" . $file_name5); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/slides/" . $file_name5); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/slides/500X500/" . $file_name5); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/slides/200X200/" . $file_name5); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['slide5'] = $result->slide5; } //For upload slide 6 $file_name6 = null; $image_name6 = $_FILES["slide6"]["name"]; if (isset($image_name6) && strlen($image_name6) > 0) { try { if (isset($result->slide6)) { $image_file = SYSTEM_PATH . "/images/user/slides/" . $result->slide6; if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/" . $result->slide6); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/200X200/" . $result->slide6); } if (file_exists($image_file)) { unlink(SYSTEM_PATH . "/images/user/slides/500X500/" . $result->slide6); } } $slide = $_FILES['slide6']['name']; $random = rand(9, 999999); $file_name6 = $random . $slide; $formData["slide6"] = $file_name6; move_uploaded_file($_FILES["slide6"]['tmp_name'], SYSTEM_PATH . "images/user/slides/" . $file_name6); $thumb = new Application_Model_Thumbnail(SYSTEM_PATH . "images/user/slides/" . $file_name6); $thumb->resize(500, 500); $thumb->save(SYSTEM_PATH . "images/user/slides/500X500/" . $file_name6); $thumb->resize(200, 200); $thumb->save(SYSTEM_PATH . "images/user/slides/200X200/" . $file_name6); } catch (Zend_File_Transfer_Exception $e) { throw new Exception('Bad data: ' . $e->getMessage()); } } else { $formData['slide6'] = $result->slide6; } $formData['id'] = $id; $result = $this->sliders->updateSlider($formData); $this->view->msg = $result; $this->_redirect("/admin/sliders/edit/id/" . $id); }