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", "Сохранить"); } }
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; } }
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); } }
public static function getRequest($uri) { if (strpos($uri, Config::ADDRESS) !== false) { $uri = substr($uri, strlen(Config::ADDRESS)); } if ($uri === "/") { return $uri; } $uri = substr($uri, 1); $uri = str_replace(Config::SEF_SUFFIX, "", $uri); if (preg_match("/^page-(\\d+)\$/i", $uri, $matches)) { return "/?page=" . $matches[1]; } $result = SefDB::getLinkOnAlias($uri); if (!$result) { $uri = substr($uri, 0, strpos($uri, "?")); $result = SefDB::getLinkOnAlias($uri); } if ($result) { return $result; } return false; }
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; } }