Пример #1
0
 public function index()
 {
     $data = array();
     $blogCollection = new BlogCollection();
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $perPage = 5;
     $offset = $page ? ($page - 1) * $perPage : 0;
     $rows = count($blogCollection->getAll());
     $pagination = new Pagination();
     $pagination->setPerPage($perPage);
     $pagination->setTotalRows($rows);
     $pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/index.php?c=blog&m=index");
     $blogs = $blogCollection->getAll(array(), $offset, $perPage);
     $data['blogs'] = $blogs;
     $data['pagination'] = $pagination;
     $this->loadFrontView('blog/listing', $data);
 }
Пример #2
0
 public function index()
 {
     if (!$this->loggedIn()) {
         header('Location: index.php?c=login&m=login');
     }
     $data = array();
     $usersCollection = new UserCollection();
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $perPage = 5;
     $offset = $page ? ($page - 1) * $perPage : 0;
     $rows = count($usersCollection->getAll());
     $pagination = new Pagination();
     $pagination->setPerPage($perPage);
     $pagination->setTotalRows($rows);
     $pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/admin/index.php?c=user&m=index");
     $users = $usersCollection->getAll(array(), $offset, $perPage);
     $data['users'] = $users;
     $data['pagination'] = $pagination;
     $this->loadView('users/listing', $data);
 }
Пример #3
0
 public function index()
 {
     $data = array();
     $categoryId = isset($_GET['id']) ? $_GET['id'] : 0;
     $toursCollection = new ToursCollection();
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $perPage = 6;
     $offset = $page ? ($page - 1) * $perPage : 0;
     if ($categoryId > 0) {
         $where = array('category_id' => $categoryId);
         $rows = count($toursCollection->getAll($where));
         $tours = $toursCollection->getAll($where, $offset, $perPage);
     } else {
         $rows = count($toursCollection->getAll());
         $tours = $toursCollection->getAll(array(), $offset, $perPage);
     }
     $pagination = new Pagination();
     $pagination->setPerPage($perPage);
     $pagination->setTotalRows($rows);
     $pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/index.php?c=tours&m=index&id=" . $categoryId);
     $data['pagination'] = $pagination;
     $data['tours'] = $tours;
     $this->loadFrontView('tours/listing', $data);
 }
Пример #4
0
 public function index()
 {
     $data = array();
     if (!$this->loggedIn()) {
         header('Location: index.php?c=login&m=login');
     }
     $search = isset($_GET['search']) ? $_GET['search'] : '';
     if (trim($search) != '') {
         $like = array('name', htmlspecialchars(trim($search)));
     } else {
         $like = array();
     }
     $perPageSelect = isset($_GET['perPage']) ? (int) $_GET['perPage'] : 0;
     switch ($perPageSelect) {
         case 0:
             $perPage = 10;
             break;
         case 1:
             $perPage = 5;
             break;
         case 2:
             $perPage = 10;
             break;
         case 3:
             $perPage = 20;
             break;
         case 4:
             $perPage = 50;
             break;
         default:
             $perPage = 10;
     }
     $orderBy = isset($_GET['orderBy']) ? (int) $_GET['orderBy'] : 0;
     switch ($orderBy) {
         case 0:
             $order = array('id', 'DESC');
             break;
         case 1:
             $order = array('name', 'ASC');
             break;
         case 2:
             $order = array('name', 'DESC');
             break;
         case 3:
             $order = array('category_id', 'ASC');
             break;
         case 4:
             $order = array('category_id', 'DESC');
             break;
         default:
             $order = array('id', 'DESC');
     }
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $offset = $page ? ($page - 1) * $perPage : 0;
     $toursCollection = new ToursCollection();
     $rows = count($toursCollection->getAll(array(), -1, 0, $order, $like)) == 0 ? 1 : count($toursCollection->getAll(array(), -1, 0, $order, $like));
     $pagination = new Pagination();
     $pagination->setPerPage($perPage);
     $pagination->setTotalRows($rows);
     $pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/admin/index.php?c=tour&m=index&perPage={$perPageSelect}&orderBy={$orderBy}&search={$search}");
     $tours = $toursCollection->getAll(array(), $offset, $perPage, $order, $like);
     $data['tours'] = $tours;
     $data['pagination'] = $pagination;
     $data['search'] = $search;
     $data['perPageSelect'] = $perPageSelect;
     $data['orderBy'] = $orderBy;
     $data['page'] = $page;
     $this->loadView('tours/listing', $data);
 }
Пример #5
0
                    <thead>
                    <tr>
                        <th>Username</th>
                        <th>Email</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php 
$usersCollection = new UserCollection();
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$perPage = 5;
$offset = $page ? ($page - 1) * $perPage : 0;
$rows = count($usersCollection->getAll());
$pagination = new Pagination();
$pagination->setPerPage($perPage);
$pagination->setTotalRows($rows);
$pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/admin/users.php");
$users = $usersCollection->getAll(array(), $offset, $perPage);
foreach ($users as $user) {
    ?>
                        <tr>
                            <td><?php 
    echo $user->getUsername();
    ?>
</td>
                            <td class="center"><?php 
    echo $user->getEmail();
    ?>
</td>
                            <td class="center"><?php