Exemple #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);
 }
Exemple #2
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);
     }
 }