Пример #1
1
 public function __construct($id = false)
 {
     parent::__construct();
     $this->add("products");
     $this->name = "form_slider";
     $this->enctype = "multipart/form-data";
     $this->action = URL::current();
     $this->products = ProductDB::getAdminShow();
     if (!$id) {
         $this->text("title", "Название:");
         $this->textarea("description", "Описание:");
         $this->submit("insert_slider", "Сохранить");
     } else {
         $this->add("img");
         $this->add("product_id");
         $this->hidden("id", $id);
         $obj = new SliderDB();
         $obj->load($id);
         $this->text("title", "Название:", $obj->title);
         $img = ProductDB::getCellOnID($obj->product_id, "img");
         $view = new View(Config::DIR_TMPL);
         $this->img = $view->render("img", array("src" => Config::DIR_IMG_PRODUCT . $img), true);
         $this->textarea("description", "Описание:", $obj->description);
         $this->submit("update_slider", "Сохранить");
         $this->product_id = $obj->product_id;
     }
 }
Пример #2
0
 public function actionIndex()
 {
     $this->title = "Интернет магазин детских товаров Мама-Па";
     $this->meta_desc = "В интернет магазине www.mama-pa.ru представлены товары самых известных и качественных брендов, доказавших на деле удобство, красоту и практичность своих товаров";
     $this->meta_key = "товары для детей, детские товары, магазин детских товаров, интернет магазин детских товаров";
     $head = $this->getHead(array("/css/main.css"));
     $head->js = array("/js/main.js", "/js/slider.js");
     $sections = new Section();
     $sections->items = SectionDB::getAllShow();
     $slider = new Slider();
     $slider->items = SliderDB::getItems();
     $promo = new Promo();
     $promo->brands = BrandDB::getAllShow();
     $this->render($head, $this->renderData(array("slider" => $slider, "promo" => $promo, "sections" => $sections), "index"));
 }
Пример #3
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;
     }
 }