3
* $RCSfile: Sitemap.inc,v $
5
* Gallery - a web based photo album viewer and editor
6
* Copyright (C) 2000-2006 Bharat Mediratta
8
* This program is free software; you can redistribute it and/or modify
9
* it under the terms of the GNU General Public License as published by
10
* the Free Software Foundation; either version 2 of the License, or (at
11
* your option) any later version.
13
* This program is distributed in the hope that it will be useful, but
14
* WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16
* General Public License for more details.
18
* You should have received a copy of the GNU General Public License
19
* along with this program; if not, write to the Free Software
20
* Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
24
* @version $Revision: 1.3 $ $Date: 2006/01/13 03:39:51 $
26
* @subpackage UserInterface
27
* @author Bharat Mediratta <bharat@menalto.com>
31
* Create an appropriate Google Sitemap for this site.
34
* @subpackage UserInterface
36
class SitemapView extends GalleryView {
39
* @see GalleryView::isImmediate
41
function isImmediate() {
46
* @see GalleryView::renderImmediate
48
function renderImmediate($status, $error) {
50
list ($ret, $rootId) =
51
GalleryCoreApi::getPluginParameter('module', 'core', 'id.rootAlbum');
53
return $ret->wrap(__FILE__, __LINE__);
56
$ret = $this->renderSitemap($rootId);
58
return $ret->wrap(__FILE__, __LINE__);
63
* Output a site map rooted at the given id
66
* @return object GalleryStatus a status code
68
function renderSitemap($rootId) {
70
$urlGenerator =& $gallery->getUrlGenerator();
71
$phpVm = $gallery->getPhpVm();
75
* - Calculate priority by using a percentage of item view count to max view counts
79
* Don't use a template for this as we may wind up trying to buffer
82
$phpVm->header('Content-type: application/xhtml+xml');
83
print '<?xml version=\'1.0\' encoding=\'UTF-8\'?>';
85
print '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84" ';
86
print 'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';
87
print 'xsi:schemaLocation="http://www.google.com/schemas/sitemap/0.84 ';
88
print 'http://www.google.com/schemas/sitemap/0.84/sitemap.xsd">';
91
$queue = array($rootId);
92
while (!empty($queue)) {
93
$currentId = array_shift($queue);
94
list ($ret, $newIds) =
95
GalleryCoreApi::fetchChildItemIdsWithPermission($currentId, 'core.view');
97
return $ret->wrap(__FILE__, __LINE__);
99
$queue = array_merge($queue, $newIds);
101
/* TODO: load entities in chunks */
102
list ($ret, $entity) = GalleryCoreApi::loadEntitiesById($currentId);
104
return $ret->wrap(__FILE__, __LINE__);
107
printf("<url><loc>%s</loc><lastmod>%s</lastmod></url>\n",
108
$urlGenerator->generateUrl(
109
array('view' => 'core.ShowItem', 'itemId' => $currentId),
110
array('forceSessionId' => false, 'forceFullUrl' => true)),
112
gmstrftime("%Y-%m-%dT%H:%M:%S%z", $entity->getModificationTimestamp()),