/** * Интеграция в карту сайта ссылок на категории. * * @param object &$treeitem Объект дерева карты сайта. * @param string $section Полный строковой идентификатор раздела. * @param integer $id=0 Идентификатор родительской категории. */ function gallery_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'], gallery_createCategoryLink($row['id'], $section)); gallery_createMap_Categories($treeitem->items[$row['id']], $section, $row['id']); } 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); }
/** * Формирование данных доступных в шаблоне страницы альбома. */ 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']; }