예제 #1
0
 public function actionProduct()
 {
     $obj = new ProductDB();
     if (!$obj->getProduct($this->request->id)) {
         $this->notFound();
     }
     $this->title = $obj->title;
     //$this->meta_desc = $obj->meta_desc;
     //$this->meta_key= $obj->meta_key;
     $head = $this->getHead(array("/css/main.css"));
     $head->js = array("/js/main.js", "/js/gallery.js");
     $product = new Product();
     $hornav = $this->getHornav();
     $hornav->addData($obj->section, URL::get("section", "", array("id" => $obj->section_id)));
     $hornav->addData($obj->category, URL::get("category", "", array("id" => $obj->category_id)));
     $hornav->addData($obj->title);
     $product->hornav = $hornav;
     $product->title = $obj->title;
     $product->img = $obj->img;
     $product->available = $obj->available;
     $product->id = $obj->id;
     $product->brand = $obj->brand;
     $product->brand_img = Config::DIR_IMG_BRAND . $obj->brand_img;
     $product->price = $obj->price;
     $product->full_text = $obj->full_text;
     $product->video = $obj->video;
     $product->foto = ImgDB::getImgOnID($this->request->id);
     $product->others = ProductDB::getOthers($this->request->id);
     $this->render($head, $product);
 }
예제 #2
0
require '../model/database.php';
require '../model/category.php';
require '../model/category_db.php';
require '../model/product.php';
require '../model/product_db.php';
if (isset($_POST['action'])) {
    $action = $_POST['action'];
} else {
    if (isset($_GET['action'])) {
        $action = $_GET['action'];
    } else {
        $action = 'list_products';
    }
}
if ($action == 'list_products') {
    $category_id = $_GET['category_id'];
    if (empty($category_id)) {
        $category_id = 1;
    }
    $current_category = CategoryDB::getCategory($category_id);
    $categories = CategoryDB::getCategories();
    $products = ProductDB::getProductsByCategory($category_id);
    include 'product_list.php';
} else {
    if ($action == 'view_product') {
        $categories = CategoryDB::getCategories();
        $product_id = $_GET['product_id'];
        $product = ProductDB::getProduct($product_id);
        include 'product_view.php';
    }
}
예제 #3
0
파일: index.php 프로젝트: j-jm/web182
require '../model/category_db.php';
require '../model/product.php';
require '../model/product_db.php';
// create the CategoryDB and ProductDB objects
$categoryDB = new CategoryDB();
$productDB = new ProductDB();
$action = filter_input(INPUT_POST, 'action');
if ($action == NULL) {
    $action = filter_input(INPUT_GET, 'action');
    if ($action == NULL) {
        $action = 'list_products';
    }
}
if ($action == 'list_products') {
    $category_id = filter_input(INPUT_GET, 'category_id', FILTER_VALIDATE_INT);
    if ($category_id == NULL || $category_id == FALSE) {
        $category_id = 1;
    }
    // Get product and category data
    $current_category = $categoryDB->getCategory($category_id);
    $categories = $categoryDB->getCategories();
    $products = $productDB->getProductsByCategory($category_id);
    include 'product_list.php';
} else {
    if ($action == 'view_product') {
        $categories = $categoryDB->getCategories();
        $product_id = filter_input(INPUT_GET, 'product_id', FILTER_VALIDATE_INT);
        $product = $productDB->getProduct($product_id);
        include 'product_view.php';
    }
}