/** * Индексация всех страниц в базу поиска по сайту. * * @param string $section Полный строковой идентификатор раздела. */ function pages_searchIndexAll($section) { $idsec = getSectionId($section); A::$DB->query("SELECT * FROM {$section} WHERE type='page'"); while ($row = A::$DB->fetchRow()) { $name = getTreePath($section, $row['level'] == 0 || $row['urlname'] != 'index' ? $row['id'] : $row['idker'], " - "); A_SearchEngine::getInstance()->updateIndex($idsec, $row['id'], $name, $row['content'], $row['tags']); } A::$DB->free(); }
/** * Формирование данных доступных в шаблоне. */ 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); }
/** * Получение полных данных записи каталога. * * @param integer $id Идентификатор материала. * @param string $section Полный строковой идентификатор раздела. * @param integer $idsec=0 Числовой идентификатор раздела. * @return array */ function catalog_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'] = catalog_createItemLink($row['id'], $section); $row['vote'] = round($row['vote'], 2); if ($row['idcat'] > 0) { $row['category'] = getTreePath("{$section}_categories", $row['idcat']); } $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('catalog_prepareValues', $section, $row); return $cache[$section][$id] = $row; } else { return $cache[$section][$id] = false; } }
/** * Формирование данных доступных в шаблоне страницы результатов поиска. */ function ResultPage() { if (!empty($_REQUEST['sort'])) { A_Session::set(SECTION . '_rsort', $_REQUEST['sort']); } if (!empty($_REQUEST['rows'])) { A_Session::set(SECTION . '_rrows', $_REQUEST['rows']); } $sort = escape_order_string(A_Session::get(SECTION . '_rsort', !empty(A::$OPTIONS['mysort']) ? A::$OPTIONS['mysort'] : A::$OPTIONS['sort'])); $rows = (int) A_Session::get(SECTION . '_rrows', A::$OPTIONS['rrows']); $this->Assign("rows", $rows); $this->Assign("sort", $sort); $_GET['filter'] = 1; $fields = array('name' => 'string', 'content' => 'string', 'tags' => 'string', 'art' => 'string', 'date' => 'int', 'price' => 'int', 'favorite' => 'bool', 'new' => 'bool'); $where = $this->frontfilter('', $fields); if (!empty($_GET['idcat'])) { if (is_array($_GET['idcat'])) { $where2 = array(); foreach ($_GET['idcat'] as $idcat) { if ($idcats = $this->childCategories((int) $idcat)) { $where2[] = "(idcat IN(" . implode(",", $idcats) . ") OR idcat1 IN(" . implode(",", $idcats) . ") OR idcat2 IN(" . implode(",", $idcats) . "))"; } } $where .= " AND (" . implode(" OR ", $where2) . ")"; } elseif (empty($this->idcat)) { if ($this->category = A::$DB->getRowById($_GET['idcat'], SECTION . "_categories")) { A::goUrl(shoplite_createCategoryLink($this->category['id'], SECTION) . 'result.html?' . getenv('QUERY_STRING')); } } } if ($this->category) { $this->category['link'] = shoplite_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); if ($idcats = $this->childCategories($this->idcat)) { $where .= " AND (idcat IN(" . implode(",", $idcats) . ") OR idcat1 IN(" . implode(",", $idcats) . ") OR idcat2 IN(" . implode(",", $idcats) . "))"; } } $items = array(); $pager = new A_Pager($rows); $pager->query("SELECT *,svote/cvote AS vote FROM " . SECTION . "_catalog WHERE active='Y'{$where} ORDER BY {$sort}"); while ($row = $pager->fetchRow()) { $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; if (A::$OPTIONS['useimages']) { $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; } if (A::$OPTIONS['usefiles']) { $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(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 (A::$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 (A::$OPTIONS['usetags']) { $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); } prepareValues(SECTION, $row); $row = A::$OBSERVER->Modifier('shoplite_prepareValues', SECTION, $row); $items[] = $row; } $this->Assign("items", $items); $this->Assign("items_pager", $pager); $data = $pars = array(); foreach ($_GET as $field => $value) { if (!empty($value)) { if (is_array($value)) { $p = array(); foreach ($value as $val) { $p[] = "{$field}[]=" . (int) $val; } $pars[$field] = implode("&", $p); $data[$field] = implode(",", $value); } else { $pars[$field] = "{$field}=" . urlencode($value); $data[$field] = $value; } } } prepareValues(SECTION, $data); $filters = array(); A::$DB->query("SELECT * FROM " . DOMAIN . "_fields WHERE item='" . SECTION . "' ORDER BY sort"); while ($row = A::$DB->fetchRow()) { if (!empty($data[$row['field']])) { $filters[] = array('field' => $row['field'], 'caption' => $row['name_' . A::$LANG], 'value' => $data[$row['field']], 'link' => getSectionLink(SECTION) . "result.html?" . $pars[$row['field']]); } } A::$DB->free(); $this->Assign("filters", $filters); $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION)); $this->AddNavCategories($this->idcat); }
/** * Формирование данных доступных в шаблоне страницы категории. */ function CategoryPage() { $this->supportCached(); $this->addCacheParam_Get('page'); if (A::$OPTIONS['usetags']) { $this->category['tags'] = A_SearchEngine::getInstance()->convertTags($this->category['tags']); } $this->Assign("category", $this->category); $categories = array(); A::$DB->query("SELECT * FROM " . SECTION . "_categories WHERE idker={$this->idcat} AND active='Y' ORDER BY sort"); while ($row = A::$DB->fetchRow()) { $row['link'] = gallery_createCategoryLink($row['id'], SECTION); $row['subcategories'] = array(); A::$DB->query("SELECT * FROM " . SECTION . "_categories WHERE idker={$row['id']} AND active='Y' ORDER BY sort"); while ($subrow = A::$DB->fetchRow()) { $subrow['link'] = gallery_createCategoryLink($subrow['id'], SECTION); $row['subcategories'][] = $subrow; } A::$DB->free(); $categories[] = $row; } A::$DB->free(); $this->Assign("categories", $categories); $rows = (int) (!empty($_GET['rows'])) ? (int) $_GET['rows'] : A::$OPTIONS['crows']; $irows = (int) (!empty($_GET['irows'])) ? (int) $_GET['irows'] : A::$OPTIONS['irows']; $sort = escape_order_string(!empty(A::$OPTIONS['mysort']) ? A::$OPTIONS['mysort'] : A::$OPTIONS['sort']); $this->Assign("rows", $rows); $this->Assign("irows", $irows); $this->Assign("sort", $sort); $where = $this->frontfilter(); $albums = array(); $pager = new A_Pager($rows); $pager->query("SELECT *,svote/cvote AS vote FROM " . SECTION . "_albums\tWHERE idcat={$this->idcat} AND active='Y'{$where} ORDER BY {$sort}"); while ($row = $pager->fetchRow()) { $row['link'] = gallery_createItemLink($row['id'], SECTION); $row['category'] = getTreePath(SECTION . "_categories", $row['idcat']); $row['vote'] = round($row['vote'], 2); $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id'])); if (A::$OPTIONS['usetags']) { $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); } prepareValues(SECTION, $row); $row = A::$OBSERVER->Modifier('gallery_prepareValues', SECTION, $row); $albums[] = $row; } $pager->free(); $this->Assign("albums", $albums); $this->Assign("albums_pager", $pager); $pager = new A_Pager($irows); $images = $pager->setItems(!empty($albums) ? $albums[0]['images'] : array()); $this->Assign("images", $images); $this->Assign("images_pager", $pager); $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION)); $this->AddNavCategories($this->category['idker']); $this->title = $this->category['name'] . (!empty($this->title) ? " - " . $this->title : ""); $this->description = $this->category['description']; }
/** * Формирование данных доступных в шаблоне. */ function createData() { if (!A_Session::is_set(SECTION . "_filter")) { $this->unFilter(); } $fields = A::$DB->getFields(SECTION . "_orders"); if (!in_array('pay', $fields)) { A::$DB->execute("ALTER TABLE `" . SECTION . "_orders` ADD `pay` int(11) NOT NULL default '0'"); } $categories = A::$DB->getAll("SELECT id,idker,name FROM " . SECTION . "_categories ORDER BY level,sort"); $this->Assign("categories", $categories); if (!empty($_GET['idcat'])) { $this->Assign("category", A::$DB->getRowById($_GET['idcat'], SECTION . "_categories")); $idcat = (int) $_GET['idcat']; $childcats = array($idcat); getTreeSubItems(SECTION . "_categories", $idcat, $childcats); $where = "(c.idcat IN(" . implode(",", $childcats) . ") OR c.idcat1 IN(" . implode(",", $childcats) . ") OR c.idcat2 IN(" . implode(",", $childcats) . "))"; $this->Assign("childcats", $childcats = count($childcats)); } else { $where = ""; } if ($filter = $this->getFilter()) { $where = !empty($where) ? "{$where} AND {$filter}" : $filter; } $this->Assign("treebox", new A_CategoriesTree("items")); $rows = A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 20); $sort = escape_order_string(A_Session::get(SECTION . "_sort", isset($_COOKIE[SECTION . '_sort']) ? $_COOKIE[SECTION . '_sort'] : A::$OPTIONS['sort'])); $items = array(); $pager = new A_Pager($rows); $pager->tab = "items"; $pager->query("\r\r\n\tSELECT c.*,c.svote/c.cvote AS vote,cc.name AS category\r\r\n\tFROM " . SECTION . "_catalog AS c\r\r\n\tLEFT JOIN " . SECTION . "_categories AS cc ON cc.id=c.idcat\r\r\n\t" . (!empty($where) ? " WHERE {$where}" : "") . "\r\r\n\tORDER BY {$sort}"); while ($row = $pager->fetchRow()) { $row['link'] = shoplite_createItemLink($row['id'], SECTION); $row['catpath'] = ""; if (empty($_GET['idcat']) || $childcats > 1) { $row['catpath'] .= getTreePath(SECTION . "_categories", $row['idcat']); } if (!empty($row['idcat1'])) { $row['catpath'] .= '<br>' . getTreePath(SECTION . "_categories", $row['idcat1']); } if (!empty($row['idcat2'])) { $row['catpath'] .= '<br>' . getTreePath(SECTION . "_categories", $row['idcat2']); } $row['vote'] = round($row['vote'], 2); if (A::$OPTIONS['useimages']) { $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; } if (A::$OPTIONS['usefiles']) { $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id'])); $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0; } $items[] = $row; } $pager->free(); $this->Assign("items", $items); $this->Assign("items_pager", $pager); $this->Assign("rows", $rows); $this->Assign("sort", $sort); $this->Assign("filter", !empty($filter)); if (A::$OPTIONS['usecomments']) { $this->Assign("commbox", new A_CommentsEditor(SECTION . "_catalog")); } $rows = (int) A_Session::get(SECTION . "_rows2", 20); $idpays = A::$DB->getCol("SELECT DISTINCT pay FROM " . SECTION . "_orders ORDER BY pay"); $pays = array(); foreach ($idpays as $idpay) { $pays[$idpay] = function_exists('pay_getname') ? pay_getname($idpay) : "Наличные"; } $pays = array_unique($pays); $this->Assign("pays", $pays); $where = array(); if (isset($_GET['date'])) { if (!empty($_GET['from'])) { $where[] = "date>=" . (int) $_GET['from']; } if (!empty($_GET['to'])) { $where[] = "date<=" . (int) $_GET['to']; } } if (!empty($_GET['sum1'])) { $where[] = "sum>=" . (int) $_GET['sum1']; } if (!empty($_GET['sum2'])) { $where[] = "sum<=" . (int) $_GET['sum2']; } if (isset($_GET['status']) && $_GET['status'] >= 0) { $where[] = "status=" . (int) $_GET['status']; } if (isset($_GET['pay']) && $_GET['pay'] >= 0) { $where[] = "pay=" . (int) $_GET['pay']; } $where = implode(" AND ", $where); $orders = array(); $pager2 = new A_Pager($rows); $pager2->tab = "orders"; $pager2->query("SELECT * FROM " . SECTION . "_orders " . ($where ? "WHERE {$where}" : "") . " ORDER BY status,date DESC"); while ($row = $pager2->fetchRow()) { $row['pay'] = function_exists('pay_getname') ? pay_getname($row['pay']) : "Наличные"; $row['sum'] = round($row['sum'], 2); $orders[] = $row; } $pager2->free(); $this->Assign("orders", $orders); $this->Assign("orders_pager", $pager2); $this->Assign("rows2", $rows); $this->Assign("optbox1", new A_OptionsBox("Внешний вид на сайте:", array("idgroup" => 1))); $this->Assign("optbox2", new A_OptionsBox("Файлы:", array("idgroup" => 2))); $this->Assign("optbox3", new A_OptionsBox("Заказ:", array("idgroup" => 3))); $this->Assign("optbox4", new A_OptionsBox("Комментирование и голосование:", array("idgroup" => 4))); $this->Assign("optbox5", new A_OptionsBox("Дополнительно:", array("idgroup" => 5))); $this->Assign("fieldsbox", new A_FieldsEditor(SECTION . "_catalog", array('tab' => 'opt', 'tab_opt' => 'fields'), false, true)); $types = array('string' => 'Строка', 'int' => 'Целое число', 'float' => 'Дробное число', 'bool' => 'Логический (Да/Нет)', 'text' => 'Текст', 'select' => 'Значение из списка', 'mselect' => 'Множество значений из списка', 'mprice' => 'Модификатор цены', 'image' => 'Изображение', 'file' => 'Файл'); $nums = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); $cols = array(); A::$DB->query("SELECT * FROM " . SECTION . "_cols ORDER BY sort"); while ($row = A::$DB->fetchRow()) { $row['num'] = array_shift($nums); $row['type'] = isset($types[$row['type']]) ? $types[$row['type']] : $row['type']; $cols[] = $row; } A::$DB->free(); $this->Assign("cols", $cols); }
function breadcrumb($atts) { global $pretext, $sitename; extract(lAtts(array('wraptag' => 'p', 'sep' => ' » ', 'separator' => ' » ', 'link' => 1, 'label' => $sitename, 'title' => '', 'class' => '', 'linkclass' => ''), $atts)); if (isset($atts['sep'])) { $separator = $sep; trigger_error(gTxt('deprecated_attribute', array('{name}' => 'sep')), E_USER_NOTICE); } // bc, get rid of in crockery if ($link == 'y') { $linked = true; } elseif ($link == 'n') { $linked = false; } else { $linked = $link; } $label = txpspecialchars($label); if ($linked) { $label = doTag($label, 'a', $linkclass, ' href="' . hu . '"'); } $content = array(); extract($pretext); if (!empty($s) && $s != 'default') { $section_title = $title ? fetch_section_title($s) : $s; $section_title_html = escape_title($section_title); $content[] = $linked ? doTag($section_title_html, 'a', $linkclass, ' href="' . pagelinkurl(array('s' => $s)) . '"') : $section_title_html; } $category = empty($c) ? '' : $c; foreach (getTreePath($category, 'article') as $cat) { if ($cat['name'] != 'root') { $category_title_html = $title ? escape_title($cat['title']) : $cat['name']; $content[] = $linked ? doTag($category_title_html, 'a', $linkclass, ' href="' . pagelinkurl(array('c' => $cat['name'])) . '"') : $category_title_html; } } // add the label at the end, to prevent breadcrumb for home page if ($content) { $content = array_merge(array($label), $content); return doTag(join($separator, $content), $wraptag, $class); } }
/** * Формирование данных доступных в шаблоне. */ 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 breadcrumb($atts) { global $pretext, $thisarticle, $sitename; extract(lAtts(array('wraptag' => 'p', 'sep' => ' » ', 'link' => 'y', 'label' => $sitename, 'title' => '', 'class' => '', 'linkclass' => 'noline'), $atts)); $linked = $link == 'y' ? true : false; if ($linked) { $label = doTag($label, 'a', $linkclass, ' href="' . hu . '"'); } $content = array(); extract($pretext); if (!empty($s) && $s != 'default') { $section_title = $title ? fetch_section_title($s) : $s; $section_title_html = escape_title($section_title); $content[] = $linked ? doTag($section_title_html, 'a', $linkclass, ' href="' . pagelinkurl(array('s' => $s)) . '"') : $section_title_html; } $category = empty($c) ? '' : $c; foreach (getTreePath($category, 'article') as $cat) { if ($cat['name'] != 'root') { $category_title_html = $title ? escape_title($cat['title']) : $cat['name']; $content[] = $linked ? doTag($category_title_html, 'a', $linkclass, ' href="' . pagelinkurl(array('c' => $cat['name'])) . '"') : $category_title_html; } } //Add the label at the end, to prevent breadcrumb for home page if (!empty($content)) { $content = array_merge(array($label), $content); } //Add article title without link if we're on an individual archive page? return doTag(join($sep, $content), $wraptag, $class); }
/** * Формирование данных доступных в шаблоне страницы категории. */ function CategoryPage() { if (empty($_GET['filter'])) { $this->supportCached(); $this->addCacheParam_Get('filter'); $this->addCacheParam_Get('page'); } 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); $categories = array(); A::$DB->query("SELECT * FROM " . SECTION . "_categories WHERE idker={$this->idcat} AND active='Y' ORDER BY sort"); while ($row = A::$DB->fetchRow()) { $row['link'] = catalog_createCategoryLink($row['id'], SECTION); $row['subcategories'] = array(); A::$DB->query("SELECT * FROM " . SECTION . "_categories WHERE idker={$row['id']} AND active='Y' ORDER BY sort"); while ($subrow = A::$DB->fetchRow()) { $subrow['link'] = catalog_createCategoryLink($subrow['id'], SECTION); $row['subcategories'][] = $subrow; } A::$DB->free(); $categories[] = $row; } A::$DB->free(); $this->Assign("categories", $categories); if (!empty($_REQUEST['sort'])) { A_Session::set(SECTION . '_csort', $_REQUEST['sort']); } if (!empty($_REQUEST['rows'])) { A_Session::set(SECTION . '_crows', $_REQUEST['rows']); } $sort = escape_order_string(A_Session::get(SECTION . '_csort', !empty(A::$OPTIONS['mysort']) ? A::$OPTIONS['mysort'] : A::$OPTIONS['sort'])); $rows = (int) A_Session::get(SECTION . '_crows', A::$OPTIONS['crows']); $this->Assign("rows", $rows); $this->Assign("sort", $sort); $where = $this->frontfilter(); $items = array(); $pager = new A_Pager($rows); $pager->query("SELECT *,svote/cvote AS vote FROM " . SECTION . "_catalog WHERE idcat={$this->idcat} AND active='Y'{$where} ORDER BY {$sort}"); while ($row = $pager->fetchRow()) { $row['link'] = catalog_createItemLink($row['id'], SECTION); $row['category'] = getTreePath(SECTION . "_categories", $row['idcat']); $row['vote'] = round($row['vote'], 2); if (A::$OPTIONS['useimages']) { $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; } if (A::$OPTIONS['usefiles']) { $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(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 (A::$OPTIONS['usetags']) { $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); } prepareValues(SECTION, $row); $row = A::$OBSERVER->Modifier('catalog_prepareValues', SECTION, $row); $items[] = $row; } $pager->free(); $this->Assign("items", $items); $this->Assign("items_pager", $pager); $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION)); $this->AddNavCategories($this->category['idker']); $this->AddNavigation($this->category['name']); $this->title = $this->category['name'] . (!empty($this->title) ? " - " . $this->title : ""); $this->description = $this->category['description']; }
/** * Обработчик действия: Перемещение страницы или подраздела. * * @param integer $id=0 Идентификатор элемента. */ function Move($id = 0) { if ($id > 0) { $_REQUEST['id'] = $id; } if (empty($_REQUEST['id'])) { return false; } $row = A::$DB->getRowById($_REQUEST['id'], SECTION); if (!$row || $_REQUEST['id'] == $_REQUEST['idto']) { return false; } $update = array(); if (!empty($_REQUEST['idto'])) { $update['level'] = A::$DB->getOne("SELECT level FROM " . SECTION . " WHERE id=" . (int) $_REQUEST['idto']) + 1; } else { $update['level'] = 0; } $update['idker'] = (int) $_REQUEST['idto']; $update['sort'] = A::$DB->getOne("SELECT MAX(sort) FROM " . SECTION . " WHERE idker=" . (int) $_REQUEST['idto']) + 1; $update['urlname'] = getURLName($row['name'], $row['urlname'], SECTION, "idker=" . (int) $_REQUEST['idto']); A::$DB->Update(SECTION, $update, "id=" . $row['id']); $this->ReLevels($row['id'], $update['level'] + 1); $name = getTreePath(SECTION, $row['level'] == 0 || $row['urlname'] != 'index' ? $row['id'] : $row['idker'], " - "); if ($row['active'] == 'Y') { A::$OBSERVER->Event('searchIndexUpdate', SECTION, array('id' => $row['id'], 'name' => $name, 'content' => $row['content'], 'tags' => $row['tags'])); } return true; }
/** * Обработчик действия: Сохранение страницы. */ function applyPage() { $this->RESULT['result'] = false; $row = A::$DB->getRowById($_REQUEST['id'], SECTION); if (!$row) { return false; } $_REQUEST['date'] = time(); $_REQUEST['name'] = strip_tags($_REQUEST['name']); $_REQUEST['urlname'] = getURLName($_REQUEST['name'], $_REQUEST['urlname'], SECTION, "type='page' AND idker={$row['idker']} AND id<>" . $row['id']); $_REQUEST['keywords'] = getkeywords($_REQUEST['content']); $_REQUEST['description'] = truncate($_REQUEST['content'], 350); $_REQUEST['active'] = isset($_REQUEST['active']) ? 'Y' : 'N'; $_REQUEST['inmap'] = isset($_REQUEST['inmap']) ? 'Y' : 'N'; $dataset = new A_DataSet(SECTION, true); $dataset->fields = array("date", "name", "urlname", "keywords", "description", "content", "tags", "active", "inmap"); $_REQUEST["template"] = preg_replace("/[^a-zA-Z0-9._-]+/i", "", $_REQUEST["template"]); $dataset->fields[] = 'template'; if ($row = $dataset->Update()) { $name = getTreePath(SECTION, $row['level'] == 0 || $row['urlname'] != 'index' ? $row['id'] : $row['idker'], " - "); A::$OBSERVER->Event('searchIndexUpdate', SECTION, array('id' => $row['id'], 'name' => $name, 'content' => $_REQUEST['content'], 'tags' => $_REQUEST['tags'])); if (!empty($_REQUEST["template"])) { copyfile("modules/pages/templates/default/pages_page.tpl", "templates/" . DOMAIN . "/" . $_REQUEST["template"]); } while ($row['idker']) { if ($row = A::$DB->getRowById($row['idker'], SECTION)) { A::$DB->Update(SECTION, array('date' => $_REQUEST['date']), "id=" . $row['id']); } } $this->RESULT['date'] = date("d.m.Y H:i", $_REQUEST['date']) . " "; $this->RESULT['result'] = true; return true; } }
/** * Формирование данных доступных в шаблоне. */ function createData() { if (!A_Session::is_set(SECTION . "_filter")) { $this->unFilter(); } $categories = A::$DB->getAll("SELECT id,idker,name FROM " . SECTION . "_categories ORDER BY level,sort"); $this->Assign("categories", $categories); if (!empty($_GET['idcat'])) { $this->Assign("category", A::$DB->getRowById($_GET['idcat'], SECTION . "_categories")); $idcat = (int) $_GET['idcat']; $childcats = array($idcat); getTreeSubItems(SECTION . "_categories", $idcat, $childcats); $where = "c.idcat IN(" . implode(",", $childcats) . ")"; $this->Assign("childcats", $childcats = count($childcats)); } else { $where = ""; } if ($filter = $this->getFilter()) { $where = !empty($where) ? "{$where} AND {$filter}" : $filter; } $rows = (int) A_Session::get(SECTION . "_rows", isset($_COOKIE[SECTION . '_rows']) ? $_COOKIE[SECTION . '_rows'] : 10); $sort = escape_order_string(A_Session::get(SECTION . "_sort", isset($_COOKIE[SECTION . '_sort']) ? $_COOKIE[SECTION . '_sort'] : A::$OPTIONS['sort'])); $items = array(); $pager = new A_Pager($rows); $pager->tab = "items"; $pager->query("\r\r\n\tSELECT c.*,c.svote/c.cvote AS vote,cc.name AS category\r\r\n\tFROM " . SECTION . "_catalog AS c\r\r\n\tLEFT JOIN " . SECTION . "_categories AS cc ON cc.id=c.idcat\r\r\n\t" . (!empty($where) ? " WHERE {$where}" : "") . "\r\r\n\tORDER BY {$sort}"); while ($row = $pager->fetchRow()) { $row['link'] = catalog_createItemLink($row['id'], SECTION); $row['vote'] = round($row['vote'], 2); if (A::$OPTIONS['useimages']) { $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id'])); $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0; } if (A::$OPTIONS['usefiles']) { $row['files'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_files WHERE idsec=? AND iditem=? ORDER BY sort", array(SECTION_ID, $row['id'])); $row['idfile'] = isset($row['files'][0]['id']) ? $row['files'][0]['id'] : 0; } $row['tags'] = A_SearchEngine::getInstance()->convertTags($row['tags']); if (empty($_GET['idcat']) || $childcats > 1) { $row['catpath'] = getTreePath(SECTION . "_categories", $row['idcat']); } $items[] = $row; } $pager->free(); $this->Assign("items", $items); $this->Assign("items_pager", $pager); $this->Assign("treebox", new A_CategoriesTree("items")); if (A::$OPTIONS['usecomments']) { $this->Assign("commbox", new A_CommentsEditor(SECTION . "_catalog")); } $this->Assign("optbox1", new A_OptionsBox("Внешний вид на сайте:", array('idgroup' => 1))); $this->Assign("optbox2", new A_OptionsBox("Файлы:", array('idgroup' => 2))); $this->Assign("optbox3", new A_OptionsBox("Комментирование и голосование:", array('idgroup' => 3))); $this->Assign("optbox4", new A_OptionsBox("Дополнительно:", array('idgroup' => 4))); $this->Assign("fieldsbox", new A_FieldsEditor(SECTION . "_catalog", array('tab' => 'opt', 'tab_opt' => 'fields'), false, true)); $this->Assign("rows", $rows); $this->Assign("sort", $sort); $this->Assign("filter", !empty($filter)); }
/** * Формирование данных доступных в шаблоне. */ 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']); }