Example #1
0
/**
 * Интеграция в карту сайта ссылок на категории.
 *
 * @param object &$treeitem Объект дерева карты сайта.
 * @param string $section Полный строковой идентификатор раздела.
 * @param integer $id=0 Идентификатор родительской категории.
 */
function catalog_createMap_Categories(&$treeitem, $section, $id = 0)
{
    A::$DB->query("SELECT * FROM {$section}_categories WHERE idker={$id} AND active='Y' ORDER BY sort");
    while ($row = A::$DB->fetchRow()) {
        $treeitem->items[$row['id']] = new SiteMap_Box($row['name'], catalog_createCategoryLink($row['id'], $section));
        catalog_createMap_Categories($treeitem->items[$row['id']], $section, $row['id']);
    }
    A::$DB->free();
}
Example #2
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'];
 }
Example #3
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'] = 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));
 }