_handlers)) { $file = BASE_PATH . '/App/Doc/' . ucfirst($name) . '.php'; if (file_exists($file)) { $class = 'App_Doc_' . ucfirst($name); $this->_handlers[$name] = new $class(); } else { $this->_handlers[$name] = false; } } return $this->_handlers[$name]; } public function exec() { if (null !== ($filter = $this->getConfig('filter'))) { $sitemap = Qs_SiteMap::getFromDb(array('filter' => $filter->toArray())); } else { $sitemap = Qs_SiteMap::getFromDb(); } $xml = new App_Sitemap_Xml_Writer(); $xml->start(); $this->_writeXmlSitemap($xml, $sitemap); $xml->end(); $xml->finish(); $xml->output(); } public static function deleteSiteMap() { $filePath = WWW_PATH . '/' . 'sitemap.xml'; if (file_exists($filePath)) { unlink($filePath); } } protected function _writeXmlSitemap(App_Sitemap_Xml_Writer $xml, $sitemap) { foreach ($sitemap as $page) { if ('y' != $page['isIndexing'] || 'y' != $page['enabled']) { continue; } if (false === ($doc = $this->getHandler($page['handler']))) { Qs_Debug::log('Unknown page handler "' . $page['handler'] . '" for page "' . $page['fullAlias'] . '"'); continue; } $doc->setOptions($page); if ('n' == $page['final'] || 'y' == $page['final'] && !in_array(Model::SKIP_ROOT, Qs_Array::get($page, 'xIndexingOptions', [])) ) { $xml->writeUrl((('y' == $page['isSecure']) ? BASE_URL_HTTPS : BASE_URL_HTTP) . '/' . $page['fullAlias']); } foreach ($page['items'] as $item) { $item['doc'] = $doc; if ($itemObject = Qs_SiteMap::createPageItemView($item)) { if (method_exists($itemObject, 'writeXmlSitemap')) { $itemObject->writeXmlSitemap($xml); } unset($itemObject); } } if ($page['final'] == 'n' && isset($page['sub']) && !empty($page['sub'])) { $this->_writeXmlSitemap($xml, $page['sub']); } } return $this; } }