public function create() { $data = array(); $categoryCollection = new CategoryCollection(); $categories = $categoryCollection->getAll(); $insertInfo = array('title' => '', 'image' => ''); $errors = array(); if (isset($_POST['createSlide'])) { $fileUpload = new fileUpload('image'); $file = $fileUpload->getFilename(); $fileExtention = $fileUpload->getFileExtention(); $imageErrors = array(); if ($file != '') { $imageErrors = $fileUpload->validate(); $newName = sha1(time()) . '.' . $fileExtention; } else { $newName = ''; } $insertInfo = array('title' => $_POST['title'], 'image' => $newName); if (empty($imageErrors) && empty($errors)) { $toursCollection = new SliderCollection(); $toursEntity = new SliderEntity(); $obj = $toursEntity->init($insertInfo); $toursCollection->save($obj); $fileUpload->upload('uploads/tours/' . $newName); header("Location: index.php?c=slider&m=index"); } } $data['errors'] = $errors; $data['insertInfo'] = $insertInfo; $this->loadView('slider/create', $data); }
public function blogImages() { if (!$this->loggedIn()) { header('Location: index.php?c=login&m=login'); } $data = array(); if (!isset($_GET['id'])) { header('Location: index.php?c=blog&m=index'); } $blogCollection = new BlogCollection(); $blog = $blogCollection->getOne($_GET['id']); if (is_null($blog)) { header('Location: index.php?c=blog&m=index'); } $blogImagesCollection = new BlogImagesCollection(); $images = $blogImagesCollection->getAll(array('blog_post_id' => $_GET['id'])); $fileUpload = new fileUpload('image'); $file = $fileUpload->getFilename(); $fileExtention = $fileUpload->getFileExtention(); $imageErrors = array(); if ($file != '') { $imageErrors = $fileUpload->validate(); $newName = sha1(time()) . '.' . $fileExtention; $insertInfo = array('blog_post_id' => $_GET['id'], 'image' => $newName); if (empty($imageErrors)) { $imageEntity = new BlogImagesEntity(); $obj = $imageEntity->init($insertInfo); $blogImagesCollection->save($obj); $fileUpload->upload('uploads/tours/' . $newName); header("Location: index.php?c=blog&m=blogImages&id=" . $_GET['id']); } } else { } $data['imageErrors'] = $imageErrors; $data['images'] = $images; $data['blogId'] = $_GET['id']; $this->loadView('blog/blogImages', $data); }
if (!loggedIn()) { header('Location: login.php'); } if (!isset($_GET['id'])) { header('Location: tours.php'); } $tourCollection = new ToursCollection(); $tour = $tourCollection->getOne($_GET['id']); if (is_null($tour)) { header('Location: tours.php'); } $tourImagesCollection = new ToursImagesCollection(); $images = $tourImagesCollection->getAll(array('tours_id' => $_GET['id'])); $fileUpload = new fileUpload('image'); $file = $fileUpload->getFilename(); $fileExtention = $fileUpload->getFileExtention(); $imageErrors = array(); if ($file != '') { $imageErrors = $fileUpload->validate(); $newName = sha1(time()) . '.' . $fileExtention; $insertInfo = array('tours_id' => $_GET['id'], 'image' => $newName); if (empty($imageErrors)) { $imageEntity = new ToursImagesEntity(); $obj = $imageEntity->init($insertInfo); $tourImagesCollection->save($obj); $fileUpload->upload('uploads/tours/' . $newName); header("Location: tourImages.php?id=" . $_GET['id']); } } else { } ?>