public function index() { $data = array(); //last 3 blog posts $blogCollection = new BlogCollection(); $lastBlogposts = $blogCollection->getAll(array(), 3, 0, array('id', 'DESC')); //random 6 tours $toursCollection = new ToursCollection(); $randomTours = $toursCollection->getAll(array(), 6, 0, array('id', 'desc'), array(), 1); $data['lastBlogPosts'] = $lastBlogposts; $data['randomTours'] = $randomTours; $this->loadFrontView('landingPage', $data); }
public function show() { $data = array(); $tourId = isset($_GET['id']) ? (int) $_GET['id'] : 0; if ($tourId == 0) { header("Location: index.php?c=tours"); } $toursCollection = new ToursCollection(); $tour = $toursCollection->getOne($tourId); if ($tour === null) { header("Location: index.php?c=tours"); } $tourImagesCollection = new ToursImagesCollection(); $tourImages = $tourImagesCollection->getAll(array('tours_id' => $tour->getId())); $data['tour'] = $tour; $data['tourImages'] = $tourImages; $this->loadFrontView('tours/show', $data); }
public function index() { if (!$this->loggedIn()) { header('Location: index.php?c=login&m=login'); } $data = array(); //users $userCollection = new UserCollection(); $users = count($userCollection->getAll()); //customers $clientCollection = new ClientsCollection(); $client = count($clientCollection->getAll()); //tours $toursCollection = new ToursCollection(); $tours = count($toursCollection->getAll()); //blog posts $blogpostCollection = new BlogCollection(); $blogs = count($blogpostCollection->getAll()); $data['users'] = $users; $data['client'] = $client; $data['tours'] = $tours; $data['blogs'] = $blogs; $this->loadView('dashboard', $data); }
<?php require_once 'common/header.php'; 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']); }
<?php require_once 'common/header.php'; if (!loggedIn()) { header('Location: login.php'); } if (!isset($_GET['id'])) { header('Location: tours.php'); } $toursCollection = new ToursCollection(); $tour = $toursCollection->getOne($_GET['id']); if (is_null($tour)) { header('Location: tours.php'); } $toursCollection->delete($tour->getId()); header('Location: tours.php');
public function tourImages() { if (!$this->loggedIn()) { header('Location: index.php?c=login&m=login'); } $data = array(); if (!isset($_GET['id'])) { header('Location: index.php?c=tour&m=index'); } $tourCollection = new ToursCollection(); $tour = $tourCollection->getOne($_GET['id']); if (is_null($tour)) { header('Location: index.php?c=tour&m=index'); } $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: index.php?c=tour&m=tourImages&id=" . $_GET['id']); } } else { } $data['imageErrors'] = $imageErrors; $data['images'] = $images; $data['tourId'] = $_GET['id']; $this->loadView('tours/tourImages', $data); }