<?php
/* example.php
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
$Id: $
*/
/** Example to explain how to generate sitemaps tree according
* to sitemap protocol (see http://www.sitemaps.org/protocol.php).
*
* @category class
* @package sitemap_manager
* @author Giuseppe Sucameli <brush.tyler@hotmail.it>
* @copyright 2009 Giuseppe Sucameli
* @license http://www.gnu.org/licenses/gpl.html GPL V 2.0
* @version 0.1
*/
require_once('SitemapManager.class.php');
// create an array of urls
$arr = array(
'http://www.host.com/',
'http://www.host.com/index.html',
'http://www.host.com/site.php?page=1234',
'http://www.anotherhost.com/index.html', // for using different hosts in the same sitemap, see http://www.sitemaps.org/protocol.php#location
new SitemapItem('http://www.host.com/test.php'),
new SitemapItem('http://www.host.com/index.php?id=1234&user=4321', '2009-09-11'),
new SitemapItem('http://www.host.com/contact.html', '', 'never'),
new SitemapItem('http://www.host.com/images/gallery.html', time(), 'monthly', 0.5)
);
// create the SitemapManager and use it to add urls to the tree of sitemaps
$man = new SitemapManager('/var/www/site/', 'http://www.host.com');
$man->AddUrls($arr);
// print the url of the sitemap that is the actual tree root
print($man->GetSitemapRootUrl()."\n");
/* The following code demonstrates the changing of sitemaps tree root
* when a sitemap is full, but is commented becouse executing it requires
* a long running time (about 1 minute).
*/
/*
// now insert so many urls to fill a sitemap
$count = Sitemap::MAX_URLS/count($arr);
for($i=0; $i<$count; $i++)
$man->AddUrls($arr);
// print the url of the new sitemap root
print($man->GetSitemapRootUrl()."\n");
*/
?>
|