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'].'
| '; foreach ($pattern as $key => $val) { $content .= ' | '.$val.' | '; } $content .= 'Цена | |
|---|---|---|---|
| '.Shop::shop_product_title_bin($massiv).' | '; foreach ($pattern as $key => $val) { $content .= ''.$massiv[$key].' | '; } $content .= ''.Shop::shop_product_price_format($massiv).' | '.Shop::shop_product_bin($massiv).' |
| '; foreach ($pattern as $key => $val) { $content .= ' | '; } $content .= ' |
В данной категории нет товаров
'; } $content .= (!empty($category_desc[1])) ? $category_desc[1] : '' ; $content .= $text; $content .= Shop::shop_category_view(); /*} else { $content .= 'no cat'; }*/ break; case 'view': if ($_GET['mod'] == 'shop') { $ar = $db->GetAll('SELECT *, max(c.category_id) as category_id FROM a_shop_products as p, a_shop_products_categories as c WHERE p.product_id=c.product_id && p.product_id="'.$_GET['id'].'" group by p.product_id'); if (!empty($ar)) { $content .= ''; if (!empty($ar)) { array_filter($ar); foreach ($ar as $key => $massiv) { $cat = Helpers::get_cat_list(); header('location: /'.$cat[$massiv['product_category_id']]['category_alias'].'/view/'.$massiv['product_alias'].'/'); } } } } if ($_GET['id']) { $ar = $db->GetAll('SELECT *, max(c.category_id) as category_id FROM a_shop_products as p, a_shop_products_categories as c WHERE p.product_id=c.product_id && p.product_alias="'.$_GET['id'].'" group by p.product_id'); 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)) { $pattern = Shop::table_array($massiv2['category_pattern']); $title = ''.$massiv['product_title'].''; $active_id = $massiv['category_id']; //$breadcrumbs[] = 'Продукция'; if ($massiv2['parent_id'] <> 0) { if ($rez[$massiv2['parent_id']]['parent_id'] <> 0) { $lastid = $rez[$massiv2['parent_id']]['parent_id']; $breadcrumbs[] = array('title' => $rez[$lastid]['title'], 'href' => '/'.$rez[$lastid]['category_alias'].'/'); $breadcrumbs[] = array('title' => $rez[$massiv2['parent_id']]['title'], 'href' => '/'.$rez[$massiv2['parent_id']]['category_alias'].'/'); } else { $breadcrumbs[] = array('title' => $rez[$massiv2['parent_id']]['title'], 'href' => '/'.$rez[$massiv2['parent_id']]['category_alias'].'/'); } } $breadcrumbs[] = array('title' => $rez[$massiv2['category_id']]['title'], 'href' => '/'.$rez[$massiv2['category_id']]['category_alias'].'/'); $breadcrumbs[] = array('title' => $massiv['product_title'], 'href' => ''); } //$gallery = Shop::shop_products_gallery($massiv, $_GET['option'], 'shop_products', 'product_id'); $gallery = Shop::shop_products_gallery($massiv, $_GET['option'], 'shop_category', 'product_category_id'); $content .= '';
if (!preg_match('~]* />~', $massiv['product_desc_full'])) {
//unset($gallery[0]);
foreach ($gallery as $gal) {
$content .= $gal;
}
}
$content .= '
| '.$val.' | '.$massiv[$key].' |
| '.$val.' | |
| '.Shop::shop_product_price($massiv).' | '.Shop::shop_product_bin($massiv).' |
| '; foreach ($pattern as $key => $val) { $content .= ' | '.$val.' | '; } $content .= '||
|---|---|---|---|
| '.Shop::shop_product_title_bin($massiv).' | '; foreach ($pattern as $key => $val) { $content .= ''.$massiv[$key].' | '; } $content .= ''.Shop::shop_product_price_format($massiv).' | '.Shop::shop_product_bin($massiv).' |
В данной категории нет товаров
'; foreach ($links as $key => $val) { if (!empty($val)) { $content .= ''.$val.'
'; } } } } else { $content .= 'no'; } break; } $script_start = microtime(TRUE); ?>