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: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: 604: 605: 606: 607: 608: 609: 610: 611: 612: 613: 614: 615: 616: 617: 618: 619: 620: 621: 622: 623: 624: 625: 626: 627: 628: 629: 630: 631: 632: 633: 634: 635: 636: 637: 638: 639: 640: 641: 642: 643: 644: 645: 646: 647: 648: 649: 650: 651: 652: 653: 654: 655: 656: 657: 658: 659: 660: 661: 662: 663: 664: 665: 666: 667: 668: 669: 670: 671: 672: 673: 674: 675: 676: 677: 678: 679: 680: 681: 682: 683: 684: 685: 686: 687: 688: 689: 690: 691: 692: 693: 694: 695: 696: 697: 698: 699: 700: 701: 702: 703: 704: 705: 706: 707: 708: 709: 710: 711: 712: 713: 714: 715: 716: 717: 718: 719: 720: 721: 722: 723: 724: 725: 726: 727: 728: 729: 730: 731: 732: 733: 734: 735: 736: 737: 738: 739: 740: 741: 742: 743: 744: 745: 746: 747: 748: 749: 750: 751: 752: 753: 754: 755: 756: 757: 758: 759: 760: 761: 762: 763: 764: 765: 766: 767: 768: 769: 770: 771: 772: 773: 774: 775: 776: 777: 778: 779: 780: 781: 782: 783: 784: 785: 786: 787: 788: 789: 790: 791: 792: 793: 794: 795: 796: 797: 798: 799: 800: 801: 802: 803: 804: 805: 806: 807: 808: 809: 810: 811: 812: 813: 814: 815: 816: 817: 818: 819: 820: 821: 822: 823: 824: 825: 826: 827: 828: 829: 830: 831: 832: 833: 834: 835: 836: 837: 838: 839: 840: 841: 842: 843: 844: 845: 846: 847: 848: 849: 850: 851: 852: 853: 854: 855: 856: 857: 858: 859: 860: 861: 862: 863: 864: 865: 866: 867: 868: 869: 870: 871: 872: 873: 874: 875: 876: 877: 878: 879: 880: 881: 882: 883: 884: 885: 886: 887: 888: 889: 890: 891: 892: 893: 894: 895: 896: 897: 898: 899: 900: 901: 902: 903: 904: 905: 906: 907: 908: 909: 910: 911: 912: 913: 914: 915: 916: 917: 918: 919: 920: 921: 922: 923: 924: 925: 926: 927: 928: 929: 930: 931: 932: 933: 934: 935: 936: 937: 938: 939: 940: 941: 942: 943: 944: 945: 946: 947: 948: 949: 950: 951: 952: 953: 954: 955: 956: 957: 958: 959: 960: 961: 962: 963: 964: 965: 966: 967: 968: 969: 970: 971: 972: 973: 974: 975: 976: 977: 978: 979: 980: 981: 982: 983: 984: 985: 986: 987: 988: 989: 990: 991: 992: 993: 994: 995: 996: 997: 998: 999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218:
<?php
class PHPShopShop extends PHPShopShopCore {
var $debug = false;
var $cache = true;
var $cache_format = array('content', 'yml_bid_array');
var $max_item = 200;
var $sort_template, $cat_template = null;
var $ed_izm = null;
var $multi_currency_search = false;
var $parent_title = '';
var $parent_color = '';
var $category;
var $category_array = array();
function __construct() {
global $PHPShopAnalitica;
$this->path = '/' . $GLOBALS['SysValue']['nav']['path'];
$this->action = array("nav" => array("CID", "UID"));
parent::__construct();
$this->PHPShopOrm->cache_format = $this->cache_format;
$this->page = $this->PHPShopNav->getPage();
if (strlen($this->page) == 0)
$this->page = 1;
$this->multi_currency_search = $this->PHPShopSystem->getSerilizeParam('admoption.multi_currency_search');
$this->PHPShopAnalitica = $PHPShopAnalitica;
}
function setCell($d1, $d2 = null, $d3 = null, $d4 = null, $d5 = null, $d6 = null, $d7 = null) {
if ($this->memory_get(__CLASS__ . '.' . __FUNCTION__, true)) {
$Arg = func_get_args();
$hook = $this->setHook(__CLASS__, __FUNCTION__, $Arg);
if ($hook) {
return $hook;
}
else
$this->memory_set(__CLASS__ . '.' . __FUNCTION__, 0);
}
return parent::setCell($d1, $d2, $d3, $d4, $d5, $d6, $d7);
}
function setActiveMenu() {
$this->set('thisCat', $this->PHPShopCategory->getParam('parent_to'));
$cat = $this->get('thisCat');
if (empty($cat))
$this->set('thisCat', intval($this->PHPShopNav->getId()));
$PHPShopOrm = new PHPShopOrm($GLOBALS['SysValue']['base']['categories']);
$PHPShopOrm->cache = $this->cache;
$PHPShopOrm->debug = $this->debug;
$PHPShopOrm->cache_format = array('content', 'description');
$data = $PHPShopOrm->select(array('*'), array('id' => '=' . intval($this->get('thisCat'))), false, array('limit' => 1));
$ParentTest = $data['parent_to'];
$this->set('thisCatName', $data['name']);
if (!empty($ParentTest)) {
$this->set('thisCat', $ParentTest);
$this->set('thisPodCat', $this->PHPShopCategory->getParam('parent_to'));
}
$this->setHook(__CLASS__, __FUNCTION__, $data);
}
function file($row) {
$files = unserialize($row['files']);
if ($this->PHPShopSystem->getSerilizeParam('admoption.digital_product_enabled') != 1) {
if (is_array($files)) {
$this->set('productFiles', '');
foreach ($files as $cfile) {
$this->set('productFiles', '<p><span class="glyphicon glyphicon-paperclip"></span> ', true);
$this->set('productFiles', PHPShopText::a($cfile['path'], urldecode($cfile['name']), urldecode($cfile['name']), false, false, '_blank'), true);
$this->set('productFiles', '</p>', true);
}
} else {
$this->set('productFiles', __(""));
$this->set('productFilesStart', PHPShopText::comment());
$this->set('productFilesEnd', PHPShopText::comment('>'));
}
}
else
$this->set('productFiles', __(""));
$this->setHook(__CLASS__, __FUNCTION__, $row);
}
function cloud($row) {
global $PHPShopCloudElement;
$disp = $PHPShopCloudElement->index($row);
$this->set('cloud', $disp);
$this->setHook(__CLASS__, __FUNCTION__, $row);
}
function article($row) {
if ($this->setHook(__CLASS__, __FUNCTION__, $row, 'START'))
return true;
$dis = null;
if (strstr($row['page'], ','))
$pages = explode(",", $row['page']);
else
$pages = array($row['page']);
if (!empty($pages) and is_array($pages)) {
foreach ($pages as $val) {
if ($val) {
$PHPShopOrm = new PHPShopOrm($GLOBALS['SysValue']['base']['page']);
$data = $PHPShopOrm->select(array('name'), array('link' => "='" . $val . "'", 'enabled' => '="1"'));
if (is_array($data)) {
$this->set('pageLink', $val);
$this->set('pageName', $data['name']);
$this->setHook(__CLASS__, __FUNCTION__, $data, 'MIDDLE');
$dis .= ParseTemplateReturn($this->getValue('templates.product_pagetema_forma'));
}
}
}
if (!empty($dis)) {
$this->set('temaContent', $dis);
$this->set('temaTitle', __(''));
$this->set('pagetemaDisp', ParseTemplateReturn($this->getValue('templates.product_pagetema_list')));
}
}
if (!$this->get('pagetemaDisp')) {
$this->set('pagetemaDispStart', PHPShopText::comment());
$this->set('pagetemaDispEnd', PHPShopText::comment('>'));
}
$this->setHook(__CLASS__, __FUNCTION__, $data, 'END');
}
function rating($row) {
if ($this->setHook(__CLASS__, __FUNCTION__, $row))
return true;
$this->doLoadFunction(__CLASS__, __FUNCTION__, $row);
}
function comment_rate($row, $type = "") {
if ($this->setHook(__CLASS__, __FUNCTION__, array("row" => $row, "type" => "$type")))
return true;
$this->doLoadFunction(__CLASS__, __FUNCTION__, array("row" => $row, "type" => "$type"));
}
function image_gallery($row) {
if ($this->setHook(__CLASS__, __FUNCTION__, $row))
return true;
$this->doLoadFunction(__CLASS__, __FUNCTION__, $row);
}
function option_select($row) {
if ($this->setHook(__CLASS__, __FUNCTION__, $row))
return true;
$this->doLoadFunction(__CLASS__, __FUNCTION__, $row);
}
function UID() {
$this->ajaxTemplate = 'product/main_product_forma_full_ajax.tpl';
if ($this->setHook(__CLASS__, __FUNCTION__, null, 'START'))
return true;
if (!PHPShopSecurity::true_num($this->PHPShopNav->getId()))
return $this->setError404();
$row = parent::getFullInfoItem(array('*'), array('id' => "=" . $this->PHPShopNav->getId(), 'parent_enabled' => "='0'"), __CLASS__, __FUNCTION__);
if (empty($row['enabled'])) {
if ($this->PHPShopSystem->getSerilizeParam('admoption.safe_links') == 1)
$row['sklad'] = 1;
else
unset($row);
}
if (empty($row['id']))
return $this->setError404();
$this->category = $row['category'];
$this->PHPShopCategory = new PHPShopCategory($this->category);
$this->category_name = $this->PHPShopCategory->getName();
if ($this->errorMultibase($this->category, $row['dop_cat']))
return $this->setError404();
if (empty($row['ed_izm']))
$ed_izm = $this->ed_izm;
else
$ed_izm = $row['ed_izm'];
$this->file($row);
$this->image_gallery($row);
$this->sort_table($row);
$this->option_select($row);
$this->rating($row);
if(empty($row['rate'])){
$rate=5;
$rate_count=1;
}
else {
$rate=$row['rate'];
$rate_count=$row['rate_count'];
}
$this->set('productRatingValue', $rate);
$this->set('productRatingCount', $rate_count);
$this->comment_rate($row);
$this->set('productName', $row['name']);
$this->set('productContent', $row['description']);
$this->set('productArt', $row['uid']);
if (!empty($row['uid']) and PHPShopParser::checkFile('product/main_product_forma_full_productArt.tpl')) {
$this->set('productArt', ParseTemplateReturn('product/main_product_forma_full_productArt.tpl'));
}
$this->checkStore($row);
$this->set('productSaleReady', $this->lang('productSaleReady'));
$this->set('productDes', Parser($row['content']));
$this->set('productPriceMoney', $this->dengi);
$this->set('productBack', $this->lang('product_back'));
$this->set('productSale', $this->lang('product_sale'));
$this->set('productSelect', $this->lang('product_select'));
$this->set('productUid', $row['id']);
$this->set('productId', $row['id']);
$this->set('productBestPrice', $this->lang('productBestPrice'));
$this->article($row);
$this->parent($row);
$this->setHook(__CLASS__, __FUNCTION__, $row, 'MIDDLE');
if (isset($_REQUEST['ajax'])) {
if ($_REQUEST['ajax'] == 'json') {
$json = array(
'id' => $row['id'],
'name' => PHPShopString::win_utf8($row['name'],true),
'uid' => PHPShopString::win_utf8($row['uid']),
'category' => PHPShopString::win_utf8($this->category_name),
'price' => str_replace(' ', '', $this->get('productPrice')),
'success' => 1
);
header("Content-Type: application/json");
exit(json_encode($json));
} else {
$disp = ParseTemplateReturn($this->ajaxTemplate);
if (!empty($GLOBALS['SysValue']['base']['seourlpro']['seourlpro_system']))
$disp = $GLOBALS['PHPShopSeoPro']->AjaxCompile($disp);
header('Content-type: text/html; charset='.$GLOBALS['PHPShopLang']->charset);
exit(PHPShopParser::replacedir($disp));
}
}
else
$this->add(ParseTemplateReturn($this->getValue('templates.main_product_forma_full')), true);
$this->odnotip($row);
$cat = $this->PHPShopCategory->getValue('parent_to');
if (!empty($cat)) {
$parent_category_row = $this->select(array('id,name,parent_to'), array('id' => '=' . $cat), false, array('limit' => 1), __FUNCTION__, array('base' => $this->getValue('base.categories'), 'cache' => 'true'));
} else {
$cat = 0;
$parent_category_row = array(
'name' => '',
'id' => 0
);
}
$this->set('catalogCat', $parent_category_row['name']);
$this->set('catalogId', $parent_category_row['id']);
$this->set('catalogUId', $cat);
$this->set('pcatalogId', $this->category);
$this->set('productName', $row['name']);
$this->set('catalogCategory', $this->PHPShopCategory->getName());
$this->setActiveMenu();
$this->navigation($this->category, $row['name']);
$this->set_meta(array($row, $this->PHPShopCategory->getArray(), $parent_category_row));
$this->lastmodified = $row['datas'];
$this->setHook(__CLASS__, __FUNCTION__, $row, 'END');
$row['category'] = $this->category_name;
$this->PHPShopAnalitica->init(__FUNCTION__, $row);
$this->parseTemplate($this->getValue('templates.product_page_full'));
}
function set_meta($row) {
if ($this->setHook(__CLASS__, __FUNCTION__, $row))
return true;
$this->doLoadFunction(__CLASS__, __FUNCTION__, $row);
}
function odnotip($row) {
global $PHPShopProductIconElements;
$this->odnotip_setka_num = null;
$this->line = false;
$this->template_odnotip = 'main_spec_forma_icon';
$hook = $this->setHook(__CLASS__, __FUNCTION__, $row, 'START');
if ($hook)
return true;
$disp = null;
$odnotipList = null;
if (!empty($row['odnotip']))
$odnotipList = ' id IN (' . $row['odnotip'] . ') ';
if ($this->PHPShopSystem->getSerilizeParam('admoption.sklad_status') == 2)
$chek_items = ' and items>0';
else
$chek_items = null;
if (!empty($row['odnotip'])) {
if (PHPShopParser::check($this->getValue('templates.main_product_odnotip_list'), 'productOdnotipList')) {
if (empty($this->odnotip_setka_num))
$this->odnotip_setka_num = $this->PHPShopSystem->getParam('num_vitrina');
$productOdnotipList = true;
$this->template_odnotip = 'main_product_forma_' . $this->odnotip_setka_num;
} else {
$productOdnotipList = false;
if (empty($this->odnotip_setka_num))
$this->odnotip_setka_num = 1;
$this->template_odnotip = 'main_spec_forma_icon';
}
$PHPShopOrm = new PHPShopOrm();
$PHPShopOrm->mysql_error = false;
$PHPShopOrm->debug = $this->debug;
$result = $PHPShopOrm->query("select * from " . $this->objBase . " where " . $odnotipList . " " . $chek_items . " and enabled='1' and parent_enabled='0' and sklad!='1' order BY FIELD (id, " . $row['odnotip'] . ")");
while ($row = mysqli_fetch_assoc($result))
$data[] = $row;
if (!empty($data) and is_array($data))
$disp = $PHPShopProductIconElements->seamply_forma($data, $this->odnotip_setka_num, $this->template_odnotip, $this->line);
}
if (!empty($disp)) {
$this->set('productOdnotipList', $disp);
$this->set('productOdnotip', __(''));
$this->setHook(__CLASS__, __FUNCTION__, $row, 'MIDDLE');
$odnotipDisp = ParseTemplateReturn($this->getValue('templates.main_product_odnotip_list'));
$this->set('odnotipDisp', $odnotipDisp);
}
$this->setHook(__CLASS__, __FUNCTION__, $row, 'END');
}
function parent($row){
if($this->setHook(__CLASS__, __FUNCTION__, $row, 'START'))
return true;
$this->select_value = array();
$this->parent_id = $row['id'];
$row['parent'] = PHPShopSecurity::CleanOut($row['parent']);
if (!empty($row['parent'])) {
$parent = @explode(",", $row['parent']);
$sklad_status = $this->PHPShopSystem->getSerilizeParam('admoption.sklad_status');
$this->set('ComStartCart', '<!--');
$this->set('ComEndCart', '-->');
PHPShopObj::loadClass('sort');
$PHPShopParentNameArray = new PHPShopParentNameArray(array('id' => '=' . $this->PHPShopCategory->getParam('parent_title')));
$parent_title = $PHPShopParentNameArray->getParam($this->PHPShopCategory->getParam('parent_title') . ".name");
$parent_color = $PHPShopParentNameArray->getParam($this->PHPShopCategory->getParam('parent_title') . ".color");
if (!empty($parent_title))
$this->parent_title = $parent_title;
else
$this->parent_title = __($this->parent_title);
if (!empty($parent_color))
$this->parent_color = $parent_color;
else $this->parent_color = __($this->parent_color);
if ($this->PHPShopSystem->ifSerilizeParam('1c_option.update_option'))
$Product = $this->select(array('*'), array('uid' => ' IN ("' . @implode('","', $parent) . '")', 'enabled' => "='1'", 'sklad' => "!='1'"), array('order' => 'length(parent),parent'), array('limit' => 100), __FUNCTION__, false, false);
else
$Product = $this->select(array('*'), array('id' => ' IN ("' . @implode('","', $parent) . '")', 'enabled' => "='1'", 'sklad' => "!='1'"), array('order' => 'length(parent),parent'), array('limit' => 100), __FUNCTION__, false, false);
if (is_array($Product) and !empty($row['price']) and empty($row['priceSklad']) and (!empty($row['items']) or (empty($row['items']) and $sklad_status == 1))) {
$this->select_value[] = array($row['name'] . " - (" . $this->price($row) . "
" . $this->currency . ')', $row['id'], $row['items'], $row);
}
if (is_array($Product))
foreach ($Product as $p) {
if (!empty($p)) {
if (empty($p['priceSklad']) and (!empty($p['items']) or (empty($p['items']) and $sklad_status == 1))) {
$price = $this->price($p);
if ($this->memory_get(__CLASS__ . '.' . __FUNCTION__, true)) {
$hook = $this->setHook(__CLASS__, __FUNCTION__, $p, 'MIDDLE');
if ($hook) {
$this->select_value[] = $hook;
} else {
$this->memory_set(__CLASS__ . '.' . __FUNCTION__, 0);
$this->select_value[] = array($p['name'] . ' - (' . $price . ' ' . $this->currency . ')', $p['id'], $p['items'], $p);
}
}
else
$this->select_value[] = array($p['name'] . ' - (' . $price . ' ' . $this->currency . ')', $p['id'], $p['items'], $p);
}
}
}
$this->set('productPrice', $this->price($row));
$productPriceNew = $this->price($row, true);
if ((float) $productPriceNew > 0) {
$this->set(array('productPriceOld', 'productPriceRub'), PHPShopText::strike($productPriceNew . " " . $this->currency, $this->format));
}
if (count($this->select_value) > 0) {
$this->set('parentList', PHPShopText::select('parentId', $this->select_value, "; max-width:300px;"));
$this->set('productParentList', ParseTemplateReturn("product/product_odnotip_product_parent.tpl"));
$this->set('optionsDisp', null);
}
else
$this->set('elementCartHide', 'hide hidden');
$this->setHook(__CLASS__, __FUNCTION__, $row, 'END');
}
}
function CID() {
if ($this->setHook(__CLASS__, __FUNCTION__, false, 'START'))
return true;
$this->category = PHPShopSecurity::TotalClean($this->PHPShopNav->getId(), 1);
$this->PHPShopCategory = new PHPShopCategory(intval($this->category));
$this->category_name = $this->PHPShopCategory->getName();
$parent_category_row = $this->select(array('*'), array('parent_to' => '=' . $this->category . " or dop_cat LIKE '%#" . intval($this->category) . "#%'"), false, array('limit' => 1), __FUNCTION__, array('base' => $this->getValue('base.categories')));
$this->setHook(__CLASS__, __FUNCTION__, $parent_category_row, 'MIDDLE');
if ($parent_category_row['id']) {
$depth = $this->PHPShopSystem->getSerilizeParam('admoption.catlist_depth');
if(empty($depth)) {
$depth = 2;
}
$this->category_array = array_column($this->PHPShopCategory->getChildrenCategories($depth, ['id', 'parent_to']), 'id');
if (is_array($this->category_array) and $this->PHPShopSystem->ifSerilizeParam('admoption.catlist_enabled') and PHPShopParser::check($this->getValue('templates.product_page_list'), 'ProductCatalogContent')) {
$this->CID_Product(null, true);
}
else
$this->CID_Category();
}
else {
$this->CID_Product();
}
}
function query_filter($where = false) {
$hook = $this->setHook(__CLASS__, __FUNCTION__);
if (!empty($hook))
return $hook;
return $this->doLoadFunction(__CLASS__, __FUNCTION__);
}
function sort_table($row) {
if ($this->setHook(__CLASS__, __FUNCTION__, $row))
return true;
$this->doLoadFunction(__CLASS__, __FUNCTION__, $row);
}
function CID_Product($category = null, $mode = false) {
global $PHPShopBase;
if (!empty($category))
$this->category = intval($category);
$this->objPath = './CID_' . $this->category . '_';
$this->cell = $cell = $this->calculateCell($this->category, $this->PHPShopCategory->getParam('num_row'));
if ($this->setHook(__CLASS__, __FUNCTION__, false, 'START'))
return true;
if (empty($this->category_name) or $this->errorMultibase($this->category) or $this->PHPShopCategory->getParam('skin_enabled') == 1)
return $this->setError404();
$order = $this->query_filter();
$num_cow = $this->PHPShopCategory->getParam('num_cow');
if (!empty($num_cow))
$this->num_row = $num_cow;
else if ($this->PHPShopSystem->getValue('num_row') > 0)
$this->num_row = $this->PHPShopSystem->getValue('num_row');
else
$this->num_row = (6 - $cell) * $cell;
if((int) $this->cell > 0) {
$check_cell = $this->num_row % $this->cell;
if ($this->num_row % $this->cell !== 0)
$this->num_row = $this->num_row - $check_cell;
}
if (is_array($order)) {
$this->dataArray = parent::getListInfoItem(false, false, false, __CLASS__, __FUNCTION__, $order['sql']);
if (!is_array($this->dataArray)) {
if ($this->page > 1)
return $this->setError404();
if (isset($_POST['ajax'])) {
header('Content-type: text/html; charset='.$GLOBALS['PHPShopLang']->charset);
exit(PHPShopText::h4($this->lang('empty_product_list'), 'empty_product_list'));
}
if ($this->PHPShopSystem->ifSerilizeParam('admoption.filter_cache_enabled'))
$this->update_cache('filter');
}
$this->setPaginator(count($this->dataArray), $order['sql']);
if ($this->PHPShopSystem->getSerilizeParam('admoption.filter_cache_enabled') == 1 && $this->PHPShopSystem->getSerilizeParam('admoption.filter_products_count') == 1)
$this->update_cache('count_products');
} else {
$this->PHPShopOrm->sql = 'select * from ' . $this->SysValue['base']['products'] . ' where ' . $order;
$this->PHPShopOrm->debug = $this->debug;
$this->PHPShopOrm->comment = __CLASS__ . '.' . __FUNCTION__;
$this->dataArray = $this->PHPShopOrm->select();
$this->PHPShopOrm->clean();
$this->setPaginator(count($this->dataArray), $order);
}
$this->set('pcatalogId', $this->category);
$grid = $this->product_grid($this->dataArray, $cell);
if (!empty($GLOBALS['SysValue']['base']['seourlpro']['seourlpro_system'])) {
$this->set('page_prefix', '-');
$seourlpro = true;
} elseif (!empty($GLOBALS['SysValue']['base']['seourl']['seourl_system'])) {
$this->set('seomod', $GLOBALS['seourl_pref'] . PHPShopString::toLatin($this->category_name));
$this->set('page_prefix', '_');
}
else
$this->set('page_prefix', '_');
$this->set('page_postfix', $_SERVER['QUERY_STRING']);
$this->set('max_page', $this->max_page);
if (isset($_POST['ajax'])) {
if (!empty($seourlpro))
$grid = $GLOBALS['PHPShopSeoPro']->AjaxCompile($grid);
header('Content-type: text/html; charset='. $GLOBALS['PHPShopLang']->charset);
exit(PHPShopParser::replacedir($this->separator . $grid));
}
if (empty($grid) and empty($mode)){
$grid = PHPShopText::h4($this->lang('empty_product_list'), 'empty_product_list');
$this->set('hideSort', 'hide');
}
$this->add($grid, true);
PHPShopObj::loadClass('sort');
$PHPShopSort = new PHPShopSort($this->category, $this->PHPShopCategory->getParam('sort'), true, $this->sort_template, false, true, true, true, $this->cat_template);
if (isset($_REQUEST['ajaxfilter'])) {
header('Content-type: text/html; charset='.$GLOBALS['PHPShopLang']->charset);
exit($PHPShopSort->display());
}
$this->set('vendorDisp', $PHPShopSort->display());
$this->set('vendorCatDisp', $PHPShopSort->categories());
if ($this->category_array) {
$dop_cats = '';
foreach ($this->category_array as $dopCat) {
$dop_cats .= ' OR dop_cat LIKE \'%#' . $dopCat . '#%\' ';
}
$categories_str = implode(",", $this->category_array);
$where = array('(category' => ' IN (' . $categories_str . ') ' . $dop_cats . ')', 'enabled' => "='1'", 'parent_enabled' => "='0'", $this->PHPShopSystem->getPriceColumn() => '>1');
}
else
$where = array('(category' => '=' . intval($this->category) . ' OR dop_cat LIKE \'%#' . $this->category . '#%\')', 'enabled' => "='1'", 'parent_enabled' => "='0'", $this->PHPShopSystem->getPriceColumn() => '>1');
if ($this->multi_currency_search)
$search_where = array('min(price_search) as min', 'max(price_search) as max');
else
$search_where = array('max(' . $this->PHPShopSystem->getPriceColumn() . ') as max', 'min(' . $this->PHPShopSystem->getPriceColumn() . ') as min');
if (!$PHPShopBase->phpversion())
$group = array('group' => $this->PHPShopSystem->getPriceColumn());
else
$group = null;
$data = $this->select($search_where, $where, $group);
$this->price_max = $data['max'] + 6;
$this->price_min = $data['min'];
if ($this->price_min == $this->price_max)
$this->price_min = intval($this->price_max / 2);
$this->set('price_max', intval($this->price_max));
$this->set('price_min', intval($this->price_min));
$this->setHook(__CLASS__, __FUNCTION__, $this->dataArray, 'END');
if ($mode) {
$this->set('ProductCatalogContent', $this->CID_Category(true));
}
else
$this->set('ProductCatalogContent', $this->catalog_content());
$this->PHPShopAnalitica->init(__FUNCTION__, array('name' => $this->category_name,'pic_small'=>$this->PHPShopCategory->getParam('icon')));
if (!empty($grid))
$this->parseTemplate($this->getValue('templates.product_page_list'));
else if ($mode)
$this->parseTemplate($this->getValue('templates.catalog_info_forma'));
}
function catalog_content() {
$cat = $this->PHPShopCategory->getParam('parent_to');
if (!empty($cat)) {
$parent_category_row = $this->select(array('id,name,parent_to'), array('id' => '=' . $cat), false, array('limit' => 1), __FUNCTION__, array('base' => $this->getValue('base.categories'), 'cache' => 'true'));
} else {
$cat = $this->category;
$parent_category_row = array();
}
$this->set('catalogCat', $parent_category_row['name']);
$this->set('catalogCategory', $this->PHPShopCategory->getName());
$this->set('productId', $this->category);
$this->set('catalogUId', $cat);
$this->setActiveMenu();
$this->set_meta(array($this->PHPShopCategory->getArray(), $parent_category_row));
$this->other_cat_navigation($cat);
$this->navigation($cat, $this->PHPShopCategory->getName());
$this->set('catalogContent', Parser($this->PHPShopCategory->getContent()));
$this->setHook(__CLASS__, __FUNCTION__, $parent_category_row);
$dis = ParseTemplateReturn($this->getValue('templates.product_catalog_content'));
return $dis;
}
function other_cat_navigation($parent) {
$this->setHook(__CLASS__, __FUNCTION__, $parent, 'START');
$dis = PHPShopText::h1($this->get('catalogCat'));
$dataArray = array();
$dis = null;
foreach ($GLOBALS['Cache'][$GLOBALS['SysValue']['base']['categories']] as $val) {
if ($val['parent_to'] == $parent and $val['skin_enabled'] != 1)
$dataArray[] = $val;
}
if (count($dataArray) > 1) {
foreach ($dataArray as $row) {
if ($row['id'] == $this->category)
$class = 'activ_catalog';
else
$class = null;
$dis .= PHPShopText::a('/shop/CID_' . $row['id'] . '.html', $row['name'], false, false, false, false, $class);
$dis .= ' | ';
}
}
else {
$PHPShopOrm = new PHPShopOrm($this->getValue('base.categories'));
$PHPShopOrm->debug = $this->debug;
$PHPShopOrm->cache = false;
$dataArray = $PHPShopOrm->select(array('*'), array('parent_to' => '=' . $parent, 'skin_enabled' => " != '1'"), array('order' => 'num'), array('limit' => 100));
if (is_array($dataArray))
foreach ($dataArray as $row) {
if ($row['id'] == $this->category)
$class = 'activ_catalog';
else
$class = null;
$dis .= PHPShopText::a('/shop/CID_' . $row['id'] . '.html', $row['name'], false, false, false, false, $class);
$dis .= ' | ';
}
}
$hook = $this->setHook(__CLASS__, __FUNCTION__, $parent, 'END');
if ($hook)
return true;
$this->set('DispCatNav', substr($dis, 0, strlen($dis) - 2));
}
function CID_Category($mode = false) {
$this->cid_cat_with_foto_template = 'catalog/cid_category.tpl';
$hook = $this->setHook(__CLASS__, __FUNCTION__, false, 'START');
if ($hook)
return true;
$this->category = PHPShopSecurity::TotalClean($this->PHPShopNav->getId(), 1);
$this->PHPShopCategory = new PHPShopCategory($this->category);
if ($this->PHPShopCategory->getParam('skin_enabled') == 1 or $this->errorMultibase($this->category))
return $this->setError404();
$this->category_name = $this->PHPShopCategory->getName();
$where['skin_enabled'] = "!='1'";
$where['skin_enabled'].=' and (parent_to =' . $this->category . " or dop_cat LIKE '%#" . $this->category . "#%')";
if (defined("HostID"))
$where['servers'] = " REGEXP 'i" . HostID . "i'";
elseif (defined("HostMain"))
$where['skin_enabled'] .= ' and (servers ="" or servers REGEXP "i1000i")';
switch ($this->PHPShopCategory->getValue('order_to')) {
case(1):
$order_direction = "";
break;
case(2):
$order_direction = " desc";
break;
default:
$order_direction = "";
break;
}
switch ($this->PHPShopCategory->getValue('order_by')) {
case(1):
$order = array('order' => 'name' . $order_direction);
break;
case(2):
$order = array('order' => 'name' . $order_direction);
break;
case(3):
$order = array('order' => 'num' . $order_direction);
break;
default:
$order = array('order' => 'num' . $order_direction);
break;
}
$PHPShopOrm = new PHPShopOrm($this->getValue('base.categories'));
$PHPShopOrm->debug = $this->debug;
$PHPShopOrm->cache = $this->cache;
$dis = null;
$dataArray = $PHPShopOrm->select(array('*'), $where, $order, array('limit' => $this->max_item));
if (is_array($dataArray))
if (PHPShopParser::checkFile($this->cid_cat_with_foto_template)) {
foreach ($dataArray as $row) {
if (empty($row['icon']))
$row['icon'] = $this->no_photo;
$this->set('podcatalogIcon', $row['icon']);
$this->set('podcatalogId', $row['id']);
$this->set('podcatalogName', $row['name']);
$this->set('podcatalogDesc', $row['content']);
$dis .= ParseTemplateReturn($this->cid_cat_with_foto_template);
}
$disp = $dis;
} else {
foreach ($dataArray as $row) {
$dis .= PHPShopText::li($row['name'], '/shop/CID_' . $row['id'] . '.html');
}
$disp = PHPShopText::ul($dis);
}
$this->set('catalogContent', Parser($this->PHPShopCategory->getContent()));
$this->set('catalogName', $this->category_name);
$this->set('catalogList', $disp);
$this->set('thisCat', $this->PHPShopNav->getId());
$cat = $this->PHPShopCategory->getValue('parent_to');
if (!empty($cat)) {
$parent_category_row = $this->select(array('id,name,parent_to'), array('id' => '=' . $cat), false, array('limit' => 1), __FUNCTION__, array('base' => $this->getValue('base.categories'), 'cache' => 'true'));
} else {
$cat = 0;
$parent_category_row = array(
'name' => '',
'id' => 0
);
}
$this->setActiveMenu();
$this->set_meta(array($this->PHPShopCategory->getArray(), $parent_category_row));
$this->navigation($this->PHPShopCategory->getParam('parent_to'), $this->category_name);
$this->setHook(__CLASS__, __FUNCTION__, $dataArray, 'END');
if ($mode == true)
return ParseTemplateReturn($this->getValue('templates.catalog_info_forma'));
else
$this->parseTemplate($this->getValue('templates.catalog_info_forma'));
}
function index() {
$this->setError404();
}
function update_cache($type) {
if (count($_REQUEST['v']) == 1) {
foreach ($_REQUEST['v'] as $sort_id => $sort_value) {
if (count($sort_value) == 1) {
$period = ($this->PHPShopSystem->getSerilizeParam('admoption.filter_cache_period')) * 86400;
if (empty($period))
$period = 259200;
$PHPShopOrm = new PHPShopOrm($GLOBALS['SysValue']['base']['categories']);
$sort_cache = $PHPShopOrm->select(array('sort_cache', 'sort_cache_created_at'), array('id=' => $this->category));
if (($sort_cache['sort_cache_created_at'] + $period) > time()) {
$cache = unserialize($sort_cache['sort_cache']);
if ($type == 'filter') {
if (is_array($cache['filter_cache'][$sort_id]))
array_push($cache['filter_cache'][$sort_id], PHPShopSecurity::TotalClean($sort_value[0], 5));
else
$cache['filter_cache'][$sort_id] = array(PHPShopSecurity::TotalClean($sort_value[0], 5));
$PHPShopOrm->update(
array(
'sort_cache_new' => serialize($cache)
), array(
'id=' => $this->category
));
} elseif ($type = 'count_products') {
if (is_array($_REQUEST['v']))
foreach ($_REQUEST['v'] as $k => $v)
if (is_array($v))
foreach ($v as $key => $val)
$cache['products'][$k][intval($val)] = (int) $this->num_page;
$PHPShopOrm->update(
array(
'sort_cache_new' => serialize($cache)), array(
'id=' => $this->category
));
}
} else {
if ($type == 'filter') {
if (is_array($_REQUEST['v']))
foreach ($_REQUEST['v'] as $k => $v)
if (is_array($v))
foreach ($v as $key => $val)
$cache['filter_cache'][$k][$key] = intval($val);
$PHPShopOrm->update(
array(
'sort_cache_new' => serialize($cache),
'sort_cache_created_at_new' => time()), array(
'id=' => $this->category
));
}elseif ($type = 'count_products') {
if (is_array($_REQUEST['v']))
foreach ($_REQUEST['v'] as $k => $v)
if (is_array($v))
foreach ($v as $key => $val)
$cache['products'][$k][intval($val)] = (int) $this->num_page;
$PHPShopOrm->update(
array(
'sort_cache_new' => serialize($cache),
'sort_cache_created_at_new' => time()), array(
'id=' => $this->category
));
}
}
}
}
}
}
}
?>