public function actionCategory()
 {
     $category_db = new CategoryDB();
     $category_db->load($this->request->id);
     if (!$category_db->isSaved()) {
         $this->notFound();
     } else {
         $this->section_id = $category_db->section_id;
         $this->title = $category_db->title;
         $this->meta_desc = $category_db->meta_desc;
         $this->meta_key = $category_db->meta_key;
         $section_db = new SectionDB();
         $section_db->load($category_db->section_id);
         $hornav = $this->getHornav();
         //горизонтальная навигация
         $hornav->addData($section_db->title, $section_db->link);
         $hornav->addData($category_db->title);
         $intro = new Intro();
         $intro->hornav = $hornav;
         $intro->obj = $category_db;
         $category = new Category();
         $articles = ArticleDB::getAllOnCatID($this->request->id, Config::COUNT_ARTICLES_ON_PAGE);
         $more_articles = ArticleDB::getAllOnSectionID($this->request->id, false, false);
         $category->articles = $articles;
         $this->render($intro . $category);
     }
 }
示例#2
0
 public function __construct($id = false)
 {
     parent::__construct();
     $this->add("sections");
     $this->name = "form_category";
     $this->enctype = "multipart/form-data";
     $this->action = URL::current();
     $this->sections = SectionDB::getAll();
     if (!$id) {
         $this->text("title", "Название:", FormProcessor::getSessionData("title"));
         $this->textarea("meta_desc", "Описание:", FormProcessor::getSessionData("meta_desc"));
         $this->textarea("meta_key", "Ключевые слова:", FormProcessor::getSessionData("meta_key"));
         $this->text("alias", "ЧПУ ссылка", FormProcessor::getSessionData("alias"));
         $this->checkbox("show", "Показывать:", "1");
         $this->submit("insert_category", "Сохранить");
     } else {
         $this->add("section_id");
         $this->hidden("id", $id);
         $obj = new CategoryDB();
         $obj->load($id);
         $this->text("title", "Название:", $obj->title);
         $this->textarea("meta_desc", "Описание:", $obj->meta_desc);
         $this->textarea("meta_key", "Ключевые слова:", $obj->meta_key);
         $link = URL::get("category", "", array("id" => $id), true, "", false);
         $alias = SefDB::getAliasOnLink($link);
         $this->text("alias", "ЧПУ ссылка", $alias);
         $this->checkbox("show", "Показывать:", "1", "", (int) $obj->show);
         $this->submit("update_category", "Сохранить");
         $this->section_id = $obj->section_id;
     }
 }
示例#3
0
 public function go()
 {
     $p = 0;
     $brand = array();
     $xml = file_get_contents('http://abumba.ru/index.php?route=feed/opt_yml');
     //$xml = file_get_contents('http://test');
     $dom = new SimpleXMLElement($xml);
     $categories = $dom->shop->categories->category;
     $products = $dom->shop->offers->offer;
     foreach ($categories as $category) {
         $category_db = new CategoryDB();
         $category_db->number = $category["id"];
         $category_db->parent_number = $category["parentId"] ? $category["parentId"] : null;
         $category_db->title = (string) $category;
         $category_db->meta_desc = (string) $category;
         $category_db->meta_key = (string) $category;
         $category_id = $category_db->save();
         foreach ($products as $product) {
             if ((string) $product->categoryId[0] == (string) $category["id"]) {
                 $images = $product->picture;
                 $product_db = new ProductDB();
                 $product_db->category_id = (int) $category_id;
                 $product_db->img = (string) $product->picture[0];
                 $product_db->price = (string) $product->price[0];
                 $product_db->title = (string) $product->name[0];
                 $product_db->meta_desc = (string) $product->name[0];
                 $product_db->meta_key = (string) $product->name[0];
                 if ($product["available"] === "false") {
                     $product_db->available = 0;
                 } else {
                     $product_db->available = 1;
                 }
                 $brand = (string) $product->vendor[0];
                 $id = BrandDB::getBrandIDonName($brand);
                 if (!$id) {
                     $brand_db = new BrandDB();
                     $brand_db->title = $brand;
                     $brand_db->img = null;
                     $product_db->brand_id = $brand_db->save();
                 } else {
                     $product_db->brand_id = $id;
                 }
                 $product_id = $product_db->save();
                 $p++;
                 for ($j = 1; $j < count($images); $j++) {
                     $img_db = new ImgDB();
                     $img_db->product_id = (int) $product_id;
                     $img_db->url = (string) $images[$j];
                     $img_db->save();
                 }
             }
         }
     }
     echo "В базу внесено " . $p . " наименований товаров.";
 }
