/** * Формирование данных доступных в шаблоне страницы альбома. */ 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']; }
/** * Формирование данных доступных в шаблоне. */ 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); }