protected function _load() { $pagesList = array(); $pages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllMainMenuPages(); $configHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('config'); $showMemberPages = (bool) $configHelper->getConfig('memPagesInMenu'); $isAllowed = Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_PAGE_PROTECTED); $flatPages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllStaticMenuPages(); $nomenuPages = Application_Model_Mappers_PageMapper::getInstance()->fetchAllNoMenuPages(); foreach ($pages as $key => $page) { if ($page['parentId'] == 0) { if ((bool) $page['protected'] && !$isAllowed && !$showMemberPages) { continue; } $pagesList[$key]['category'] = $page; foreach ($pages as $subPage) { if (isset($subPage['protected']) && (bool) $subPage['protected'] && !$isAllowed && !$showMemberPages) { continue; } if ($subPage['parentId'] == $page['id']) { $pagesList[$key]['subPages'][] = $subPage; } } } } $this->_view->pages = $pagesList; $this->_view->flatPages = $flatPages; if (isset($this->_options[0])) { if ($this->_options[0] == 'nomenuPages') { $this->_view->nomenuPages = $nomenuPages; } } $newslogPlugin = Application_Model_Mappers_PluginMapper::getInstance()->findByName('newslog'); if ($newslogPlugin instanceof Application_Model_Models_Plugin) { if ($newslogPlugin->getStatus() == Application_Model_Models_Plugin::ENABLED) { $this->_view->newsFolder = Newslog_Models_Mapper_ConfigurationMapper::getInstance()->fetchConfigParam('folder'); } } return $this->_view->render('sitemap.phtml'); }
/** * Serve sitemaps * */ public function sitemapAction() { //disable renderer $this->_helper->viewRenderer->setNoRender(true); //get sitemap type from the params if (($sitemapType = $this->getRequest()->getParam('type', '')) == Tools_Content_Feed::SMFEED_TYPE_REGULAR) { //regular sitemap.xml requested if (null === ($this->view->pages = $this->_helper->cache->load('sitemappages', 'sitemaps_'))) { if (in_array('newslog', Tools_Plugins_Tools::getEnabledPlugins(true))) { $this->view->newsPageUrlPath = Newslog_Models_Mapper_ConfigurationMapper::getInstance()->fetchConfigParam('folder'); } $pages = Application_Model_Mappers_PageMapper::getInstance()->fetchAll(); if (is_array($pages) && !empty($pages)) { $quoteInstalled = Tools_Plugins_Tools::findPluginByName('quote')->getStatus() == Application_Model_Models_Plugin::ENABLED; $pages = array_filter($pages, function ($page) use($quoteInstalled) { if ($page->getExtraOption(Application_Model_Models_Page::OPT_PROTECTED) || $page->getDraft() || $page->getIs404page() || $quoteInstalled && intval($page->getParentId()) === Quote::QUOTE_CATEGORY_ID) { return false; } return true; }); } else { $pages = array(); } $this->view->pages = $pages; $this->_helper->cache->save('sitemappages', $this->view->pages, 'sitemaps_', array('sitemaps')); } } else { if ($sitemapType == Tools_Content_Feed::SMFEED_TYPE_INDEX) { //default sitemaps $sitemaps = array('sitemap' => array('extension' => 'xml', 'lastmod' => date(DATE_ATOM)), 'sitemapnews' => array('extension' => 'xml', 'lastmod' => date(DATE_ATOM))); //real sitemaps (in the toaster root) $sitemapFiles = Tools_Filesystem_Tools::findFilesByExtension($this->_helper->website->getPath(), 'xml', false, false, false); if (is_array($sitemapFiles) && !empty($sitemapFiles)) { foreach ($sitemapFiles as $sitemapFile) { if (preg_match('~sitemap.*\\.xml.*~', $sitemapFile)) { $fileInfo = pathinfo($this->_helper->website->getPath() . $sitemapFile); if (is_array($fileInfo)) { $sitemaps[$fileInfo['filename']] = array('extension' => $fileInfo['extension'], 'lastmod' => date(DATE_ATOM, fileatime($this->_helper->website->getPath() . $sitemapFile))); } } } } $this->view->sitemaps = $sitemaps; } } $template = 'sitemap' . $sitemapType . '.xml.phtml'; if (null === ($sitemapContent = $this->_helper->cache->load($sitemapType, Helpers_Action_Cache::PREFIX_SITEMAPS))) { try { $sitemapContent = $this->view->render('backend/seo/' . $template); } catch (Zend_View_Exception $zve) { // Try to find plugin's sitemap try { $sitemapContent = Tools_Plugins_Tools::runStatic('getSitemap', $sitemapType); if (!$sitemapContent) { $sitemapContent = Tools_Plugins_Tools::runStatic('getSitemap' . ucfirst($sitemapType)); } } catch (Exception $e) { Tools_System_Tools::debugMode() && error_log($e->getMessage()); $sitemapContent = false; } if ($sitemapContent === false) { $this->getResponse()->setHeader('Content-Type', 'text/html', true); return $this->forward('index', 'index', null, array('page' => 'sitemap' . $sitemapType . '.xml')); } } $this->_helper->cache->save($sitemapType, $sitemapContent, Helpers_Action_Cache::PREFIX_SITEMAPS, array('sitemaps'), Helpers_Action_Cache::CACHE_WEEK); } echo $sitemapContent; }