/** * Формирование данных доступных в шаблоне. */ function createData() { if ($this->params['sort'] != 5) { $this->supportCached(); } $this->params['idcat'] = (int) $this->params['idcat']; $this->params['rows'] = (int) $this->params['rows']; if ($this->params['idcat']) { $catrow = A::$DB->getRowById($this->params['idcat'], "{$this->section}_categories"); $catrow['link'] = gallery_createCategoryLink($this->params['idcat'], $this->section); $this->Assign("category", $catrow); } switch ($this->params['sort']) { default: case 1: $sort = "date DESC"; break; case 2: $sort = "date"; break; case 3: $sort = "name"; break; case 4: $sort = "sort"; break; case 5: $sort = "RAND()"; break; } $sql = "\r\r\n\tSELECT *,svote/cvote AS vote FROM {$this->section}_albums\r\r\n\tWHERE active='Y'" . ($this->params['idcat'] ? " AND idcat={$this->params['idcat']}" : "") . (!empty($this->params['filter']) ? " AND {$this->params['filter']}" : "") . "\r\r\n\tORDER BY {$sort}"; if ($this->params['rows']) { A::$DB->queryLimit($sql, 0, $this->params['rows']); } else { A::$DB->query($sql); } $albums = array(); while ($row = A::$DB->fetchRow()) { $row['category'] = getTreePath($this->section . "_categories", $row['idcat']); $row['link'] = gallery_createItemLink($row['id'], $this->section); $row['vote'] = round($row['vote'], 2); $row['images'] = A::$DB->getAll("\r\r\n\t SELECT * FROM " . getDomain($this->section) . "_images\r\r\n\t WHERE idsec=? AND iditem=? ORDER BY sort", array($this->section_id, $row['id'])); if ($this->options['usetags']) { $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); } prepareValues($this->section, $row); $row = A::$OBSERVER->Modifier('gallery_prepareValues', $this->section, $row); $albums[] = $row; } A::$DB->free(); $this->Assign("albums", $albums); }
function listdata_loadlist($item) { $advc = A::$DB->getCount(A::$DOMAIN . "_fields", "item='{$item}'"); $lang = A::$LANG; if ($advc > 0) { $list = A::$DB->getAssoc("SELECT * FROM {$item} ORDER BY sort"); foreach ($list as $i => $row) { $list[$i]['name'] = $row['name_' . $lang]; prepareValues($item, $list[$i]); } } else { $list = A::$DB->getAssoc("SELECT id,name_{$lang} AS name FROM {$item} ORDER BY sort"); } return $list; }
/** * Формирование данных доступных в шаблоне. */ function createData() { $this->supportCached(true); $this->params['idcat'] = (int) $this->params['idcat']; if (isset($this->params['curcheck']) && $this->section == SECTION && A::$MAINFRAME->id > 0) { $this->params['idcat'] = A::$MAINFRAME->idker; } $links = array(); A::$DB->query("SELECT * FROM {$this->section} WHERE idker={$this->params['idcat']} AND active='Y' ORDER BY sort"); while ($row = A::$DB->fetchRow()) { if ($row['urlname'] == 'index') { continue; } $row['link'] = pages_createItemLink($row['id'], $this->section); $row['selected'] = $this->section == SECTION && ($row['id'] == A::$MAINFRAME->id || $row['type'] == 'dir' && $row['id'] == A::$MAINFRAME->idker); $row['subindex'] = false; if ($row['type'] == 'dir') { $row['sublinks'] = array(); A::$DB->query("SELECT id,name,urlname,type,level,content FROM {$this->section} WHERE idker={$row['id']} AND active='Y' ORDER BY sort"); while ($subrow = A::$DB->fetchRow()) { if ($subrow['urlname'] == 'index') { $row['subindex'] = true; continue; } $subrow['link'] = pages_createItemLink($subrow['id'], $this->section); $subrow['selected'] = $this->section == SECTION && $subrow['id'] == A::$MAINFRAME->id; $row['sublinks'][] = $subrow; } A::$DB->free(); } elseif ($this->options['usetags']) { $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); } prepareValues($this->section, $row); $links[] = $row; } A::$DB->free(); $this->Assign("links", $links); }
/** * Функция загрузки списка из данных каталога. * * @param string $item Полный строковой идентификатор раздела. */ function catalog_loadlist($item) { $rows = A::$DB->getAll("SELECT * FROM {$item}_catalog LIMIT 0,500"); $rows = array_multisort_key($rows, 'name'); $list = array(); foreach ($rows as $row) { prepareValues($item, $row); $list[$row['id']] = $row; } return $list; }
/** * Формирование данных доступных в шаблоне страницы полного списка товаров. */ function PricePage() { $this->supportCached(); $categories = array(); $this->getCategories($categories); $baselink = getSectionLink(SECTION); $sort = !empty($_GET['sort']) ? preg_replace("/[^a-z0-1_]+/i", "", $_GET['sort']) : (!empty(A::$OPTIONS['mysort']) ? A::$OPTIONS['mysort'] : A::$OPTIONS['sort']); foreach ($categories as $i => $catrow) { $categories[$i]['items'] = array(); A::$DB->query("\n SELECT * FROM " . SECTION . "_catalog\n WHERE idcat={$catrow['id']} AND active='Y'\n ORDER BY {$sort}"); while ($row = A::$DB->fetchRow()) { $row['tobasketlink'] = $baselink . "?action=addbasket&id=" . $row['id']; $row['tocomparelink'] = $baselink . "?action=addcompare&id=" . $row['id']; $row['available'] = $row['iscount'] > 0; prepareValues(SECTION, $row); $row = A::$OBSERVER->Modifier('shoplite_prepareValues', SECTION, $row); $categories[$i]['items'][] = $row; } A::$DB->free(); } $this->Assign("categories", $categories); $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION)); }
/** * Формирование данных доступных в шаблоне страницы альбома. */ function AlbumPage() { $this->supportCached(); $this->addCacheParam_Get('page'); if ($this->idcat > 0) { $this->category['link'] = gallery_createCategoryLink($this->category['id'], SECTION); if (A::$OPTIONS['usetags']) { $this->category['tags'] = A_SearchEngine::getInstance()->convertTags($this->category['tags']); } $this->Assign("category", $this->category); } $album = $this->album; $album['vote'] = $album['cvote'] > 0 ? round($album['svote'] / $album['cvote'], 2) : 0; $album['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $album['id'])); if (A::$OPTIONS['usetags']) { $album['tags'] = A_SearchEngine::getInstance()->convertTags($album['tags']); } prepareValues(SECTION, $album); $album = A::$OBSERVER->Modifier('gallery_prepareValues', SECTION, $album); $this->Assign("album", $album); $irows = (int) (!empty($_GET['irows'])) ? (int) $_GET['irows'] : A::$OPTIONS['irows']; $this->Assign("irows", $irows); $pager = new A_Pager($irows); $images = $pager->setItems($album['images']); $this->Assign("images", $images); $this->Assign("images_pager", $pager); $sort = escape_order_string(!empty(A::$OPTIONS['mysort']) ? A::$OPTIONS['mysort'] : A::$OPTIONS['sort']); $albums = A::$DB->getCol("\r\r\n\tSELECT id FROM " . SECTION . "_albums\r\r\n\tWHERE active='Y' AND idcat={$album['idcat']} ORDER BY {$sort}"); $i = array_search($album['id'], $albums); if ($i !== false) { $previd = isset($albums[$i - 1]) ? $albums[$i - 1] : 0; $nextid = isset($albums[$i + 1]) ? $albums[$i + 1] : 0; if ($previd) { $this->Assign("prevalbum", gallery_createItemLink($previd, SECTION)); } if ($nextid) { $this->Assign("nextalbum", gallery_createItemLink($nextid, SECTION)); } } if (A::$OPTIONS['usecomments']) { $comments = array(); A::$DB->query("SELECT * FROM " . DOMAIN . "_comments WHERE idsec=" . SECTION_ID . " AND iditem={$this->idalb} AND active='Y' ORDER BY date"); while ($row = A::$DB->fetchRow()) { if ($row['iduser'] > 0 && A::$AUTH->section) { if ($row['user'] = A::$DB->getRowById($row['iduser'], A::$AUTH->section)) { prepareValues(A::$AUTH->section, $row['user']); } } $comments[] = $row; } A::$DB->free(); $this->Assign("comments", $comments); $form = array(); $form['name'] = !empty($_REQUEST['name']) ? $_REQUEST['name'] : (A::$AUTH->isLogin() ? A::$AUTH->data['name'] : ""); $form['message'] = !empty($_REQUEST['message']) ? $_REQUEST['message'] : ""; $this->Assign("form", $form); $this->Assign("captcha", $captcha = substr(time(), rand(0, 6), 4)); A_Session::set("captcha", md5($captcha)); } if (A::$OPTIONS['usevote']) { $this->Assign("isvote", A_Session::get(SECTION . "_vote_" . $this->idalb, false)); $this->addCacheParam_Session(SECTION . "_vote_" . $this->idalb); } $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION)); if (isset($this->category)) { $this->AddNavCategories($this->category['id']); } $this->title = $this->album['name'] . (!empty($this->title) ? " - " . $this->title : ""); $this->description = $this->album['description']; }
/** * Получение полных данных записи каталога. * * @param integer $id Идентификатор товара. * @param string $section Полный строковой идентификатор раздела. * @param integer $idsec=0 Числовой идентификатор раздела. * @return array */ function shoplite_getItem($id, $section, $idsec = 0) { static $cache = array(); if (isset($cache[$section][$id])) { return $cache[$section][$id]; } if ($row = A::$DB->getRow("SELECT * FROM {$section}_catalog WHERE id=?i AND active='Y'", $id)) { if (!$idsec) { $idsec = getSectionId($section); } $row['link'] = shoplite_createItemLink($row['id'], $section); $row['tobasketlink'] = getSectionLink($section) . "?action=addbasket&id=" . $row['id']; $row['tocomparelink'] = getSectionLink($section) . "?action=addcompare&id=" . $row['id']; $row['category'] = getTreePath("{$section}_categories", $row['idcat']); $row['vote'] = round($row['vote'], 2); $row['available'] = $row['iscount'] > 0; $row['images'] = A::$DB->getAll("SELECT * FROM " . A::$DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array($idsec, $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); prepareValues($section, $row); $row = A::$OBSERVER->Modifier('shoplite_prepareValues', $section, $row); return $cache[$section][$id] = $row; } else { return $cache[$section][$id] = false; } }
/** * Получение полных данных страницы. * * @param integer $id Идентификатор страницы. * @param string $section Полный строковой идентификатор раздела. * @param integer $idsec=0 Числовой идентификатор раздела. * @return array */ function pages_getItem($id, $section, $idsec = 0) { static $cache = array(); if (isset($cache[$section][$id])) { return $cache[$section][$id]; } if ($row = A::$DB->getRow("SELECT * FROM {$section} WHERE id=?i AND active='Y'", $id)) { $row['link'] = pages_createItemLink($row['id'], $section); $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); prepareValues($section, $row); return $cache[$section][$id] = $row; } else { return $cache[$section][$id] = false; } }
/** * Обработчик действия: Импорт каталога. */ function Import() { @set_time_limit(0); require_once "Structures/DataGrid.php"; require_once "Structures/DataGrid/DataSource/Excel.php"; require_once "Structures/DataGrid/DataSource/CSV.php"; require_once 'Image/Transform.php'; mk_dir("files/" . DOMAIN . "/tmp"); clearDir("files/" . DOMAIN . "/tmp"); if (isset($_FILES['file']['tmp_name']) && file_exists($_FILES['file']['tmp_name'])) { $path_parts = pathinfo($_FILES['file']['name']); $ext = preg_replace("/[^a-z0-9]+/i", "", mb_strtolower($path_parts['extension'])); if ($ext == 'xls' || $ext == 'csv' || $ext == 'gz') { if ($ext == 'gz') { if (extractArchive($_FILES['file']['tmp_name'], "files/" . DOMAIN . "/tmp")) { $sourcefile1 = preg_replace("/tar\\.gz\$/i", "xls", $_FILES['file']['name']); $sourcefile2 = preg_replace("/tar\\.gz\$/i", "csv", $_FILES['file']['name']); if (is_file("files/" . DOMAIN . "/tmp/{$sourcefile1}")) { $sourcefile = "files/" . DOMAIN . "/tmp/{$sourcefile1}"; $ext = "xls"; } elseif (is_file("files/" . DOMAIN . "/tmp/{$sourcefile2}")) { $sourcefile = "files/" . DOMAIN . "/tmp/{$sourcefile2}"; $content = @file_get_contents($sourcefile); if ($content && !mb_check_encoding($content, 'UTF-8')) { file_put_contents($sourcefile, mb_convert_encoding($content, 'UTF-8', 'Windows-1251')); } $ext = "csv"; } else { return false; } } else { return false; } } elseif ($ext == 'csv') { $sourcefile = $_FILES['file']['tmp_name']; $content = @file_get_contents($sourcefile); if ($content && !mb_check_encoding($content, 'UTF-8')) { file_put_contents($sourcefile, mb_convert_encoding($content, 'UTF-8', 'Windows-1251')); } } else { $sourcefile = $_FILES['file']['tmp_name']; } if (!empty($_REQUEST['clear'])) { switch ($_REQUEST['clear']) { case 1: A::$DB->execute("TRUNCATE " . SECTION . "_categories"); case 2: A::$DB->execute("TRUNCATE " . SECTION . "_catalog"); A::$DB->execute("DELETE FROM " . DOMAIN . "_images WHERE idsec=" . SECTION_ID . " AND iditem>0"); A::$DB->execute("DELETE FROM " . DOMAIN . "_files WHERE idsec=" . SECTION_ID . " AND iditem>0"); A::$DB->execute("DELETE FROM " . DOMAIN . "_comments WHERE idsec=" . SECTION_ID); A_SearchEngine::getInstance()->deleteSection(SECTION_ID); break; } } A::$OPTIONS['imgpath'] = !empty(A::$OPTIONS['imgpath']) ? preg_replace("/[^a-zA-Z0-9-_\\/]/i", "", A::$OPTIONS['imgpath']) : "ifiles"; A::$OPTIONS['filepath'] = !empty(A::$OPTIONS['filepath']) ? preg_replace("/[^a-zA-Z0-9-_\\/]/i", "", A::$OPTIONS['filepath']) : "ifiles"; $categories = array(); $fields = array(); $cfiles = array(); A::$DB->query("SELECT * FROM " . SECTION . "_cols ORDER BY sort"); $i = 0; while ($row = A::$DB->fetchRow()) { if ($row['type'] == 'select' || $row['type'] == 'mselect') { if ($row['idvar'] = A::$DB->getOne("SELECT property FROM " . DOMAIN . "_fields WHERE item='" . SECTION . "' AND field='{$row['field']}'")) { if (isset($vars[$row['idvar']])) { $row['vars'] =& $vars[$row['idvar']]; } else { $row['vars'] = array(); $_vars = loadList($row['idvar']); foreach ($_vars as $key => $name) { $row['vars'][$key] = is_array($name) ? $name['name'] : $name; } $vars[$row['idvar']] =& $row['vars']; } } } $row['id'] = $i++; if (preg_match("/^category[0-9]{1}\$/i", $row['field'])) { $categories[$row['field']] = $row; } elseif ($row['type'] == 'image' || $row['type'] == 'file') { $cfiles[$row['field']] = $row; } else { $fields[$row['field']] = $row; } } A::$DB->free(); if ($ext == 'xls') { $datasource = new Structures_DataGrid_DataSource_Excel(); $datasource->bind($sourcefile); } elseif ($ext == 'csv') { $datasource = new Structures_DataGrid_DataSource_CSV(); $datasource->bind($sourcefile, array('delimiter' => ';', 'enclosure' => '"')); } else { return false; } $datagrid = new Structures_DataGrid(); $datagrid->bindDataSource($datasource); A::$DB->caching = false; $prevgoods = A::$DB->getCount(SECTION . "_catalog", "active='Y'"); $curgoods = 0; $arts = array(); $catn = array(); $catr = array(); $cats = array(); $i = 0; $gsort = A::$DB->getOne("SELECT MAX(sort) FROM " . SECTION . "_catalog") + 1; foreach ($datagrid->recordSet as $row) { $i++; if ($i == 1) { continue; } if (empty($row)) { continue; } if ($ext == 'xls') { $trow = array(); foreach ($row as $j => $value) { if (!empty($value)) { $trow[$j - 1] = $value; } } $row = $trow; } $idcat = 0; for ($j = 0; $j < 3; $j++) { if (isset($categories['category' . $j]) && !empty($row[$categories['category' . $j]['id']])) { if ($cname = strip_tags(trim($row[$categories['category' . $j]['id']]))) { $ch = md5($idcat . '|' . $cname); if (isset($catn[$ch])) { $idcat = $catn[$ch]; } elseif ($_idcat = A::$DB->getOne("SELECT id FROM " . SECTION . "_categories WHERE idker={$idcat} AND name=?", $cname)) { $idcat = $catn[$ch] = $_idcat; } else { if (!isset($catr[$idcat])) { $catr[$idcat] = A::$DB->getRowById($idcat, SECTION . "_categories"); } $category = array(); $category['name'] = $cname; $category['urlname'] = getURLName($cname); $category['idker'] = $idcat; $category['level'] = isset($catr[$idcat]['level']) ? $catr[$idcat]['level'] + 1 : 0; $category['sort'] = A::$DB->getOne("SELECT MAX(sort) FROM " . SECTION . "_categories WHERE idker={$idcat}") + 1; $idcat = $catn[$ch] = A::$DB->Insert(SECTION . "_categories", $category); } } } } if ($idcat == 0 && empty($row[$fields['art']['id']])) { continue; } $data = array(); $data['date'] = time(); if ($idcat > 0) { $data['idcat'] = $idcat; if (!isset($cats[$idcat])) { $cats[$idcat] = 1; } else { $cats[$idcat]++; } } $data['idcat1'] = 0; $data['idcat2'] = 0; foreach ($fields as $field => $frow) { if (!isset($_REQUEST['iempty']) || !empty($row[$frow['id']])) { switch ($frow['type']) { default: $data[$field] = !empty($row[$frow['id']]) ? trim($row[$frow['id']]) : ""; break; case 'int': $data[$field] = !empty($row[$frow['id']]) ? (int) $row[$frow['id']] : 0; break; case 'float': $data[$field] = !empty($row[$frow['id']]) ? (double) str_replace(',', '.', $row[$frow['id']]) : 0; break; case 'select': if (!empty($row[$frow['id']])) { if (isset($frow['vars'])) { $row[$frow['id']] = trim($row[$frow['id']]); $key = array_search($row[$frow['id']], $frow['vars']); if (empty($key) && !empty($row[$frow['id']])) { $key = addToList($frow['idvar'], $row[$frow['id']]); $fields[$field]['vars'][$key] = $frow['vars'][$key] = $row[$frow['id']]; } if (!empty($key)) { $data[$field] = $key; } } } break; case 'mselect': if (!empty($row[$frow['id']])) { if (isset($frow['vars'])) { $row[$frow['id']] = explode(',', $row[$frow['id']]); $data[$field] = array(); foreach ($row[$frow['id']] as $value) { $value = trim($value); $key = array_search($value, $frow['vars']); if (empty($key) && !empty($value)) { $key = addToList($frow['idvar'], $value); $fields[$field]['vars'][$key] = $frow['vars'][$key] = $value; } if (!empty($key)) { $data[$field][] = sprintf("%04d", $key); } } $data[$field] = implode(",", $data[$field]); } } break; case 'bool': $data[$field] = !empty($row[$frow['id']]) && $row[$frow['id']] != 'N' ? "Y" : "N"; break; } } } if (isset($data['name'])) { $data['name'] = strip_tags(trim($data['name'])); } if (!empty(A::$OPTIONS['idrule'])) { $_data = $data; prepareValues(SECTION, $_data); $litems = array(); $idrule = A::$OPTIONS['idrule']; $idrule = explode("+", $idrule); foreach ($idrule as $fname) { if (!empty($_data[$fname])) { $litems[] = getURLName($_data[$fname]); } } $data['urlname'] = implode(!empty($GLOBALS['A_URL_SEPARATOR']) ? $GLOBALS['A_URL_SEPARATOR'] : "_", $litems); } elseif (!empty($data['art'])) { $data['urlname'] = getURLName($data['art']); } if (empty($data['urlname'])) { $data['urlname'] = getURLName($data['name']); } if (!empty($data['content']) && empty($data['description'])) { $data['description'] = truncate($data['content'], A::$OPTIONS['anonslen']); } if (!empty($data['art'])) { $grow = A::$DB->getRow("SELECT id,mprices FROM " . SECTION . "_catalog WHERE art=? LIMIT 0,1", $data['art']); if (A::$OPTIONS['usecats']) { if (!empty($arts[$data['art']]) && !empty($data['idcat'])) { if ($arts[$data['art']] < 3) { $data['idcat' . $arts[$data['art']]] = $data['idcat']; unset($data['idcat']); } $arts[$data['art']]++; } else { $arts[$data['art']] = 1; } } } else { $grow = A::$DB->getRow("SELECT id,mprices FROM " . SECTION . "_catalog WHERE idcat=? AND name=? LIMIT 0,1", array($data['idcat'], $data['name'])); } if ($grow) { $id = $grow['id']; $mprices = !empty($grow['mprices']) ? unserialize($grow['mprices']) : array(); } else { $id = 0; } if ($id) { if (isset($fields['mprice']) && !empty($data['mprice'])) { $inm = false; foreach ($mprices as $mp) { if ($mp['name'] == trim($data['mprice'])) { $inm = true; break; } } if (!$inm) { $mprices[] = array('name' => $data['mprice'], 'price' => !empty($data['price']) ? $data['price'] : ''); } $data['mprices'] = serialize($mprices); unset($data['price']); $cats[$idcat]--; $curgoods--; } if (isset($data['mprice'])) { unset($data['mprice']); } A::$DB->Update(SECTION . "_catalog", $data, "id={$id}"); $images = A::$DB->getAssoc("SELECT sort,id,path FROM " . DOMAIN . "_images\r\r\n\t\t\tWHERE idsec=" . SECTION_ID . " AND iditem={$id}"); $images = array_values($images); $files = A::$DB->getAssoc("SELECT sort,id,path FROM " . DOMAIN . "_files\r\r\n\t\t\tWHERE idsec=" . SECTION_ID . " AND iditem={$id}"); $files = array_values($files); $curgoods++; } elseif (!empty($data['idcat'])) { if (isset($fields['mprice']) && !empty($data['mprice'])) { $mprices = array(array('name' => $data['mprice'], 'price' => !empty($data['price']) ? $data['price'] : '')); $data['mprices'] = serialize($mprices); } if (isset($data['mprice'])) { unset($data['mprice']); } if (empty($data['name'])) { continue; } $data['sort'] = $gsort++; $id = A::$DB->Insert(SECTION . "_catalog", $data); $images = array(); $files = array(); $curgoods++; } else { continue; } foreach ($cfiles as $field => $frow) { if (!empty($row[$frow['id']])) { switch ($frow['type']) { case 'image': $row[$frow['id']] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$frow['id']]); $path0 = A::$AUTH->isSuperAdmin() ? "ifiles/" . $row[$frow['id']] : ""; $path1 = "files/" . DOMAIN . "/" . A::$OPTIONS['imgpath'] . "/" . $row[$frow['id']]; $path2 = "files/" . DOMAIN . "/reg_images/" . $row[$frow['id']]; $path = is_file($path0) ? $path0 : (is_file($path1) ? $path1 : (is_file($path2) ? $path2 : "")); if ($path) { preg_match("/^idimg([0-9]+)\$/i", $field, $mathes); $sort = $mathes[1]; if (!isset($images[$sort]) || $images[$sort]['path'] != $path) { $image = array(); $image['path'] = $path; $image['name'] = basename($row[$frow['id']]); $image['mime'] = getMimeByFile($row[$frow['id']]); $image['caption'] = !empty($data['name']) ? $data['name'] : ""; $it = Image_Transform::factory('GD'); $it->load($path); $image['width'] = $it->img_x; $image['height'] = $it->img_y; $image['idsec'] = SECTION_ID; $image['iditem'] = $id; $image['sort'] = $sort; if (isset($images[$sort])) { A::$DB->Update(DOMAIN . "_images", $image, "id=" . $images[$sort]['id']); } else { A::$DB->Insert(DOMAIN . "_images", $image); } } } break; case 'file': $row[$frow['id']] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$frow['id']]); $path0 = A::$AUTH->isSuperAdmin() ? "ifiles/" . $row[$frow['id']] : ""; $path1 = "files/" . DOMAIN . "/" . A::$OPTIONS['filepath'] . "/" . $row[$frow['id']]; $path2 = "files/" . DOMAIN . "/reg_files/" . $row[$frow['id']]; $path = is_file($path0) ? $path0 : (is_file($path1) ? $path1 : (is_file($path2) ? $path2 : "")); if ($path) { preg_match("/^idfile([0-9]+)\$/i", $field, $mathes); $sort = $mathes[1]; if (!isset($files[$sort]) || $files[$sort]['path'] != $path) { $file = array(); $file['path'] = $path; $file['name'] = basename($row[$frow['id']]); $file['mime'] = getMimeByFile($row[$frow['id']]); $file['caption'] = !empty($data['name']) ? $data['name'] : ""; $file['idsec'] = SECTION_ID; $file['iditem'] = $id; $file['sort'] = $sort; $file['size'] = filesize($path); $file['dwnl'] = 0; if (isset($files[$sort])) { A::$DB->Update(DOMAIN . "_files", $file, "id=" . $files[$sort]['id']); } else { A::$DB->Insert(DOMAIN . "_files", $file); } } } break; } } } } if ($prevgoods > 0 && $prevgoods != $curgoods) { $this->updateCItems(); } else { A::$DB->Update(SECTION . "_categories", array('citems' => 0)); foreach ($cats as $id => $count) { A::$DB->Update(SECTION . "_categories", array('citems' => $count), "id={$id}"); } $this->updateCItems(0, true); } A::$CACHE->resetSection(SECTION); delDir("files/" . DOMAIN . "/tmp"); return true; } } return false; }
/** * Формирование данных доступных в шаблоне. */ function createData() { $this->supportCached(); $this->addCacheParam_Get('page'); if ($this->month == 0) { $this->month = date('m'); } if ($this->year == 0) { $this->year = date('Y'); } $checkeds = !empty(A::$OPTIONS['sections']) ? unserialize(A::$OPTIONS['sections']) : array(); $srows = $sections = array(); foreach ($checkeds as $idsec) { if ($srow = A::$DB->getRowById($idsec, DOMAIN . "_sections")) { $section = DOMAIN . "_" . $srow['lang'] . "_" . $srow['name']; $sections[$section] = $srow['module']; $srows[$section] = $srow; } } $calendar = new A_Calendar($sections); $this->Assign("calendar", $calendar->getMonthHTML($this->day, $this->month, $this->year)); if ($this->day > 0) { $date1 = mktime(0, 0, 0, $this->month, $this->day, $this->year); $date2 = mktime(23, 59, 59, $this->month, $this->day, $this->year); $this->Assign("date", $date1); } else { $date1 = mktime(0, 0, 0, $this->month, 1, $this->year); $date2 = mktime(0, 0, 0, $this->month + 1 > 12 ? 1 : $this->month + 1, 1, $this->month + 1 > 12 ? $this->year + 1 : $this->year) - 1; $this->Assign("date1", $date1); $this->Assign("date2", $date2); } $items = array(); foreach ($sections as $section => $module) { $srows[$section]['caption'] = $srows[$section]['caption_' . LANG]; $srows[$section]['link'] = getSectionLink($section); A::$DB->query("SELECT *,svote/cvote AS vote FROM {$section}_catalog WHERE date>={$date1} AND date<={$date2} AND active='Y' ORDER BY date"); while ($row = A::$DB->fetchRow()) { $row['section'] = $section; $items[] = $row; } A::$DB->free(); } $items = array_multisort_key($items, 'date'); $pager = new A_Pager(A::$OPTIONS['rows']); $items = $pager->setItems($items); foreach ($items as $i => $row) { $section = $row['section']; $row['section'] = $srows[$section]; $row['section_name'] = $srows[$section]['caption']; $row['section_link'] = $srows[$section]['link']; $row['link'] = catalog_createItemLink($row['id'], $section); $row['vote'] = round($row['vote'], 2); $row['category'] = getTreePath("{$section}_categories", $row['idcat']); $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array($srows[$section]['id'], $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array($srows[$section]['id'], $row['id'])); foreach ($row['files'] as $i => $data) { $row['files'][$i]['link'] = (LANG == DEFAULTLANG ? "" : "/" . LANG) . "/getfile/" . $data['id'] . "/" . $data['name']; $row['files'][$i]['size'] = sizestring($data['size']); } $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0; if (!empty($row['tags'])) { $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); } prepareValues($section, $row); $items[$i] = $row; } $this->Assign("items", $items); $this->Assign("items_pager", $pager); $this->AddNavigation(SECTION_NAME); }
/** * Формирование данных доступных в шаблоне детальной страницы материала. */ function ItemPage() { $this->supportCached(); if ($this->idcat > 0) { $this->category['link'] = catalog_createCategoryLink($this->category['id'], SECTION); if (A::$OPTIONS['usetags']) { $this->category['tags'] = A_SearchEngine::getInstance()->convertTags($this->category['tags']); } $this->category = A::$OBSERVER->Modifier('fcategory_prepareValues', SECTION, $this->category); $this->Assign("category", $this->category); } $itemdata = $this->itemdata; $itemdata['vote'] = $itemdata['cvote'] > 0 ? round($itemdata['svote'] / $itemdata['cvote'], 2) : 0; if (A::$OPTIONS['useimages']) { $itemdata['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $itemdata['id'])); $itemdata['idimg'] = isset($itemdata['images'][0]['id']) ? $itemdata['images'][0]['id'] : 0; } if (A::$OPTIONS['usefiles']) { $itemdata['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $this->iditem)); foreach ($itemdata['files'] as $i => $data) { $itemdata['files'][$i]['link'] = (LANG == DEFAULTLANG ? "" : "/" . LANG) . "/getfile/" . $data['id'] . "/" . $data['name']; $itemdata['files'][$i]['size'] = sizestring($data['size']); } $itemdata['idfile'] = isset($itemdata['files'][0]['id']) ? $itemdata['files'][0]['id'] : 0; } if (A::$OPTIONS['usetags']) { $itemdata['tags'] = A_SearchEngine::getInstance()->convertTags($itemdata['tags']); } prepareValues(SECTION, $itemdata); $itemdata = A::$OBSERVER->Modifier('catalog_prepareValues', SECTION, $itemdata); $this->Assign("item", $itemdata); if (A::$OPTIONS['usecomments']) { $comments = array(); A::$DB->query("SELECT * FROM " . DOMAIN . "_comments WHERE idsec=" . SECTION_ID . " AND iditem={$this->iditem} AND active='Y' ORDER BY date"); while ($row = A::$DB->fetchRow()) { if ($row['iduser'] > 0 && A::$AUTH->section) { if ($row['user'] = A::$DB->getRowById($row['iduser'], A::$AUTH->section)) { prepareValues(A::$AUTH->section, $row['user']); } } $comments[] = $row; } A::$DB->free(); $this->Assign("comments", $comments); $form = array(); $form['name'] = !empty($_REQUEST['name']) ? $_REQUEST['name'] : (A::$AUTH->isLogin() ? A::$AUTH->data['name'] : ""); $form['message'] = !empty($_REQUEST['message']) ? $_REQUEST['message'] : ""; $this->Assign("form", $form); $this->Assign("captcha", $captcha = substr(time(), rand(0, 6), 4)); A_Session::set("captcha", md5($captcha)); } if (A::$OPTIONS['usevote']) { $this->Assign("isvote", A_Session::get(SECTION . "_vote_" . $this->iditem, false)); $this->addCacheParam_Session(SECTION . "_vote_" . $this->iditem); } $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION)); if (isset($this->category)) { $this->AddNavCategories($this->category['id']); } $this->title = $this->itemdata['name'] . (!empty($this->title) ? " - " . $this->title : ""); if (!empty($this->itemdata['keywords'])) { $this->keywords = $this->itemdata['keywords']; } $this->description = $this->itemdata['description']; }
/** * Формирование данных доступных в шаблоне активного типа. */ function createData() { $this->supportCached(); prepareValues(SECTION, $this->pagedata); $this->pagedata['latname'] = $this->pagedata['urlname']; if (A::$OPTIONS['usetags']) { $this->pagedata['tags'] = A_SearchEngine::getInstance()->convertTags($this->pagedata['tags']); } $this->Assign_by_ref("page", $this->pagedata); $this->Assign_by_ref("content", $this->pagedata['content']); $this->Assign_by_ref("fullpath", $this->fullpath); if ($this->pagedata['level']) { if (SNAME != A::$OPTIONS['mainsection']) { $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION)); } if ($this->pagedata['idker']) { $this->AddNavPages($this->pagedata['idker'], $this->pagedata['urlname'] != "index"); } } elseif (SNAME != A::$OPTIONS['mainsection']) { if ($this->pagedata['urlname'] != 'index') { $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION)); } else { $this->AddNavigation(SECTION_NAME); } } if (!empty($this->pagedata['title'])) { $this->title = $this->pagedata['title']; } if (!(A::$OPTIONS['mainsection'] && count(A::$URIPARAMS) == 0)) { $this->title = $this->pagedata['name'] . (!empty($this->title) ? ' - ' . $this->title : ''); } $this->keywords = $this->pagedata['keywords']; $this->description = $this->pagedata['description']; }
/** * Формирование данных доступных в шаблоне. */ function createData() { static $useitems = array(); if ($this->params['sort'] != 5) { $this->supportCached(); } $this->params['idcat'] = (int) $this->params['idcat']; $this->params['rows'] = (int) $this->params['rows']; if ($this->params['idcat']) { $catrow = A::$DB->getRowById($this->params['idcat'], "{$this->section}_categories"); $catrow['link'] = catalog_createCategoryLink($this->params['idcat'], $this->section); $this->Assign("category", $catrow); } if ($this->section == SECTION && A::$MAINFRAME->iditem) { $useitems[$this->section][] = A::$MAINFRAME->iditem; } switch ($this->params['sort']) { default: case 1: $sort = "date DESC"; break; case 2: $sort = "date"; break; case 3: $sort = "name"; break; case 4: $sort = "sort"; break; case 5: $sort = "RAND()"; break; } $where = array(); if ($this->params['idcat']) { $idcat = $this->params['idcat']; $childcats = array($idcat); getTreeSubItems($this->section . "_categories", $idcat, $childcats); $where[] = "idcat IN(" . implode(",", $childcats) . ")"; } if (!empty($this->params['filter'])) { $where[] = $this->params['filter']; } if (!empty($useitems[$this->section]) && !empty($this->params['nodouble'])) { $where[] = "NOT id IN(" . implode(',', $useitems[$this->section]) . ")"; } $sql = "\r\r\n\tSELECT *,svote/cvote AS vote FROM {$this->section}_catalog\r\r\n\tWHERE active='Y'" . (!empty($where) ? " AND " . implode(" AND ", $where) : "") . "\r\r\n\tORDER BY {$sort}"; if ($this->params['rows']) { A::$DB->queryLimit($sql, 0, $this->params['rows']); } else { A::$DB->query($sql); } $items = array(); while ($row = A::$DB->fetchRow()) { $row['category'] = getTreePath($this->section . "_categories", $row['idcat']); $row['link'] = catalog_createItemLink($row['id'], $this->section); $row['vote'] = round($row['vote'], 2); if ($this->options['useimages']) { $row['images'] = A::$DB->getAll("\r\r\n\t SELECT * FROM " . getDomain($this->section) . "_images\r\r\n\t WHERE idsec=? AND iditem=? ORDER BY sort", array($this->section_id, $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; } if ($this->options['usefiles']) { $row['files'] = A::$DB->getAll("\r\r\n\t SELECT * FROM " . getDomain($this->section) . "_files\r\r\n\t WHERE idsec=? AND iditem=? ORDER BY sort", array($this->section_id, $row['id'])); foreach ($row['files'] as $i => $data) { $row['files'][$i]['link'] = (LANG == DEFAULTLANG ? "" : "/" . LANG) . "/getfile/" . $data['id'] . "/" . $data['name']; $row['files'][$i]['size'] = sizestring($data['size']); } $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0; } if ($this->options['usetags']) { $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); } prepareValues($this->section, $row); $row = A::$OBSERVER->Modifier('catalog_prepareValues', $this->section, $row); $useitems[$this->section][] = $row['id']; $items[] = $row; } A::$DB->free(); $this->Assign("items", $items); $this->Assign("items_count", count($items)); }
/** * Формирование данных доступных в шаблоне. */ function createData() { static $useitems = array(); if ($this->params['sort'] != 5) { $this->supportCached(); } $this->params['idcat'] = (int) $this->params['idcat']; $this->params['rows'] = (int) $this->params['rows']; if ($this->params['idcat']) { $catrow = A::$DB->getRowById($this->params['idcat'], "{$this->section}_categories"); $catrow['link'] = shoplite_createCategoryLink($this->params['idcat'], $this->section); $this->Assign("category", $catrow); } if ($this->section == SECTION && A::$MAINFRAME->iditem) { $useitems[] = A::$MAINFRAME->iditem; } if (!empty($this->params['mysort'])) { $sort = $this->params['mysort']; } else { switch ($this->params['sort']) { case 1: $sort = "name"; break; case 2: $sort = "price DESC"; break; case 3: $sort = "price"; break; case 4: $sort = "sort"; break; case 5: $sort = "RAND()"; break; } } $where = array(); if ($this->params['idcat']) { $idcat = $this->params['idcat']; $childcats = array($idcat); getTreeSubItems($this->section . "_categories", $idcat, $childcats); $where[] = "(idcat IN(" . implode(",", $childcats) . ") OR idcat1 IN(" . implode(",", $childcats) . ") OR idcat2 IN(" . implode(",", $childcats) . "))"; } switch ($this->params['filter']) { case 1: $where[] = "favorite='Y'"; break; case 2: $where[] = "new='Y'"; break; } if (!empty($this->params['myfilter'])) { $where[] = $this->params['myfilter']; } if ($useitems && !empty($this->params['nodouble'])) { $where[] = "NOT id IN(" . implode(',', $useitems) . ")"; } $sql = "\r\r\n\tSELECT * FROM {$this->section}_catalog\r\r\n\tWHERE active='Y'" . (!empty($where) ? " AND " . implode(" AND ", $where) : "") . "\r\r\n\tORDER BY {$sort}"; if ($this->params['rows']) { A::$DB->queryLimit($sql, 0, $this->params['rows']); } else { A::$DB->query($sql); } $items = array(); while ($row = A::$DB->fetchRow()) { if ($this->params['idcat'] == 0) { $row['category'] = getTreePath($this->section . "_categories", $row['idcat']); } $row['link'] = shoplite_createItemLink($row['id'], $this->section); $row['tobasketlink'] = getSectionLink($this->section) . "?action=addbasket&id=" . $row['id']; $row['vote'] = $row['cvote'] > 0 ? round($row['svote'] / $row['cvote'], 2) : 0; $row['available'] = $row['iscount'] > 0; if ($this->options['useimages']) { $row['images'] = A::$DB->getAll("\r\r\n\t SELECT * FROM " . getDomain($this->section) . "_images\r\r\n\t WHERE idsec=? AND iditem=? ORDER BY sort", array($this->section_id, $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; } if ($this->options['usefiles']) { $row['files'] = A::$DB->getAll("\r\r\n\t SELECT * FROM " . getDomain($this->section) . "_files\r\r\n\t WHERE idsec=? AND iditem=? ORDER BY sort", array($this->section_id, $row['id'])); foreach ($row['files'] as $i => $data) { $row['files'][$i]['link'] = (LANG == DEFAULTLANG ? "" : "/" . LANG) . "/getfile/" . $data['id'] . "/" . $data['name']; $row['files'][$i]['size'] = sizestring($data['size']); } $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0; } if ($this->options['modprices']) { $mprices = !empty($row['mprices']) ? unserialize($row['mprices']) : array(); $row['mprices'] = array(); foreach ($mprices as $i => $mp) { $row['mprices'][] = array('id' => $i, 'name' => $mp['name'], 'price' => $mp['price']); } } if ($this->options['usetags']) { $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); } prepareValues($this->section, $row); $row = A::$OBSERVER->Modifier('shoplite_prepareValues', $this->section, $row); $useitems[] = $row['id']; $items[] = $row; } A::$DB->free(); $this->Assign("items", $items); $this->Assign("items_count", count($items)); $this->Assign('valute', $this->options['valute']); }