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:
<?php
class PHPShopNews extends PHPShopCore {
function __construct() {
$this->objBase = $GLOBALS['SysValue']['base']['table_name8'];
$this->objPath = "/news/news_";
$this->debug = false;
$this->empty_index_action = true;
$this->action = array("nav" => array("index", "ID"), "post" => "news_plus", "get" => "news_del");
parent::__construct();
}
function index() {
global $PHPShopModules;
$this->dataArray = parent::getListInfoItem(array('*'), false, array('order' => 'id DESC'));
if (!isset($this->dataArray))
return $this->setError404();
if (is_array($this->dataArray))
foreach ($this->dataArray as $row) {
$this->set('newsId', $row['id']);
$this->set('newsData', $row['date']);
$this->set('newsZag', $row['title']);
$this->set('newsKratko', $row['description']);
$PHPShopModules->setHookHandler(__CLASS__, __FUNCTION__, $this, $row);
$this->addToTemplate($this->getValue('templates.main_news_forma'));
}
$this->setPaginator();
$this->title = "" . $this->PHPShopSystem->getValue("name");
$this->parseTemplate($this->getValue('templates.news_page_list'));
}
function setPaginatorContent() {
$curId = $this->PHPShopNav->getId();
$prevId = $curId - 1;
$nextId = $curId + 1;
$PHPShopOrm = new PHPShopOrm($this->objBase);
$PHPShopOrm->Option['where'] = ' or ';
$PHPShopOrm->debug = $this->debug;
$PHPShopOrm->sql = 'select id from ' . $this->objBase . ' where id=' . $prevId . ' or id=' . $nextId;
$row = $PHPShopOrm->select();
if (count($row) == 1)
$data[0] = $row;
else
$data = $row;
if (is_array($data)) {
if ($data[0]['id'] == $prevId)
$navigat = '<a href="./ID_' . $prevId . '.html" title="' . $this->getValue('lang.prev_page') . '">' .
$this->getValue('lang.prev_page') . '</a>';
else
$navigat = '';
if ($data[1]['id'] == $nextId)
$navigat.=' | <a href="./ID_' . $nextId . '.html" title="' . $this->getValue('lang.next_page') . '">' .
$this->getValue('lang.next_page') . '</a>';
else
$navigat.='';
}
return $navigat;
}
function ID() {
global $PHPShopModules;
if (!PHPShopSecurity::true_num($this->PHPShopNav->getId()))
return $this->setError404();
$row = parent::getFullInfoItem(array('*'), array('id' => '=' . $this->PHPShopNav->getId()));
if (!is_array($row))
return $this->setError404();
$this->set('newsData', $row['date']);
$this->set('newsZag', $row['title']);
$this->set('newsKratko', $row['description']);
$this->set('newsPodrob', $row['content']);
$this->set('paginatorContent', $this->setPaginatorContent());
$PHPShopModules->setHookHandler(__CLASS__, __FUNCTION__, $this, $row);
$this->addToTemplate($this->getValue('templates.main_news_forma_full'));
$this->title = $row['title'] . " - " . $this->PHPShopSystem->getValue("name");
$this->description = strip_tags($row['description']);
$this->lastmodified = PHPShopDate::GetUnixTime($row['date']);
$this->navigation(false, $row['title'], array('name' => __(''), 'url' => '/news/'));
$this->parseTemplate($this->getValue('templates.news_page_full'));
}
function news_plus() {
$mail = PHPShopSecurity::TotalClean($_POST['mail'], 3);
switch ($_POST['status']) {
case 1:
$this->write($mail);
break;
case 0:
$this->del($mail);
break;
}
$this->title = "" . $this->PHPShopSystem->getValue("name");
$this->parseTemplate($this->getValue('templates.news_forma_message'));
}
function chek($mail) {
$PHPShopOrm = new PHPShopOrm($this->getValue('base.table_name9'));
$PHPShopOrm->debug = $this->debug;
$num = $PHPShopOrm->select(array('id'), array('mail' => "='$mail'"), false, array('limit' => 1));
if (empty($num['id']))
return true;
}
function write($mail) {
if (!empty($mail)) {
if ($this->chek($mail)) {
$PHPShopOrm = new PHPShopOrm($this->getValue('base.table_name9'));
$PHPShopOrm->debug = $this->debug;
$PHPShopOrm->insert(array('date' => date("d-m-y"), 'mail' => $mail), $prefix = '');
$mes = "<FONT style=\"font-size:14px;color:red\">
<B>" . $this->getValue('lang.good_news_message_1') . "</B></FONT><BR>" . $this->getValue('lang.good_news_message_2');
} else {
$mes = "<FONT style=\"font-size:14px;color:red\">
<B>" . $this->getValue('lang.bad_news_message_1') . "</B></FONT><BR>" . $this->getValue('lang.good_news_message_2');
}
} else {
$mes = "<FONT style=\"font-size:14px;color:red\">
<B>" . $this->getValue('lang.bad_news_message_3') . "</B></FONT><BR>" . $this->getValue('lang.good_news_message_2');
}
$this->set('mesageText', $mes);
}
function del($mail) {
if (!$this->chek($mail)) {
$PHPShopOrm = new PHPShopOrm($this->getValue('base.table_name9'));
$PHPShopOrm->debug = $this->debug;
$PHPShopOrm->delete(array('mail' => "='$mail'"));
$mes = "<FONT style=\"font-size:14px;color:red\">
<B>" . $this->getValue('lang.bad_news_message_2') . "</B></FONT><BR>" . $this->getValue('lang.good_news_message_2');
} else {
$mes = "<FONT style=\"font-size:14px;color:red\">
<B>" . $this->getValue('lang.bad_news_message_3') . "</B></FONT><BR>" . $this->getValue('lang.good_news_message_2');
}
$this->set('mesageText', $mes);
}
function news_del() {
$mail = PHPShopSecurity::TotalClean($_GET['mail'], 3);
$this->del($mail);
$this->title = "" . $this->PHPShopSystem->getValue("name");
$this->parseTemplate($this->getValue('templates.news_forma_message'));
}
function meta() {
global $PHPShopModules;
parent::meta();
$PHPShopModules->setHookHandler(__CLASS__, __FUNCTION__, $this);
}
}
?>