Exemple #1
0
/**
 * Интеграция в карту сайта.
 *
 * @param object &$treemap Объект дерева карты сайта.
 * @param string $section Полный строковой идентификатор раздела.
 * @param string $caption Название раздела.
 */
function pages_createMap(&$treemap, $section, $caption = "")
{
    if (A::$OPTIONS['mainsection'] == getName($section)) {
        pages_createSubMap($treemap, $section, $caption, 0, true);
    } else {
        $treemap->items[$section] = new SiteMap_Box($caption, getSectionLink($section));
        pages_createSubMap($treemap->items[$section], $section, $caption);
    }
}
Exemple #2
0
 /**
  * Формирование ссылки для выбора дня.
  *
  * @param integer $day Номер дня.
  * @param integer $month Номер месяца.
  * @param integer $year Номер года.
  * @return string
  */
 function getDateLink($day, $month, $year)
 {
     $date1 = mktime(0, 0, 0, $month, $day, $year);
     $date2 = mktime(23, 59, 59, $month, $day, $year);
     $count = 0;
     foreach ($this->sections as $section => $module) {
         if ($module == 'catalog') {
             $count += A::$DB->getOne("SELECT COUNT(*) FROM {$section}_{$module} WHERE date>={$date1} AND date<={$date2} AND active='Y'");
         }
     }
     if ($count > 0) {
         $link = getSectionLink(!empty($this->section) ? $this->section : SECTION) . sprintf('%02d', $day) . '-' . sprintf('%02d', $month) . '-' . $year . '.html';
     } else {
         $link = "";
     }
     return $link;
 }
Exemple #3
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 function createData()
 {
     $items = array();
     $pager = new A_Pager(A::$OPTIONS['rows']);
     if (!empty($_GET['idsec'])) {
         if (is_array($_GET['idsec'])) {
             foreach ($_GET['idsec'] as $i => $id) {
                 $idsec[$i] = (int) $id;
             }
         } else {
             $idsec = array((int) $_GET['idsec']);
         }
     }
     $imodules = array('feedback');
     if (!empty($_GET['query'])) {
         $_GET['query'] = mb_substr($_GET['query'], 0, 50);
         $stems = $_stems = array();
         $words = $_words = array();
         $query = explode(" ", $_GET['query']);
         foreach ($query as $word) {
             if (mb_strlen($word) > 2) {
                 $word = mb_strtolower($word);
                 $words[] = $word;
                 $_words[] = empty($_words) ? "+>{$word}" : ">{$word}";
                 if ($stem = A_SearchEngine::getInstance()->getStem($word)) {
                     if (mb_strlen($stem) > 3) {
                         $stems[] = $stem;
                         $_stems[] = empty($_stems) ? "+<{$stem}" : "<{$stem}";
                     }
                 }
             }
         }
         $_words = A::$DB->real_escape_string(implode(" ", $_words));
         $_stems = A::$DB->real_escape_string(implode(" ", $_stems));
         if (!empty($_words)) {
             $pager->query("\r\r\n\t    SELECT `date`,`idsec`,`iditem`,`name`,`content`,`idtags`,\r\r\n\t    MATCH(`name`) AGAINST('{$_words}')+MATCH(`content`) AGAINST('{$_words}')+MATCH(`stems`) AGAINST('{$_stems}') AS relevant\r\r\n\t    FROM " . SECTION . "\r\r\n\t    WHERE " . (!empty($idsec) ? "idsec IN(" . implode(",", $idsec) . ") AND " : "") . "\r\r\n\t    ( MATCH(`name`) AGAINST ('{$_words}' IN BOOLEAN MODE)\r\r\n\t      OR\r\r\n\t\t  MATCH(`content`) AGAINST ('{$_words}' IN BOOLEAN MODE)\r\r\n\t\t  OR\r\r\n\t\t  MATCH(`stems`) AGAINST ('{$_stems}' IN BOOLEAN MODE)\r\r\n\t    )\r\r\n\t    ORDER BY `relevant` DESC, `date` DESC");
             while ($row = $pager->fetchRow()) {
                 $row['num'] = $pager->begin + count($items);
                 $row['description'] = A_SearchEngine::getInstance()->getFindedText($words, $stems, $row['content']);
                 if ($srow = A::$DB->getRowById($row['idsec'], DOMAIN . "_sections")) {
                     $section = DOMAIN . '_' . $srow['lang'] . '_' . $srow['name'];
                     if (!empty($row['name']) && !in_array($srow['module'], $imodules)) {
                         if (!empty($srow['caption_' . LANG])) {
                             $row['name'] = $srow['caption_' . LANG] . " - " . $row['name'];
                         }
                     } else {
                         $row['name'] = $srow['caption_' . LANG];
                     }
                     if ($row['iditem'] > 0) {
                         $row['link'] = function_exists($srow['module'] . '_createItemLink') ? call_user_func($srow['module'] . '_createItemLink', $row['iditem'], $section) : getSectionLink($section);
                     } else {
                         $row['link'] = function_exists($srow['module'] . '_createCategoryLink') ? call_user_func($srow['module'] . '_createCategoryLink', -$row['iditem'], $section) : getSectionLink($section);
                     }
                     $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array($row['idsec'], $row['iditem']));
                     $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
                     $row['tags'] = A_SearchEngine::getInstance()->getTags($row['idtags']);
                     $items[] = $row;
                 }
             }
             $pager->free();
         }
     } elseif (!empty($_GET['tag'])) {
         if ($_GET['tag'] = mb_substr(mb_strtolower(trim($_GET['tag'])), 0, 50)) {
             if ($idtag = A::$DB->getOne("SELECT id FROM " . SECTION . "_tags WHERE tag=?", $_GET['tag'])) {
                 $idtag = sprintf("%04d", $idtag);
                 $pager->query("\r\r\n\t    SELECT `date`,`idsec`,`iditem`,`name`,`content`,`idtags`\r\r\n\t    FROM " . SECTION . "\r\r\n\t    WHERE " . (!empty($idsec) ? "idsec IN(" . implode(",", $idsec) . ") AND " : "") . "\r\r\n\t    MATCH(`idtags`) AGAINST ('{$idtag}' IN BOOLEAN MODE)\r\r\n\t    ORDER BY `date` DESC");
                 while ($row = $pager->fetchRow()) {
                     $row['num'] = $pager->begin + count($items);
                     $row['description'] = truncate($row['content'], 350);
                     if ($srow = A::$DB->getRowById($row['idsec'], DOMAIN . "_sections")) {
                         $section = DOMAIN . '_' . $srow['lang'] . '_' . $srow['name'];
                         if (!empty($row['name']) && !in_array($srow['module'], $imodules)) {
                             if (!empty($srow['caption_' . LANG])) {
                                 $row['name'] = $srow['caption_' . LANG] . " - " . $row['name'];
                             }
                         } else {
                             $row['name'] = $srow['caption_' . LANG];
                         }
                         if ($row['iditem'] > 0) {
                             $row['link'] = function_exists($srow['module'] . '_createItemLink') ? call_user_func($srow['module'] . '_createItemLink', $row['iditem'], $section) : getSectionLink($section);
                         } else {
                             $row['link'] = function_exists($srow['module'] . '_createCategoryLink') ? call_user_func($srow['module'] . '_createCategoryLink', -$row['iditem'], $section) : getSectionLink($section);
                         }
                         $row['images'] = A::$DB->getAll("SELECT * FROM " . DOMAIN . "_images WHERE idsec=? AND iditem=? ORDER BY sort", array($row['idsec'], $row['iditem']));
                         $row['idimg'] = isset($row['images'][0]['id']) ? $row['images'][0]['id'] : 0;
                         $row['tags'] = A_SearchEngine::getInstance()->getTags($row['idtags']);
                         $items[] = $row;
                     }
                 }
                 $pager->free();
             }
         }
     }
     $this->Assign("items", $items);
     $this->Assign("items_pager", $pager);
     $this->Assign("sections", A_SearchEngine::getInstance()->getSections());
     $this->AddNavigation(SECTION_NAME);
 }
