public function main() { $aInfo = \Extasy\sitemap\Route::getCurrentUrlInfo(); $aMenu = Sitemap_PagesOperations::selectChildWithoutAdditional($aInfo['id'], 1, 0); $url = ''; if (empty($aMenu)) { // Получаем предка if (!empty($aInfo['parent'])) { $aParent = Sitemap_Sample::get($aInfo['parent']); $url .= $aParent['full_url']; $this->jump($url); } else { die('Parent empty'); } } $url .= $aMenu[0]['full_url']; $this->jump($url); }
public function goFirstChild() { // $aMenu = Sitemap_PagesOperations::selectChildWithoutAdditional($this->aUrlInfo['id'], 1); if (empty($aMenu)) { throw new NotFoundException(); } // $url = $aMenu[0]['full_url']; $this->jump($url); }
/** * Возвращает полное меню для указанного документа * @param bool $nId обозначает индекс страницы, от которой меню генерировать * @param bool $bWithAdditional обозначает необходимость подгрузки доп. информации из моделей */ public static function selectFullMenu($nId = 0, $bWithAdditional = false, $aExcludeSitemapEntity = array()) { $aUrlInfo = self::getCurrentUrlInfo(); $aResult = array(); if ($bWithAdditional) { $aData = Sitemap_PagesOperations::selectChildWithAdditional($nId); } else { $aData = Sitemap_PagesOperations::selectChildWithoutAdditional($nId); } // Перебор по рекурсии, спускаемся ниже, чтобы найти следующие документы $aResult = array(); foreach ($aData as &$row) { // Определяем, что текущий элемент активный $isCurrent = SitemapMisc::urlsMatch($aUrlInfo['full_url'], $row['full_url']); if ($isCurrent) { $row['active'] = 1; } if ($row['full_url'] == $aUrlInfo['full_url']) { $row['active'] = 1; } // Определяем, что текущий элемент активный $excludeDocument = !empty($row['document_name']) && in_Array($row['document_name'], $aExcludeSitemapEntity); $excludeScript = !empty($row['script']) && in_Array($row['script'], $aExcludeSitemapEntity); if ($excludeDocument || $excludeScript) { // Не включаем дерево ненужные документы continue; } if (!empty($row['count'])) { $row['aChild'] = self::selectFullMenu($row['id'], $bWithAdditional, $aExcludeSitemapEntity); } else { $row['aChild'] = array(); } $aResult[] = $row; } unset($row); return $aResult; }
/** * */ public function orderMoveDown($id, $nPage = 0) { $this->nPage = intval($nPage); $aInfo = Sitemap_Sample::get($id); if (empty($aInfo) || !$this->checkSecurity($aInfo['id'], $aInfo['parent'])) { print 'No'; die; } $aItem = Sitemap_PagesOperations::selectChildWithoutAdditional($aInfo['parent']); $aSort = array(); $bMoved = false; foreach ($aItem as $row) { if (sizeof($aSort) > 0 && $aSort[sizeof($aSort) - 1] == $aInfo['id'] && !$bMoved) { $nOld = array_pop($aSort); $aSort[] = $row['id']; $aSort[] = $nOld; $bMoved = true; } else { $aSort[] = $row['id']; } } Sitemap::manualOrder($aInfo['parent'], $aSort); $this->nParent = $aInfo['parent']; $this->getInformation(); $this->getData(); $this->outputDataTable(CMSDesign::getInstance()); die; }
protected static function selectChilds($nSitemapId, $szAdditionalSQL, $orderCondition, $nStart, $nCount) { $nSitemapId = intval($nSitemapId); $nCount = intval($nCount); $nStart = intval($nStart); $nStart = $nStart < 0 ? 0 : $nStart; $sql = 'SELECT SQL_CALC_FOUND_ROWS * FROM `%s` WHERE `parent`="%d" %s ORDER by %s'; if (!empty($nCount)) { $sql .= ' LIMIT %d,%d'; } else { } $orderCondition = empty($orderCondition) ? '`order` asc' : $orderCondition; if (!defined('CMS')) { $szAdditionalSQL .= 'and `visible`=1 '; } $sql = sprintf($sql, SITEMAP_TABLE, $nSitemapId, $szAdditionalSQL, $orderCondition, $nStart, $nCount); $aItem = DB::query($sql); // if (!empty($nCount)) { $aFound = DB::get('SELECT FOUND_ROWS() as `totalcount`'); self::$nTotalCount = $aFound['totalcount']; } return $aItem; }