class Menu extends Db { function get_one() { $this->Query('SELECT * FROM menu WHERE menu.parent="0" ORDER BY menu.id'); while($row = mysqli_fetch_array($result)) { $res_array[$count] = $row; $count++; } return $res_array; } //Функция выборки подменю function get_two($parent) { $this->Query('SELECT * FROM menu WHERE menu.parent="$parent" ORDER BY menu.id'); while($row = mysqli_fetch_array($result)) { $res_array[$count] = $row; $count++; } return $res_array; } } $menu = new Menu(); class Paginator extends Db { public static $limit = 7; /* public static $navigation = array(); public static function split($sql, $perPage, $page, $link) { $page = !isset($page) || $page <= 0 ? 1 : intval($page); $limit = $page - 1 == 0 ? 0 : ($page - 1) * $perPage; $r = mysqli()->query("SELECT SQL_CALC_FOUND_ROWS * FROM ($sql) TBL LIMIT $limit, $perPage"); //if (!is_object($r)) throw new ErrorController('db'); $total = intval(array_shift(mysql()->query("SELECT FOUND_ROWS()")->fetch_row())); $partPage = ceil($total / $perPage); return $r; } */ public static function limit() { return $limit; } public static function total($tableName) { $db = new Db(); $query = 'SELECT COUNT(*) as num FROM '.$tableName; $total_pages = $db->fetch($db->Query($query)); $total_pages = $total_pages['num']; return $total_pages; } public static function start() { $page = ($_GET['page']); if($page){ return ($page - 1) * self::$limit; }else{ return 0; } } public static function page($mod, $tableName) { $page = ($_GET['page']); $stages = 3; // Initial page num setup if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil(self::total($tableName)/self::$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= '
'.$massiv['title'].'
В данной категории нет товаров
'; } } else { $content .= 'no cat'; } break; case 'view': if ($_GET['alias']) { $result = $db->Query('SELECT * FROM a_shop_products as p, a_shop_products_categories as c WHERE p.product_id=c.product_id && p.product_id=?s group by p.product_id', $_GET['alias']); while ($massiv = $db->fetch($result)) { $ar[] = $massiv; } if (!empty($ar)) { $content .= ''; if (!empty($ar)) { array_filter($ar); foreach ($ar as $key => $massiv) { $result = $db->Query('SELECT a.*, f.category_parent_id as parent_id, f.category_child_id FROM a_shop_category AS a, a_shop_category_xref AS f WHERE a.category_publish="Y" AND a.category_id = f.category_child_id AND a.category_id="'.$massiv['category_id'].'" ORDER BY parent_id, a.category_name'); if ($massiv2 = $db->fetch($result)) { $title = (!empty($massiv['meta_title'])) ? $massiv['meta_title'] : $massiv['product_title'] ; $active_id = $massiv['category_id']; $breadcrumbs[] = ''.$res[$massiv2['category_id']]['title'].''; $breadcrumbs[] = $massiv['product_title']; } $gallery = Shop::shop_products_gallery($massiv, $_GET['option'], 'shop_products', 'product_id'); $content .= '';
if (!preg_match('~]* />~', $massiv['product_desc_full'])) {
//unset($gallery[0]);
foreach ($gallery as $gal) {
$content .= $gal;
}
}
$content .= '
В данной категории нет товаров
'; } } else { $content .= 'no'; } break; }