1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156:
<?php
function sort_table($obj, $row) {
global $SysValue;
$sort = $obj->PHPShopCategory->unserializeParam('sort');
$vendor_array = unserialize($row['vendor_array']);
$dis = $sortCat = $sortValue = null;
$arrayVendorValue = array();
$odnotip = $row['odnotip'];
if (is_array($sort))
foreach ($sort as $v) {
$sortCat.=intval($v) . ',';
}
if (!empty($sortCat)) {
$PHPShopOrm = new PHPShopOrm();
$PHPShopOrm->debug = $obj->debug;
$result = $PHPShopOrm->query("select * from " . $SysValue['base']['sort_categories'] . " where id IN ( $sortCat 0) order by num");
while (@$row = mysqli_fetch_assoc($result)) {
$arrayVendor[$row['id']] = $row;
}
if (is_array($vendor_array))
foreach ($vendor_array as $v) {
foreach ($v as $value)
if (is_numeric($value))
$sortValue.=intval($value) . ',';
}
if (!empty($sortValue)) {
$PHPShopOrm = new PHPShopOrm();
$PHPShopOrm->debug = $obj->debug;
$result = $PHPShopOrm->query("select * from " . $SysValue['base']['sort'] . " where id IN ( $sortValue 0) order by num");
while (@$row = mysqli_fetch_array($result)) {
if ($row['name'][0] == '#')
$arrayVendorValue[$row['category']]['name'][$row['id']] = ' <div class="sort-color" style="width:25px;height:25px;background:' . $row['name'] . ';float:left;padding:3px;margin:3px;"></div> ';
else
$arrayVendorValue[$row['category']]['name'][$row['id']] = $row['name'];
$arrayVendorValue[$row['category']]['id'][] = $row['id'];
if(!empty($row['page'])) {
$arrayVendorValue[$row['category']]['page'][$row['id']] = $row['page'];
}
if ($arrayVendor[$row['category']]['brand']) {
$obj->set('brandIcon', $row['icon']);
$obj->set('brandName', $row['name']);
if ($row['page']) {
$PHPShopOrm->clean();
$res = $PHPShopOrm->query("select content from " . $SysValue['base']['page'] . " where link = '$row[page]' LIMIT 1");
$page = mysqli_fetch_array($res);
$desc = stripslashes($page['content']);
}
$obj->set('brandPageLink', '/selection/?v[' . $row['category'] . ']=' . $row['id']);
if (@$desc) {
$obj->set('brandDescr', $desc);
} else {
$obj->set('brandDescr', '');
}
$obj->set('brandUidDescription', ParseTemplateReturn('product/brand_uid_description.tpl'), true);
}
}
if (is_array($arrayVendor))
foreach ($arrayVendor as $idCategory => $value) {
if (!empty($value['product']) and strstr($odnotip, ',')) {
$where['id'] = ' IN (' . $odnotip . ')';
$where['enabled'] = "='1'";
$PHPShopOrm = new PHPShopOrm($GLOBALS['SysValue']['base']['products']);
$PHPShopOrm->debug = false;
$PHPShopOrm->mysql_error = false;
$data = $PHPShopOrm->select(array('*'), $where, false, array('limit' => 100));
if (is_array($data)) {
$sortValueName = null;
foreach ($data as $row) {
if (!isset($row['prod_seo_name']))
$p_link = '/shop/UID_' . $row['id'] . '.html';
else
$p_link = '/id/' . str_replace("_", "-", PHPShopString::toLatin($row['name'])) . '-' . $row['id'] . '.html';
$sortValueName.= PHPShopText::a($p_link, $row['name'],false, false, false, false, 'sort-table-product-link',$row['pic_small']) . '<br>';
}
}
$sortName = PHPShopText::b($value['name']);
$dis.=PHPShopText::tr($sortName . ': ', substr($sortValueName, 0, strlen($sortValueName) - 2));
}
elseif (!empty($arrayVendorValue[$idCategory]['name'])) {
if (!empty($value['name'])) {
if (!empty($value['page']))
$sortName = PHPShopText::a('/page/' . $value['page'] . '.html', $value['name']);
else
$sortName = PHPShopText::b($value['name']);
if (!empty($value['brand'])) {
$arr = array();
foreach ($arrayVendorValue[$idCategory]['id'] as $valueId) {
$arr[] = PHPShopText::a('/selection/?v[' . $idCategory . ']=' . $valueId, $arrayVendorValue[$idCategory]['name'][$valueId]);
}
$sortValueName = implode(', ', $arr);
}
else if (isset($arrayVendorValue[$idCategory]['page'])) {
$arr = array();
foreach ($arrayVendorValue[$idCategory]['id'] as $valueId) {
$arr[] = PHPShopText::a('/page/' . $arrayVendorValue[$idCategory]['page'][$valueId] . '.html', $arrayVendorValue[$idCategory]['name'][$valueId]);
}
$sortValueName = implode(', ', $arr);
} else {
$arr = array();
foreach ($arrayVendorValue[$idCategory]['id'] as $valueId) {
$arr[] = $arrayVendorValue[$idCategory]['name'][$valueId];
}
$sortValueName = implode(', ', $arr);
}
$dis.=PHPShopText::tr($sortName . ': ', $sortValueName);
}
}
}
$disp = PHPShopText::table($dis, $cellpadding = 3, $cellspacing = 3, $align = '', $width = '100%', $bgcolor = false, $border = 0, $id = false, 'vendorenabled');
$obj->set('vendorDisp', $disp);
}
}
}
?>