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: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365:
<?php
function getfullname($id) {
global $PHPShopShopCatalogElement;
$parent = $PHPShopShopCatalogElement->CategoryArray[$id]['parent_to'];
if (!empty($parent))
$name = $PHPShopShopCatalogElement->CategoryArray[$parent]['name'] . ' / ' . $PHPShopShopCatalogElement->CategoryArray[$id]['name'];
else
$name = $PHPShopShopCatalogElement->CategoryArray[$id]['name'];
return $name;
}
class PHPShopCompare extends PHPShopCore {
function __construct() {
parent::__construct();
$this->navigation(false, __(''));
}
function index() {
global $SysValue, $PHPShopSystem, $PHPShopValutaArray, $link_db;
$limit = 4;
$LoadItems['Valuta'] = $PHPShopValutaArray->getArray();
$LoadItems['System'] = $PHPShopSystem->getArray();
if (!empty($_SESSION['compare']))
$copycompare = $_SESSION['compare'];
else
$copycompare = array();
if (!($SysValue['nav']['id'] == "ALL")) {
$SysValue['nav']['id'] = intval($SysValue['nav']['id']);
}
$COMCID = 0;
if ($SysValue['nav']['nav'] == "COMCID") {
if (isset($SysValue['nav']['id']) && ($SysValue['nav']['id'])) {
$COMCID = $SysValue['nav']['id'];
}
}
if (is_array($copycompare))
sort($copycompare);
$oldcatid = '';
if (is_array($copycompare))
foreach ($copycompare as $id => $val) {
if ($oldcatid != $val['category']) {
$catid = $val['category'];
$oldcatid = $catid;
$cats[$catid] = getfullname($catid);
}
$goods[$oldcatid][$id]['name'] = $val['name'];
$goods[$oldcatid][$id]['id'] = $val['id'];
$goods[$oldcatid][$id]['url'] = $val['url'];
$compare[$id] = $goods[$oldcatid][$id];
}
$dis = "";
if (empty($cats))
$cats = 0;
if (is_array($cats))
foreach ($cats as $catid => $name) {
if ((count($goods[$catid]) > 1) && (count($goods[$catid]) <= $limit)) {
if ($catid != $COMCID) {
$as = '<b>' . __('') . '</b>: <a href="../compare/COMCID_' . $catid . '.html#list" title="' . __('') . ' ' . $name . '">';
$ae = '</a>';
} else {
$as = '<b>';
$ae = '</b>';
}
$dis.='
<tr><td colspan="2">' . $as . $name . $ae . '</td></tr>';
$green[] = $catid;
} elseif (count($goods[$catid]) > $limit) {
$dis.='
<tr><td><br><b>' . $name . '</b> <p class="text-danger">' . __('' . $limit . '') . '.</p></td>
<td width="50"></td></tr>';
} else {
$dis.='
<tr><td id=allspec colspan="2"><b>' . $name . '</b> </td>
</tr>';
}
foreach ($goods[$catid] as $id => $val) {
$dis.='<tr><td>' . $val['name'] . ' </td><td width="50" class="text-center"><a href="../compare/DID_' . $val['id'] . '';
}
}
if (count($cats) > 1) {
$name = '';
if ((count($compare) > 1) && (count($compare) <= $limit)) {
if ($COMCID != "ALL") {
$as = '<a href="../compare/COMCID_ALL.html#list" title="' . __('') . '"><span class="glyphicon glyphicon-ok"></span> ' . __('') . ' ';
$ae = '</a>';
} else {
$as = '<b>' . __('') . ': ';
$ae = '</b>';
}
$dis.='
<tr><td colspan="2" id=allspec>' . $as . $name . $ae . '</td>
<!--<td> </td>--></tr>';
$green[] = "ALL";
} elseif (count($compare) > $limit) {
$dis.='
<tr><td colspan="2"><b>' . $name . '</b> <p class="text-danger">' . __('' . $limit . '') . '.</p></td>
</tr>';
} else {
$dis.='
<tr><td colspan="2"><b>' . $name . '</b> <p class="text-danger">' . __('') . '</p></td>
</tr>';
}
}
$disp = '<table class="table table-bordered table-responsive">' . $dis . '</table>';
if (!$COMCID) {
if (@count($green) > 0) {
krsort($green);
foreach ($green as $c) {
$COMCID = $c;
break;
}
} else {
$disp.='<p class="text-danger">' . __('') . '.</p>';
}
}
if ($SysValue['nav']['nav'] == "DID") {
$id = $SysValue['nav']['id'];
if ($id == "ALL") {
$_SESSION['compare'] = null;
unset($_SESSION['compare']);
header("Location: ../compare/");
} else {
unset($_SESSION['compare'][$id]);
header("Location: ../compare/");
}
}
$catid = $COMCID;
if (!empty($_SESSION['compare']))
if (($COMCID && (count($goods[$catid]) > 1) && (count($goods[$catid]) <= $limit)) ||
((($COMCID == "ALL") && (count($_SESSION['compare']) > 1) && (count($_SESSION['compare']) <= $limit)))) {
if ($COMCID == "ALL") {
$comparing = __('');
} else {
$comparing = getfullname($COMCID);
}
$disp.='<a name="list"></a><P><h4>' . $comparing . '</h4></P>';
if ($COMCID != "ALL") {
$sql = 'select sort from ' . $SysValue['base']['table_name'] . ' where id=' . intval($COMCID);
$result = mysqli_query($link_db, $sql);
@$row = mysqli_fetch_array(@$result);
$sorts = unserialize($row['sort']);
} else {
foreach ($cats as $catid => $name) {
$sql = 'select sort from ' . $SysValue['base']['table_name'] . ' where id=' . intval($catid);
$result = mysqli_query($link_db, $sql);
@$row = mysqli_fetch_array(@$result);
$tempsorts = unserialize($row['sort']);
if (is_array($tempsorts))
foreach ($tempsorts as $curtempsort) {
$sorts[] = $curtempsort;
}
}
}
if (is_array($sorts))
$sorts = array_unique($sorts);
$sorts_name = array();
if (is_array($sorts))
foreach ($sorts as $sort) {
$sql = 'select name from ' . $SysValue['base']['sort_categories'] . ' where id=' . intval($sort);
$result = mysqli_query($link_db, $sql);
@$row = mysqli_fetch_array(@$result);
$sorts_name[$sort] = $row['name'];
}
if (is_array($sorts_name))
foreach ($sorts_name as $sort => $name) {
$sql = 'select id from ' . $SysValue['base']['sort_categories'] . ' where name LIKE \'' . $name . '\'';
$result = mysqli_query($link_db, $sql);
while ($row = mysqli_fetch_array(@$result)) {
$sorts_name2[$name][$row['id']] = 1;
}
}
if (empty($sorts_name2))
$sorts_name2 = 0;
$tdR[0][] = __('');
$tdR[0][] = __('');
$tdR[0][] = __('');
if (is_array($sorts_name2))
foreach ($sorts_name2 as $name => $id) {
$tdR[0][] = $name;
}
$tdR[0][] = __('');
$igood = 0;
if ($COMCID != "ALL") {
$goodstowork = $goods[$COMCID];
} else {
foreach ($cats as $catid => $name) {
foreach ($goods[$catid] as $curtempgood) {
$goodstowork[] = $curtempgood;
}
}
}
foreach ($goodstowork as $id => $val) {
$igood++;
$tdR[$igood][] = '<A href="' . $val['url'] . '.html" title="' . $val['name'] . '">' . $val['name'] . '</A>';
$sql = 'select id,price,pic_small,vendor_array,content,baseinputvaluta from ' . $SysValue['base']['products'] . ' where id=' . intval($val['id']);
$result = mysqli_query($link_db, $sql);
@$row = mysqli_fetch_array(@$result);
if (trim($row['pic_small'])) {
$tdR[$igood][] = '<img class="media-object" src="' . $row['pic_small'] . '">';
} else {
$tdR[$igood][] = '';
}
$id = $row['id'];
$admoption = unserialize($LoadItems['System']['admoption']);
if ($admoption['user_price_activate'] == 1 and !$_SESSION['UsersId']) {
$price = "-";
}
else
$price = PHPShopProductFunction::GetPriceValuta($row['id'], array($row['price'], $row['price2'], $row['price3'], $row['price4'], $row['price5']), $row['baseinputvaluta']);
$tdR[$igood][] = $price;
$chars = unserialize($row['vendor_array']);
if (is_array($chars))
foreach ($chars as $k => $char) {
$chars[$k] = array_unique($char);
}
if (is_array($sorts_name2))
foreach ($sorts_name2 as $name => $ids) {
$curchar = '';
foreach ($ids as $id => $true) {
@$ca = $chars[$id];
if (is_array($ca))
foreach ($ca as $charid) {
$sql2 = 'select name from ' . $SysValue['base']['sort'] . ' where id=' . intval($charid);
$result2 = mysqli_query($link_db, $sql2);
@$row2 = mysqli_fetch_array(@$result2);
$curchar.=' ' . $row2['name'] . '<br>';
}
}
$tdR[$igood][] = $curchar;
}
$tdR[$igood][] = stripslashes($row['content']);
}
$rows = count($tdR[0]);
$cols = count($goodstowork) + 1;
$disp.='<TABLE class="table table-striped table-responsive">';
for ($row = 0; $row < $rows; $row++) {
$disp.='<tr>';
for ($col = 0; $col < $cols; $col++) {
$value = trim($tdR[$col][$row]);
if (!$value) {
$value = ' ';
}
$disp.='<td>' . $value . '</td>';
}
$disp.='</tr>';
}
$disp.='</TABLE>';
}
if (count($cats) == 0) {
$disp = '<P><h5>' . __('') . '!</h5></P>';
}
$SysValue['other']['pageTitle'] = $SysValue['other']['pageTitl'] = $SysValue['other']['catalogCat'] = __("");
$SysValue['other']['pageContent'] = '<div class="compare_list">' . $disp . '</div>';
$SysValue['other']['catalogCategory'] = __("");
$this->description = $SysValue['other']['pageTitle'];
$this->title = $SysValue['other']['pageTitle'] . ' - ' . $this->PHPShopSystem->getValue("name");
$this->set('pageContent', $disp);
$this->set('pageTitle', $SysValue['other']['pageTitle']);
if (PHPShopParser::checkFile("users/compare/compare_page_list.tpl"))
$this->parseTemplate('users/compare/compare_page_list.tpl');
else
$this->parseTemplate($this->getValue('templates.page_page_list'));
}
}
?>