transform($this->getAll("date", true, $count_on_page)); } private function checkData($sort, $up){ return ($up === "1") || ($up === "0") && ($sort === "title") || ($sort === "price"); } public function getAllSort($count_on_page, $sort = false, $up = false){ // if(($sort === false) && ($sort === "title") && ($sort === "price")) return $this->getSortDate($count_on_page); if(!$this->checkData($sort, $up)) return $this->getSortDate($count_on_page); $desc = ""; if(!$up) $desc = " DESC"; $limit = $this->getL($count_on_page, 0); $query = "SELECT * FROM (SELECT * FROM `".$this->table_name."` ORDER BY `date` DESC $limit) as t ORDER BY `$sort` $desc"; return $this->transform($this->db->select($query)); } public function transformElement($element){ $element["link"] = $this->url->product($element["id"]); $element["bue"] = $this->url->addCart($element["id"]); $element["img"] = $this->config->dir_img.$element["img"]; $element["description"] = str_replace("\n", "
", $element["description"]); return $element; } public function get($id, $section_table){ $query = "SELECT `".$this->table_name."`.`id`, `".$this->table_name."`.`title`, `".$this->table_name."`.`img`, `".$this->table_name."`.`price`, `".$this->table_name."`.`year`, `".$this->table_name."`.`director`, `".$this->table_name."`.`section_id`, `".$this->table_name."`.`cast`, `".$this->table_name."`.`description`, `".$section_table."`.`title` AS `section` FROM `".$this->table_name."` INNER JOIN `$section_table` ON `".$this->table_name."`.`section_id` = `$section_table`.`id` WHERE `".$this->table_name."`.`id` = ".$this->config->sym_query; return $this->transform($this->db->selectRow($query, array($id))); } public function getAllOnSectionID($id, $sort, $up){ echo $sort." ".$up; if(!$this->checkData($sort, $up)) return $this->transform($this->getAllOnField("section_id", $id)); return $this->transform($this->getAllOnField("section_id", $id, $sort, $up)); } public function getRecomend ($count, $section_id, $id){ $limit = $this->getL($count, 0); $query = "SELECT `title`, `img`, `id` FROM `".$this->table_name."` WHERE `section_id` = '$section_id' AND `id` != '$id' ORDER BY RAND() $limit"; $data = $this->db->select($query); for($i = 0; $i < count($data); $i++){ $data[$i]["link"] = $this->url->product($data[$i]["id"]); $data[$i]["img"] = $this->config->dir_img.$data[$i]["img"]; $data[$i]["bue"] = $this->url->addCart($data[$i]["id"]); } return $data; } public function search($q){ return $this->transform(parent::search($q, array("title", "description", "cast", "year"))); } } ?>