Exemple #4
0
/**
 * Интеграция в карту сайта.
 *
 * @param object &$treemap Объект дерева карты сайта.
 * @param string $section Полный строковой идентификатор раздела.
 * @param string $caption Название раздела.
 */
function catalog_createMap(&$treemap, $section, $caption)
{
    $treemap->items[$section] = new SiteMap_Box($caption, getSectionLink($section));
    catalog_createMap_Categories($treemap->items[$section], $section);
}
Exemple #5
0
 /**
  * Формирование данных доступных в шаблоне страницы "мои заказы".
  */
 function MyOrdersPage()
 {
     if (!A::$AUTH->isLogin()) {
         A::goUrl(getSectionLink(SECTION));
     }
     $orders = array();
     $pager = new A_Pager(20);
     $pager->tab = "orders";
     $pager->query("SELECT * FROM " . SECTION . "_orders WHERE iduser=? ORDER BY date DESC", A::$AUTH->id);
     while ($row = $pager->fetchRow()) {
         if ($section = getSectionByModule('robopay')) {
             $row['paylink'] = getSectionLink($section) . "?action=pay&code=" . md5($section . $row['date']);
         }
         $row['pay'] = function_exists('pay_getname') ? pay_getname($row['pay']) : "Наличные";
         $row['basket'] = !empty($row['basket']) ? unserialize($row['basket']) : array();
         $row['sum'] = round($row['sum'], 2);
         $orders[] = $row;
     }
     $pager->free();
     $this->Assign("orders", $orders);
     $this->Assign("orders_pager", $pager);
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
 }