示例#4
0
 public function getCategoryIdOnName($p_title)
 {
     foreach ($this->xml_products as $xml_product) {
         $name = (string) $xml_product->name[0];
         if ($name === $p_title) {
             $number = (string) $xml_product->categoryId[0];
             $id = CategoryDB::getIdonNumder($number);
             return $id;
         }
     }
 }
示例#5
0
 public static function getProduct($product_id)
 {
     $db = Database::getDB();
     $query = "SELECT * FROM products\n                  WHERE productID = '{$product_id}'";
     $result = $db->query($query);
     $row = $result->fetch();
     $category = CategoryDB::getCategory($row['categoryID']);
     $product = new Product($category, $row['productCode'], $row['productName'], $row['listPrice']);
     $product->setID($row['productID']);
     return $product;
 }
示例#6
0
 public static function getProduct($product_id)
 {
     $db = Database::getDB();
     $query = 'SELECT * FROM products
               WHERE productID = :product_id';
     $statement = $db->prepare($query);
     $statement->bindValue(":product_id", $product_id);
     $statement->execute();
     $row = $statement->fetch();
     $statement->closeCursor();
     $category = CategoryDB::getCategory($row['categoryID']);
     $product = new Product($category, $row['productCode'], $row['productName'], $row['listPrice']);
     $product->setID($row['productID']);
     return $product;
 }
示例#7
0
 public function __construct($id = false)
 {
     parent::__construct();
     $this->add("categories");
     $this->add("brands");
     $this->name = "form_product";
     $this->enctype = "multipart/form-data";
     $this->action = URL::current();
     $this->categories = CategoryDB::getAll();
     $this->brands = BrandDB::getAll();
     if (!$id) {
         $this->text("title", "Название:", FormProcessor::getSessionData("title"));
         $this->text("price", "Цена:", FormProcessor::getSessionData("price"));
         $this->textarea("meta_desc", "Короткое описание<br />(не более 255 символов):", FormProcessor::getSessionData("meta_desc"));
         $this->textarea("full_text", "Длинное описание<br />(хоть сколько символов):", FormProcessor::getSessionData("full_text"));
         $this->textarea("meta_key", "Ключевые слова:", FormProcessor::getSessionData("meta_key"));
         $this->text("alias", "ЧПУ ссылка", FormProcessor::getSessionData("alias"));
         $this->text("video", "Ссылка на видео", FormProcessor::getSessionData("video"));
         $this->checkbox("available", "Наличие:", "1");
         $this->file("img", "Картинка:");
         $this->submit("insert_product", "Сохранить");
     } else {
         $this->add("category_id");
         $this->add("brand_id");
         $this->add("fotos");
         $this->hidden("id", $id);
         $obj = new ProductDB();
         $obj->load($id);
         $this->text("price", "Цена:", $obj->price);
         $this->textarea("title", "Название:", $obj->title);
         $this->textarea("meta_desc", "Короткое описание<br />(не более 255 символов):", $obj->meta_desc);
         $this->textarea("full_text", "Длинное описание<br />(хоть сколько символов):", $obj->full_text);
         $this->textarea("meta_key", "Ключевые слова:", $obj->meta_key);
         $link = URL::get("product", "", array("id" => $id), true, "", false);
         $alias = SefDB::getAliasOnLink($link);
         $this->text("alias", "ЧПУ ссылка", $alias);
         $this->text("video", "Ссылка на видео", $obj->video);
         $this->checkbox("available", "Наличие:", "1", "", (int) $obj->available);
         $this->file("img", "Картинка:");
         $this->submit("update_product", "Сохранить");
         $view = new View(Config::DIR_TMPL);
         $this->img = $view->render("img", array("src" => $obj->img), true);
         $this->category_id = $obj->category_id;
         $this->brand_id = $obj->brand_id;
         $this->fotos = ImgDB::getImgOnID($id);
     }
 }
