*/ /** * Create an appropriate Google Sitemap for this site. * * @package Sitemap * @subpackage UserInterface */ class SitemapView extends GalleryView { /** * @see GalleryView::isImmediate */ function isImmediate() { return true; } /** * @see GalleryView::renderImmediate */ function renderImmediate($status, $error) { list ($ret, $rootId) = GalleryCoreApi::getPluginParameter('module', 'core', 'id.rootAlbum'); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } $ret = $this->renderSitemap($rootId); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } } /** * Output a site map rooted at the given id * * @param the root id * @return object GalleryStatus a status code */ function renderSitemap($rootId) { global $gallery; $urlGenerator =& $gallery->getUrlGenerator(); $phpVm = $gallery->getPhpVm(); /* * Ideas: * - Calculate priority by using a percentage of item view count to max view counts */ /* * Don't use a template for this as we may wind up trying to buffer * way too much data */ $phpVm->header('Content-type: application/xhtml+xml'); print ''; print "\n"; print ''; print "\n"; $queue = array($rootId); while (!empty($queue)) { $currentId = array_shift($queue); list ($ret, $newIds) = GalleryCoreApi::fetchChildItemIdsWithPermission($currentId, 'core.view'); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } $queue = array_merge($queue, $newIds); /* TODO: load entities in chunks */ list ($ret, $entity) = GalleryCoreApi::loadEntitiesById($currentId); if ($ret) { return $ret->wrap(__FILE__, __LINE__); } printf("%s%s\n", $urlGenerator->generateUrl( array('view' => 'core.ShowItem', 'itemId' => $currentId), array('forceSessionId' => false, 'forceFullUrl' => true)), substr_replace( gmstrftime("%Y-%m-%dT%H:%M:%S%z", $entity->getModificationTimestamp()), ":", -2, 0)); } print ''; return null; } } ?>