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:
<?php
class PHPShopPage extends PHPShopCore {
var $navigationBase = 'base.page_categories';
var $debug = false;
var $odnootip_cell_center = 2;
var $odnootip_cell_block = 1;
var $limit = 3;
function __construct() {
$this->objBase = $GLOBALS['SysValue']['base']['page'];
$this->action = array("nav" => "CID");
$this->empty_index_action = true;
$this->cid_cat_with_foto_template = 'catalog/cid_page_category.tpl';
if (!empty($GLOBALS['SysValue']['base']['seourlpro']['seourlpro_system'])) {
$this->seourlpro_enabled = true;
}
parent::__construct();
}
function getAll() {
$title = __('');
$this->title = $title . " - " . $this->PHPShopSystem->getValue("name");
$PHPShopOrm = new PHPShopOrm($this->getValue('base.page_categories'));
$PHPShopOrm->debug = $this->debug;
$data = $PHPShopOrm->select(array('*'), array('parent_to' => "=0"), array('order' => 'num,id desc'), array('limit' => 300));
$dis = null;
if (is_array($data)) {
foreach ($data as $row) {
if (empty($row['page_cat_seo_name']) or empty($this->seourlpro_enabled))
$url = '/page/CID_' . $row['id'] . '.html';
else
$url = '/page/' . $row['page_cat_seo_name'] . '.html';
if (PHPShopParser::checkFile($this->cid_cat_with_foto_template)) {
$this->set('podcatalogIcon', $row['icon']);
$this->set('podcatalogId', $row['id']);
$this->set('podcatalogName', $row['name']);
$this->set('podcatalogUrl', $url);
$dis .= ParseTemplateReturn('catalog/cid_page_category.tpl');
} else {
$dis .= PHPShopText::li($row['name'], $url);
}
}
}
$this->navigation(0, $title);
$this->set('pageContent', PHPShopText::ul($dis));
$this->set('pageTitle', $title);
$this->set('pageIcon', $data['icon']);
$this->parseTemplate($this->getValue('templates.page_catalog_list'));
}
function index($link = false) {
$hook_start = $this->setHook(__CLASS__, __FUNCTION__, false, 'START');
if ($hook_start)
return true;
if (empty($link))
$link = PHPShopSecurity::TotalClean($this->PHPShopNav->getName(true), 2);
if (empty($link))
return $this->getAll();
if (isset($_SESSION['UsersId'])) {
$sort = " and ((secure !='1') OR (secure ='1' AND secure_groups='') OR (secure ='1' AND secure_groups REGEXP 'i" . $_SESSION['UsersStatus'] . "-1i')) ";
} else {
$sort = " and (secure !='1') ";
}
if (defined("HostID")) {
$sort .= " and servers REGEXP 'i" . HostID . "i'";
} elseif (defined("HostMain"))
$sort .= " and (servers = '' or servers REGEXP 'i1000i')";
$PHPShopOrm = new PHPShopOrm();
$PHPShopOrm->debug = $this->debug;
$result = $PHPShopOrm->query("select * from " . $this->objBase . " where link='$link' and enabled='1' $sort limit 1");
$row = mysqli_fetch_array($result);
if ($row['category'] == 2000)
return $this->setError404();
elseif (empty($row['id']))
return $this->setError404();
$this->category = $row['category'];
$this->PHPShopCategory = new PHPShopPageCategory($this->category);
$this->category_name = $this->PHPShopCategory->getName();
$this->odnotip($row);
$this->set('isPage', true);
$this->set('pageContent', Parser(stripslashes($row['content'])));
$this->set('pageTitle', $row['name']);
$this->set('catalogCategory', $this->category_name);
$this->set('catalogId', $this->category);
$this->set('pageIcon', $row['icon']);
$this->set('pagePreview', Parser(stripslashes($row['preview'])));
$this->PHPShopNav->objNav['id'] = $row['id'];
$this->set('NavActive', $row['link']);
if (empty($row['title']))
$title = $row['name'] . " - " . $this->PHPShopSystem->getValue("name");
else
$title = $row['title'];
$this->set('ogTitle', $row['name']);
if (!empty($row['icon']))
$this->set('ogImage', $row['icon']);
$this->set('ogDescription', $row['description']);
$this->title = $title;
$this->description = $row['description'];
$this->keywords = $row['keywords'];
$this->lastmodified = $row['datas'];
$this->navigation($row['category'], $row['name']);
$this->set('pageLast', $this->getLast($link));
$hook_end = $this->setHook(__CLASS__, __FUNCTION__, $row, 'END');
if ($hook_end)
return true;
$this->parseTemplate($this->getValue('templates.page_page_list'));
}
function CID() {
if ($this->setHook(__CLASS__, __FUNCTION__))
return true;
$this->category = PHPShopSecurity::TotalClean($this->PHPShopNav->getId(), 1);
$this->PHPShopCategory = new PHPShopPageCategory($this->category);
$this->category_name = $this->PHPShopCategory->getName();
$PHPShopOrm = new PHPShopOrm($this->getValue('base.page_categories'));
$PHPShopOrm->debug = $this->debug;
$row = $PHPShopOrm->select(array('id,name'), array('parent_to' => "=" . $this->category), false, array('limit' => 1));
if (empty($row['id'])) {
$this->ListPage();
}
else {
$this->ListCategory();
}
}
function ListPage() {
$dis = null;
$lastmodified = 0;
if ($this->setHook(__CLASS__, __FUNCTION__, false, 'START'))
return true;
if (empty($this->category_name))
return $this->setError404();
$where = array('category' => '=' . $this->category, 'enabled' => "='1'");
if (defined("HostID"))
$where['servers'] = " REGEXP 'i" . HostID . "i'";
elseif (defined("HostMain"))
$where['enabled'] .= ' and (servers ="" or servers REGEXP "i1000i")';
$dataArray = $this->PHPShopOrm->select(array('*'), $where, array('order' => 'num,id desc'), array('limit' => 100));
if (is_array($dataArray)) {
if (count($dataArray) > 1)
foreach ($dataArray as $row) {
$dis .= PHPShopText::li($row['name'], '/page/' . $row['link'] . '.html');
if ($row['datas'] > $lastmodified)
$lastmodified = $row['datas'];
}
else {
return $this->index($dataArray[0]['link']);
}
}
$disp = PHPShopText::ul($dis);
$this->set('catContent', $this->PHPShopCategory->getContent());
$this->set('pageContent', $disp);
$this->set('pageTitle', $this->category_name);
$this->set('pageIcon', $row['icon']);
$this->set('pagePreview', Parser(stripslashes($row['preview'])));
$cat = $this->PHPShopCategory->getValue('parent_to');
if (!empty($cat)) {
$PHPShopOrm = new PHPShopOrm($this->getValue('base.page_categories'));
$PHPShopOrm->cache = true;
$PHPShopOrm->debug = $this->debug;
$parent_category_row = $PHPShopOrm->select(array('id,name'), array('id' => '=' . $cat), false, array('limit' => 1), __FUNCTION__);
} else {
$parent_category_row['name'] = $this->lang('catalog');
}
$this->set('catalogCategory', $parent_category_row['name']);
$this->set('catalogId', $cat);
if ($this->PHPShopCategory->getValue('title') != "")
$this->title = $this->PHPShopCategory->getValue('title');
else
$this->title = $this->category_name . " - " . $this->PHPShopSystem->getValue("name");
if ($this->PHPShopCategory->getValue('description') != "")
$this->description = $this->PHPShopCategory->getValue('description');
if ($this->PHPShopCategory->getValue('keywords') != "")
$this->description = $this->PHPShopCategory->getValue('keywords');
$this->lastmodified = $lastmodified;
$this->navigation($cat, $this->category_name);
$this->setHook(__CLASS__, __FUNCTION__, $dataArray, 'END');
$this->parseTemplate($this->getValue('templates.page_page_list'));
}
function ListCategory() {
$dis = null;
if ($this->setHook(__CLASS__, __FUNCTION__, false, 'START'))
return true;
if (empty($this->category_name))
return $this->setError404();
$where = array('parent_to' => '=' . $this->category);
if (defined("HostID"))
$where['servers'] = " REGEXP 'i" . HostID . "i'";
elseif (defined("HostMain"))
$where['parent_to'] .= ' and (servers ="" or servers REGEXP "i1000i")';
$PHPShopOrm = new PHPShopOrm($this->getValue('base.page_categories'));
$PHPShopOrm->debug = $this->debug;
$dataArray = $PHPShopOrm->select(array('name', 'id'), $where, array('order' => 'num,id desc'), array('limit' => 100));
if (is_array($dataArray))
foreach ($dataArray as $row) {
if (empty($row['page_cat_seo_name']) or empty($this->seourlpro_enabled))
$url = '/page/CID_' . $row['id'] . '.html';
else
$url = '/page/' . $row['page_cat_seo_name'] . '.html';
if (PHPShopParser::checkFile($this->cid_cat_with_foto_template)) {
$this->set('podcatalogIcon', $row['icon']);
$this->set('podcatalogId', $row['id']);
$this->set('podcatalogName', $row['name']);
$this->set('podcatalogUrl', $url);
$dis .= ParseTemplateReturn('catalog/cid_page_category.tpl');
} else {
$dis .= PHPShopText::li($row['name'], $url);
}
}
$disp = PHPShopText::ul($dis);
$this->set('catContent', $this->PHPShopCategory->getContent());
$this->set('catName', $this->category_name);
$this->set('pageContent', $disp);
$this->set('pageTitle', $this->category_name);
$this->title = $this->category_name . " - " . $this->PHPShopSystem->getValue("name");
$this->navigation($this->PHPShopCategory->getParam('parent_to'), $this->category_name);
$this->setHook(__CLASS__, __FUNCTION__, $dataArray, 'END');
$this->parseTemplate($this->getValue('templates.page_catalog_list'));
}
function odnotip($row) {
global $PHPShopProductIconElements;
$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'])) {
if (strpos($row['odnotip'], ','))
$odnotip = explode(",", $row['odnotip']);
elseif (is_numeric(trim($row['odnotip'])))
$odnotip[] = trim($row['odnotip']);
}
if (is_array($odnotip))
foreach ($odnotip as $value) {
if (!empty($value))
$odnotipList .= ' id=' . trim($value) . ' OR';
}
$odnotipList = substr($odnotipList, 0, strlen($odnotipList) - 2);
if ($this->PHPShopSystem->getSerilizeParam('admoption.sklad_status') == 2)
$chek_items = ' and items>0';
else
$chek_items = null;
if (!empty($odnotipList)) {
$PHPShopOrm = new PHPShopOrm();
$PHPShopOrm->debug = $this->debug;
$result = $PHPShopOrm->query("select * from " . $this->getValue('base.products') . " where (" . $odnotipList . ") " . $chek_items . " and enabled='1' and parent_enabled='0' and sklad!='1' order by num");
while ($product_row = mysqli_fetch_assoc($result))
$data[] = $product_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)) {
if (PHPShopParser::check($this->getValue('templates.main_product_odnotip_list'), 'productOdnotipList')) {
$this->set('productOdnotipList', $disp);
$this->set('productOdnotip', __(''));
} else {
$this->set('specMainTitle', __(''));
$this->set('specMainIcon', $disp);
}
$this->setHook(__CLASS__, __FUNCTION__, $row, 'MIDDLE');
$odnotipDisp = ParseTemplateReturn($this->getValue('templates.main_product_odnotip_list'));
$this->set('odnotipDisp', $odnotipDisp);
}
else {
$this->set('specMainIcon', $PHPShopProductIconElements->specMainIcon(true, $this->category));
}
$this->setHook(__CLASS__, __FUNCTION__, $row, 'END');
}
function getLast($link) {
$dis = null;
$hook = $this->setHook(__CLASS__, __FUNCTION__, false, 'START');
if ($hook)
return $hook;
$where = array('enabled' => "='1'", 'preview' => '!=""', 'link' => '!="' . $link . '"');
if (defined("HostID"))
$where['servers'] = " REGEXP 'i" . HostID . "i'";
elseif (defined("HostMain"))
$where['preview'] .= ' and (servers ="" or servers REGEXP "i1000i")';
$PHPShopOrm = new PHPShopOrm($this->objBase);
$PHPShopOrm->debug = $this->debug;
$result = $PHPShopOrm->select(array('link', 'name', 'icon', 'datas', 'preview'), $where, array('order' => 'datas DESC'), array("limit" => $this->limit));
if ($this->limit > 1)
$data = $result;
else
$data[] = $result;
if (is_array($data))
foreach ($data as $row) {
$this->set('pageLink', $row['link']);
$this->set('pageName', $row['name']);
$this->set('pageIcon', $row['icon']);
$this->set('pageData', PHPShopDate::get($row['datas']));
$this->set('pagePreview', Parser(stripslashes($row['preview'])));
$this->setHook(__CLASS__, __FUNCTION__, $row, 'END');
$dis .= parseTemplateReturn($this->getValue('templates.page_mini'));
}
return $dis;
}
}
?>