示例#8
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';
    }
}
示例#9
0
 private function postHandling()
 {
     $this->categories = CategoryDB::getCategoryOnSection($this->id);
     $this->products = ProductDB::getThreeRandProductOnSection($this->id);
 }
示例#10
0
文件: index.php 项目: j-jm/web182
<?php

require '../model/database.php';
require '../model/category.php';
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);
    // Display the product list
    include 'product_list.php';
} else {
    if ($action == 'delete_product') {
        // Get the IDs
示例#11
0
文件: index.php 项目: j-jm/web182
        // Get the IDs
        $product_id = filter_input(INPUT_POST, 'product_id', FILTER_VALIDATE_INT);
        $category_id = filter_input(INPUT_POST, 'category_id', FILTER_VALIDATE_INT);
        // Delete the product
        ProductDB::deleteProduct($product_id);
        // Display the Product List page for the current category
        header("Location: .?category_id={$category_id}");
    } else {
        if ($action == 'show_add_form') {
            $categories = CategoryDB::getCategories();
            include 'product_add.php';
        } else {
            if ($action == 'add_product') {
                $category_id = filter_input(INPUT_POST, 'category_id', FILTER_VALIDATE_INT);
                $code = filter_input(INPUT_POST, 'code');
                $name = filter_input(INPUT_POST, 'name');
                $price = filter_input(INPUT_POST, 'price');
                if ($category_id == NULL || $category_id == FALSE || $code == NULL || $name == NULL || $price == NULL || $price == FALSE) {
                    $error = "Invalid product data. Check all fields and try again.";
                    include '../errors/error.php';
                } else {
                    $current_category = CategoryDB::getCategory($category_id);
                    $product = new Product($current_category, $code, $name, $price);
                    ProductDB::addProduct($product);
                    // Display the Product List page for the current category
                    header("Location: .?category_id={$category_id}");
                }
            }
        }
    }
}
示例#12
0
 public function actionCategory()
 {
     $obj = new CategoryDB();
     if (!$obj->load($this->request->id)) {
         $this->notFound();
     }
     $this->title = $obj->title;
     $this->meta_desc = $obj->meta_desc;
     $this->meta_key = $obj->meta_key;
     $section_db = new SectionDB();
     $section_db->load($obj->section_id);
     $head = $this->getHead(array("/css/main.css"));
     $head->js = array("/js/main.js");
     $content = new Categoryproduct();
     $url = URL::get("category", "", array("id" => $this->request->id));
     $section_url = URL::get("section", "", array("id" => $section_db->id));
     $hornav = $this->getHornav();
     $hornav->addData($section_db->title, $section_url);
     $hornav->addData($obj->title);
     $content->hornav = $hornav;
     $content->title = $obj->title;
     $count = ProductDB::getCountProductOnCategory($this->request->id);
     $offset = $this->getOffset(Config::COUNT_PRODUCTS_ON_PAGE);
     $products = ProductDB::getProductOnCategory($this->request->id, Config::COUNT_PRODUCTS_ON_PAGE, $offset);
     $pagination = $this->getPagination($count, Config::COUNT_PRODUCTS_ON_PAGE, $url);
     $content->products = $products;
     $content->pagination = $pagination;
     $this->render($head, $content);
 }
示例#13
0
 private function setSectionAndCategory()
 {
     $section = new SectionDB();
     $section->load($this->section_id);
     $category = new CategoryDB();
     $category->load($this->cat_id);
     if ($section->isSaved()) {
         $this->section = $section;
     }
     if ($category->isSaved()) {
         $this->category = $category;
     }
 }
