Пример #1
0
 public function create()
 {
     $data = array();
     $categoryCollection = new CategoryCollection();
     $categories = $categoryCollection->getAll();
     $insertInfo = array('name' => '', 'image' => '', 'category_id' => '', 'description' => '');
     $errors = array();
     if (isset($_POST['createTour'])) {
         $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('name' => $_POST['name'], 'image' => $newName, 'category_id' => $_POST['categories'], 'description' => $_POST['description']);
         if (empty($imageErrors) && empty($errors)) {
             $toursCollection = new ToursCollection();
             $toursEntity = new ToursEntity();
             $obj = $toursEntity->init($insertInfo);
             $toursCollection->save($obj);
             $fileUpload->upload('uploads/tours/' . $newName);
             header("Location: index.php?c=tour&m=index");
         }
     }
     $data['errors'] = $errors;
     $data['categories'] = $categories;
     $data['insertInfo'] = $insertInfo;
     $this->loadView('tours/create', $data);
 }
 public function index()
 {
     if (!$this->loggedIn()) {
         header('Location: index.php?c=login&m=login');
     }
     $data = array();
     $categoryCollection = new CategoryCollection();
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $perPage = 5;
     $offset = $page ? ($page - 1) * $perPage : 0;
     $rows = count($categoryCollection->getAll());
     $pagination = new Pagination();
     $pagination->setPerPage($perPage);
     $pagination->setTotalRows($rows);
     $pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/admin/index.php?c=category&m=index");
     $categories = $categoryCollection->getAll(array(), $offset, $perPage);
     $data['categories'] = $categories;
     $data['pagination'] = $pagination;
     $this->loadView('category/listing', $data);
 }
Пример #3
0
    ?>
                        <?php 
}
?>
                        <li class="divider"></li>
                        <li><a class="text-center" href="">View Cart</a></li>
                    </ul>
                </li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown ">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="true">Tours Categories <b class="caret"></b></a>
                    <ul class="dropdown-menu">
                        <?php 
$categoryCollection = new CategoryCollection();
$categories = $categoryCollection->getAll();
?>
                        <li>
                            <a href="index.php?c=tours&m=index&id=0">All Categories</a>
                        </li>
                        <?php 
foreach ($categories as $category) {
    ?>
                        <li>
                            <a href="index.php?c=tours&m=index&id=<?php 
    echo $category->getId();
    ?>
"><?php 
    echo $category->getName();
    ?>
</a>