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); } }
public function __construct($id = false) { parent::__construct(); $this->name = "form_section"; $this->enctype = "multipart/form-data"; $this->action = URL::current(); 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->textarea("full_text", "Длинное описание:", FormProcessor::getSessionData("full_text")); $this->text("alias", "ЧПУ ссылка", FormProcessor::getSessionData("alias")); $this->submit("insert_section", "Сохранить"); } else { $this->hidden("id", $id); $obj = new SectionDB(); $obj->load($id); $this->text("title", "Название:", $obj->title); $this->textarea("meta_desc", "Описание:", $obj->meta_desc); $this->textarea("meta_key", "Ключевые слова:", $obj->meta_key); $this->textarea("full_text", "Длинное описание:", $obj->full_text); $link = URL::get("section", "", array("id" => $id), true, "", false); $alias = SefDB::getAliasOnLink($link); $this->text("alias", "ЧПУ ссылка", $alias); $this->submit("update_section", "Сохранить"); } }
protected function postInit() { if (!is_null($this->img)) { $this->img = Config::DIR_IMG_ARTICLES . $this->img; } $this->link = URL::get("category", "", array("id" => $this->id)); $section = new SectionDB(); $section->load($this->section_id); $this->section = $section; return true; }
protected function postInit() { if (!is_null($this->img)) { $this->img = Config::DIR_IMG_ARTICLES . $this->img; } //указание полного пути к картинке по константе $this->link = URL::get("category", "", array("id" => $this->id)); //ссылка $section = new SectionDB(); //раздел которому пренадлежит категория $section->load($this->section_id); $this->section = $section; return true; }
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); }
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; } }
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; } }