function showArticleAdministration()
{
    $artID = -1;
    $artSystemName = '';
    $artSystemDescription = '';
    $artPrice = '';
    $artImagePath = '';
    $action = 'add';
    if (isset($_GET['origin']) && $_GET['origin'] == 'update' && isset($_GET['artId'])) {
        if (isset($_GET['artId'])) {
            $artID = $_GET['artId'];
        }
        $action = 'update';
        $lang = get_language();
        include_once "./includes/items.php";
        $item = getSysItem($artID);
        $artID = $item->getId();
        $artSystemName = $item->getName();
        $artSystemDescription = $item->getDescription();
        $artPrice = $item->getPrice();
        $artImagePath = $item->getImage();
    } else {
        if (isset($_GET['origin']) && $_GET['origin'] == 'add') {
            $action = 'add';
        }
    }
    $categoryDB = new CategoryDB();
    $categoryArticleDB = new CategoryArticleDB();
    $languageDB = new LanguageDB();
    $sqlcategoryArticleRes = $categoryArticleDB->getAllCategorysByArticle($artID);
    $sqlcategoryRes = $categoryDB->getAllCategorys();
    $selectedCats = array();
    while ($catArt = $sqlcategoryArticleRes->fetch_object()) {
        $selectedCats[] = $catArt->categoryId;
    }
    $sqllanguageRes = $languageDB->getAllLanguages();
    echo "<form action=\"index.php?site=administration\" method=\"post\">";
    echo "<input type=\"hidden\" name=\"artId\" value=\"{$artID}\" /input>";
    echo "<table style=\"width:95%\">";
    echo "<tr>";
    echo "<td >Systemname: </td>";
    echo "<td>";
    echo "<input class=\"changeArticleForm-title\" type=\"text\" name=\"artSystemName\" maxlength=\"45\" value=\"{$artSystemName}\"  /input>";
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td >Systemdescription: </td>";
    echo "<td>";
    echo "<textarea  class=\"changeArticleForm-description\" type=\"text\" name=\"artSystemDescription\" >{$artSystemDescription}</textarea>";
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td >Price: </td>";
    echo "<td>";
    echo "<input  class=\"changeArticleForm-price\" type=\"number\" name=\"artPrice\" value=\"{$artPrice}\"  /input>";
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td >Imagepath: </td>";
    echo "<td>";
    echo "<input class=\"changeArticleForm-imagePath\" type=\"text\" name=\"artImagePath\"  maxlength=\"150\" value=\"{$artImagePath}\"  /input>";
    echo "</td>";
    echo "</tr>";
    echo "<tr>";
    echo "<td >Article Category: </td>";
    echo "<td>";
    echo "<select name=\"category[]\" size=\"4\" multiple=\"multiple\" tabindex=\"1\">";
    while ($cat = $sqlcategoryRes->fetch_object()) {
        echo "<option value=\"{$cat->Category_ID}\" ";
        foreach ($selectedCats as $selected) {
            if ($selected == $cat->Category_ID) {
                echo "selected=\"selected\" ";
                break;
            }
        }
        echo ">{$cat->CategoryName}</option>";
    }
    echo "</select>";
    echo "</td>";
    echo "</tr>";
    printLanguagePart($sqllanguageRes, $artID);
    echo "</table>";
    echo "<input type=\"hidden\" name=\"action\" value=\"{$action}\" /input>";
    echo "<input class=\"basket-update-button\"  type=\"submit\" value=\"Save\"/>";
    echo "</form>";
}
示例#15
0
 public function actionDelete()
 {
     if (!self::isAuthAdmin()) {
         return null;
     }
     switch ($this->request->view) {
         case "brand":
             try {
                 $obj_db = new BrandDB();
                 $obj_db->load($this->request->id);
                 $tmp = $obj_db->img;
                 $link = URL::get($this->request->view, "", array("id" => $this->request->id), true, "", false);
                 $sef_db = new SefDB();
                 $sef_db->loadOnLink($link);
                 if ($tmp) {
                     File::delete(Config::DIR_IMG_BRAND . $tmp);
                 }
                 if ($obj_db->delete() && $sef_db->delete()) {
                     $this->fp->setSessionMessage($this->request->view, "SUCCESS_POSITION_DELETE");
                 } else {
                     $this->fp->setSessionMessage($this->request->view, "NOTFOUND_POSITION");
                 }
                 $this->redirect(URL::get($this->request->view, "admin"));
             } catch (Exception $e) {
                 $this->setSessionMessage($this->request->view, $this->getError($e));
             }
             break;
         case "product":
             try {
                 $obj_db = new ProductDB();
                 $obj_db->load($this->request->id);
                 $tmp = $obj_db->img;
                 $link = URL::get($this->request->view, "", array("id" => $this->request->id), true, "", false);
                 $sef_db = new SefDB();
                 $sef_db->loadOnLink($link);
                 if ($tmp) {
                     File::delete(Config::DIR_IMG_PRODUCT . $tmp);
                 }
                 if ($obj_db->delete() && $sef_db->delete()) {
                     $this->fp->setSessionMessage($this->request->view, "SUCCESS_POSITION_DELETE");
                 } else {
                     $this->fp->setSessionMessage($this->request->view, "NOTFOUND_POSITION");
                 }
                 $this->redirect(URL::get($this->request->view, "admin"));
             } catch (Exception $e) {
                 $this->setSessionMessage($this->request->view, $this->getError($e));
             }
             break;
         case "category":
             try {
                 $obj_db = new CategoryDB();
                 $obj_db->load($this->request->id);
                 $link = URL::get($this->request->view, "", array("id" => $this->request->id), true, "", false);
                 $sef_db = new SefDB();
                 $sef_db->loadOnLink($link);
                 if ($obj_db->delete() && $sef_db->delete()) {
                     $this->fp->setSessionMessage($this->request->view, "SUCCESS_POSITION_DELETE");
                 } else {
                     $this->fp->setSessionMessage($this->request->view, "NOTFOUND_POSITION");
                 }
                 $this->redirect(URL::get($this->request->view, "admin"));
             } catch (Exception $e) {
                 $this->setSessionMessage($this->request->view, $this->getError($e));
             }
             break;
         case "section":
             try {
                 $obj_db = new SectionDB();
                 $obj_db->load($this->request->id);
                 $link = URL::get($this->request->view, "", array("id" => $this->request->id), true, "", false);
                 $sef_db = new SefDB();
                 $sef_db->loadOnLink($link);
                 if ($obj_db->delete() && $sef_db->delete()) {
                     $this->fp->setSessionMessage($this->request->view, "SUCCESS_POSITION_DELETE");
                 } else {
                     $this->fp->setSessionMessage($this->request->view, "NOTFOUND_POSITION");
                 }
                 $this->redirect(URL::get($this->request->view, "admin"));
             } catch (Exception $e) {
                 $this->setSessionMessage($this->request->view, $this->getError($e));
             }
             break;
         case "slider":
             try {
                 $obj_db = new SliderDB();
                 $obj_db->load($this->request->id);
                 if ($obj_db->delete()) {
                     $this->fp->setSessionMessage($this->request->view, "SUCCESS_POSITION_DELETE");
                 } else {
                     $this->fp->setSessionMessage($this->request->view, "NOTFOUND_POSITION");
                 }
                 $this->redirect(URL::get($this->request->view, "admin"));
             } catch (Exception $e) {
                 $this->setSessionMessage($this->request->view, $this->getError($e));
             }
             break;
         case "dop_foto":
             try {
                 $obj_db = new ImgDB();
                 $obj_db->load($this->request->id);
                 File::delete($obj_db->url);
                 if ($obj_db->delete()) {
                     $this->fp->setSessionMessage("product", "SUCCESS_POSITION_DELETE");
                 } else {
                     $this->fp->setSessionMessage($this->request->view, "NOTFOUND_POSITION");
                 }
                 $this->redirect(URL::referer());
             } catch (Exception $e) {
                 $this->setSessionMessage($this->request->view, $this->getError($e));
             }
             break;
     }
 }