コード例 #1
0
 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);
 }
コード例 #2
0
 public function show()
 {
     $data = array();
     $blogId = isset($_GET['id']) ? (int) $_GET['id'] : 0;
     if ($blogId == 0) {
         header("Location: index.php?c=blog");
     }
     $blogCollection = new BlogCollection();
     $blog = $blogCollection->getOne($blogId);
     if ($blog === null) {
         header("Location: index.php?c=blog");
     }
     $blogImagesCollection = new BlogImagesCollection();
     $blogImages = $blogImagesCollection->getAll(array('blog_post_id' => $blog->getId()));
     $data['blog'] = $blog;
     $data['blogImages'] = $blogImages;
     $this->loadFrontView('blog/show', $data);
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 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);
 }
コード例 #5
0
if (isset($_POST['addBlogPost'])) {
    $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, 'description' => $_POST['description']);
    if (empty($imageErrors) && empty($errors)) {
        $blogPostEntity = new BlogEntity();
        $obj = $blogPostEntity->init($insertInfo);
        $blogPostCollection = new BlogCollection();
        $blogPostCollection->save($obj);
        $fileUpload->upload('uploads/tours/' . $newName);
        header("Location: blog.php");
    }
}
require_once 'common/sidebar.php';
?>
    <!-- start: Content -->
    <div id="content" class="span10">


        <ul class="breadcrumb">
            <li>
                <i class="icon-home"></i>
                <a href="index.php">Home</a>