Exemple #6
0
    $section = DOMAIN . "_" . $srow['lang'] . "_" . $srow['name'];
    $idsec = $srow['id'];
    $idcat = !empty($_GET['idcat']) ? (int) $_GET['idcat'] : 0;
} else {
    $idsec = 0;
    $idcat = 0;
}
$rssrow = A::$DB->getRow("SELECT * FROM " . STRUCTURE . " WHERE idsec={$idsec} AND idcat={$idcat}");
if (!$rssrow) {
    die;
}
require_once "modules/catalog/include.php";
require_once 'XML/Serializer.php';
$options = array(XML_SERIALIZER_OPTION_XML_DECL_ENABLED => true, XML_SERIALIZER_OPTION_XML_ENCODING => "utf-8", XML_SERIALIZER_OPTION_INDENT => "\t", XML_SERIALIZER_OPTION_LINEBREAKS => "\n", XML_SERIALIZER_OPTION_ROOT_NAME => 'rss', XML_SERIALIZER_OPTION_ROOT_ATTRIBS => array('version' => '2.0'), XML_SERIALIZER_OPTION_DEFAULT_TAG => 'item');
$serializer = new XML_Serializer($options);
$data = array('channel' => array('title' => A::$OPTIONS['sitename_' . LANG] . ($srow ? " - " . $srow['caption_' . LANG] : ""), 'link' => "http://" . DOMAINNAME . ($srow ? getSectionLink($section) : ""), 'description' => A::$OPTIONS['sitename_' . LANG], 'pubDate' => date('r')));
if ($srow) {
    A::$DB->queryLimit("\r\r\n  SELECT a.*,c.name AS category\r\r\n  FROM {$section}_catalog AS a\r\r\n  LEFT JOIN {$section}_categories AS c ON c.id=a.idcat\r\r\n  WHERE a.active='Y' " . ($idcat > 0 ? " AND a.idcat={$idcat}" : "") . "\r\r\n  ORDER BY date DESC", 0, $rssrow['rows']);
    while ($row = A::$DB->fetchRow()) {
        $item = array('title' => $row['name'], 'link' => "http://" . DOMAINNAME . catalog_createItemLink($row['id'], $section), 'pubDate' => date("r", $row['date']), 'description' => strip_tags($row['description']));
        if (!empty($row['category'])) {
            $item['category'] = $row['category'];
        }
        $data['channel'][] = $item;
    }
    A::$DB->free();
} else {
    $items = array();
    $sections = getSectionsByModule('catalog');
    foreach ($sections as $section) {
        A::$DB->queryLimit("\r\r\n    SELECT a.*,c.name AS category\r\r\n    FROM {$section}_catalog AS a\r\r\n    LEFT JOIN {$section}_categories AS c ON c.id=a.idcat\r\r\n    WHERE a.active='Y'\r\r\n    ORDER BY date DESC", 0, $rssrow['rows']);
Exemple #7
0
 /**
  * Формирование данных доступных в шаблоне страницы альбома.
  */
 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'];
 }
Exemple #8
0
/**
 * Получение полных данных записи каталога.
 *
 * @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;
    }
}
Exemple #9
0
 /**
  * Формирование данных доступных в шаблоне страницы сообщения.
  */
 function MessagePage()
 {
     $fields = array();
     if ($id = A_Session::get(SECTION . "_id", 0)) {
         if ($arch = A::$DB->getRowById($id, SECTION . "_arch")) {
             $fields = !empty($arch['data']) ? unserialize($arch['data']) : array();
         }
     }
     $this->Assign("fields", $fields);
     $this->AddNavigation(SECTION_NAME, getSectionLink(SECTION));
 }
Exemple #10
0
/**
 * Интеграция в карту сайта.
 *
 * @param object &$treemap Объект дерева карты сайта.
 * @param string $section Полный строковой идентификатор раздела.
 * @param string $caption Название раздела.
 */
function feedback_createMap($treemap, $section, $caption)
{
    $treemap->items[$section] = new SiteMap_Box($caption, getSectionLink($section));
}
Exemple #11
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 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);
 }
Exemple #12
0
 /**
  * Формирование данных доступных в шаблоне детальной страницы материала.
  */
 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'];
 }
Exemple #13
0
 function getPath($id)
 {
     if ($row = A::$DB->getRow("SELECT idker,urlname FROM " . SECTION . " WHERE id={$id}")) {
         return $this->getPath($row['idker']) . $row['urlname'] . "/";
     } else {
         $link = DOMAINNAME == preg_replace("/^www\\./i", "", HOSTNAME) ? DOMAINNAME . getSectionLink(SECTION) : getSectionLink(SECTION);
         return preg_replace("/^http\\:\\/\\//i", "", $link);
     }
 }
Exemple #14
0
 /**
  * Формирование данных доступных в шаблоне активного типа.
  */
 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'];
 }
Exemple #15
0
 /**
  * Формирование данных доступных в шаблоне.
  */
 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']);
 }