Exemplo n.º 1
0
 public function route()
 {
     $request = trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
     $request_arr = explode('/', $request);
     if ($request == '') {
         $controller = new IndexController($this->service);
         $controller->indexAction();
     } elseif ($request == 'basket') {
         $controller = new BasketController($this->service);
         $controller->indexAction();
     } elseif ($request == 'auth') {
         $controller = new AuthController($this->service);
         $controller->indexAction();
     } elseif ($request == 'reg') {
         $controller = new RegController($this->service);
         $controller->indexAction();
     } elseif ($request == 'admin') {
         $controller = new AdminController($this->service);
         $controller->indexAction();
     } elseif ($request == 'admin/additem') {
         $controller = new AdminController($this->service);
         $controller->additemAction();
     } elseif ($request == 'admin/category') {
         $controller = new AdminController($this->service);
         $controller->categoryAction();
     } elseif ($request == 'admin/catalog') {
         $controller = new AdminController($this->service);
         $controller->catalogAction();
     } elseif ($request == 'admin/orders') {
         $controller = new AdminController($this->service);
         $controller->ordersAction();
     } elseif ($request = 'cat/' . $request_arr[1]) {
         $category_mapper = new CategoryMapper($this->service->get('db'));
         if (!$category_mapper->getCategoryFromCode($request_arr[1])) {
             $this->get404();
         } else {
             $controller = new CatController($this->service);
             $controller->categoryAction($request_arr[1]);
         }
     } else {
         $this->get404();
     }
 }
Exemplo n.º 2
0
<?php

//category.php
session_start();
include 'core/connect.php';
include 'nav.php';
require 'Controllers/class.CatController.inc';
require 'Controllers/class.TopicController.inc';
//first select the category based on $_GET['cat_id']
$id = mysql_real_escape_string($_GET['id']);
$obj = new CatController($id);
// create new object of CatController class
$result = $obj->getTopics();
$name = $obj->getName();
//echo $name;
//Label bar
echo "<div id=\"catContainer\">\r\n\t<p>{$name}</p>\r\n\t<div class=\"topic\" id=\"titlebar\">\r\n\t\t<div id=\"name\">Title</div>\r\n\t\t<div id=\"created-by\">Created by</div>\r\n\t\t<div id=\"reply-count\">Replies</div>\r\n\t\t<div id=\"last-update\">Last Update</div>\r\n\t</div>\n\t";
//Need to echo the create box
if (mysql_num_rows($result) == 0) {
    //Echo an empty thing instead?
    echo '<br>There are no topics in this category yet.';
} else {
    /*
    //prepare the table
    echo '<table border="1">
    	  <tr>
    		<th>Topic</th>
    		<th>Created at</th>
    	  </tr>';	
    	
    while($row = mysql_fetch_assoc($result))