pages/sitemap/SitemapHandler.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 // $Id$
00016 
00017 
00018 import('xml.XMLCustomWriter');
00019 import('handler.Handler');
00020 
00021 define('SITEMAP_XSD_URL', 'http://www.sitemaps.org/schemas/sitemap/0.9');
00022 
00023 class SitemapHandler extends Handler {
00027    function index() {
00028       if (Request::getRequestedConferencePath() == 'index') {
00029          $doc = SitemapHandler::createSitemapIndex();
00030          header("Content-Type: application/xml");
00031          header("Cache-Control: private");
00032          header("Content-Disposition: inline; filename=\"sitemap_index.xml\"");
00033          XMLCustomWriter::printXML($doc);
00034       } else {
00035          if(Request::getRequestedSchedConfPath() == 'index') {
00036             // At conference level
00037             $doc = SitemapHandler::createConfSitemap();
00038             header("Content-Type: application/xml");
00039             header("Cache-Control: private");
00040             header("Content-Disposition: inline; filename=\"sitemap.xml\"");
00041             XMLCustomWriter::printXML($doc);
00042          } else {
00043             // At scheduled conference level
00044             $doc = SitemapHandler::createSchedConfSitemap();
00045             header("Content-Type: application/xml");
00046             header("Cache-Control: private");
00047             header("Content-Disposition: inline; filename=\"sitemap.xml\"");
00048             XMLCustomWriter::printXML($doc);
00049          }
00050       }
00051    }
00052    
00057    function createSitemapIndex() {
00058       $conferenceDao =& DAORegistry::getDAO('ConferenceDAO');
00059       $schedConfDao =& DAORegistry::getDAO('SchedConfDAO');
00060       
00061       $doc =& XMLCustomWriter::createDocument();
00062       $root =& XMLCustomWriter::createElement($doc, 'sitemapindex');
00063       XMLCustomWriter::setAttribute($root, 'xmlns', SITEMAP_XSD_URL);
00064 
00065       $conferences =& $conferenceDao->getConferences();
00066       while ($conference =& $conferences->next()) {
00067          $sitemapUrl = Request::url($conference->getPath(), 'index', 'sitemap');
00068          $sitemap =& XMLCustomWriter::createElement($doc, 'sitemap');
00069          XMLCustomWriter::createChildWithText($doc, $sitemap, 'loc', $sitemapUrl, false);
00070          XMLCustomWriter::appendChild($root, $sitemap);
00071       
00072          $schedConfs =& $schedConfDao->getSchedConfsByConferenceId($conference->getId());
00073          while ($schedConf =& $schedConfs->next()) {
00074             $sitemapUrl = Request::url($conference->getPath(), $schedConf->getPath(), 'sitemap');
00075             $sitemap =& XMLCustomWriter::createElement($doc, 'sitemap');
00076             XMLCustomWriter::createChildWithText($doc, $sitemap, 'loc', $sitemapUrl, false);
00077             XMLCustomWriter::appendChild($root, $sitemap);
00078             unset($schedConf);
00079          }
00080          unset($conference);
00081       }
00082       
00083       XMLCustomWriter::appendChild($doc, $root);
00084       return $doc;
00085    }
00086       
00091    function createConfSitemap() {      
00092       $conference =& Request::getConference();
00093       $conferenceId = $conference->getId();
00094       
00095       $doc =& XMLCustomWriter::createDocument();
00096       $root =& XMLCustomWriter::createElement($doc, 'urlset');
00097       XMLCustomWriter::setAttribute($root, 'xmlns', SITEMAP_XSD_URL);
00098       
00099       // Conf. Home 
00100       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), 'index', 'index')));
00101       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), 'index', 'schedConfs', 'archive')));
00102       
00103       XMLCustomWriter::appendChild($doc, $root);
00104       return $doc;
00105    }
00106    
00111    function createSchedConfSitemap() {    
00112       $publishedPaperDao =& DAORegistry::getDAO('PublishedPaperDAO');
00113       $galleyDao =& DAORegistry::getDAO('PaperGalleyDAO');
00114       
00115       $conference =& Request::getConference();
00116       $conferenceId = $conference->getId();
00117       $schedConf = Request::getSchedConf();
00118 
00119       $doc =& XMLCustomWriter::createDocument();
00120       $root =& XMLCustomWriter::createElement($doc, 'urlset');
00121       XMLCustomWriter::setAttribute($root, 'xmlns', SITEMAP_XSD_URL);
00122 
00123       // Sched. Conf. home
00124       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath())));
00125       // About page
00126       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'about')));
00127       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'about', 'submissions')));
00128       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'about', 'siteMap')));
00129       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'about', 'aboutThisPublishingSystem')));
00130       // Search
00131       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'search')));
00132       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'search', 'authors')));
00133       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'search', 'titles')));
00134       // Conference Information
00135       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'overview')));
00136       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'trackPolicies')));
00137       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'presentations')));
00138       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'accommodation')));
00139       XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'schedConf', 'organizingTeam')));
00140       // Individual Papers
00141       $publishedPapers =& $publishedPaperDao->getPublishedPapers($schedConf->getId());
00142       while ($paper =& $publishedPapers->next()) {
00143          // Abstract
00144          XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'paper', 'view', $paper->getId())));
00145          // Galley files
00146          $galleys = $galleyDao->getGalleysByPaper($paper->getId());
00147          foreach ($galleys as $galley) {
00148             XMLCustomWriter::appendChild($root, SitemapHandler::createUrlTree($doc, Request::url($conference->getPath(), $schedConf->getPath(), 'paper', 'view', array($paper->getId(), $galley->getId()))));
00149          }
00150       }
00151          
00152       XMLCustomWriter::appendChild($doc, $root);
00153       return $doc;
00154    }
00155    
00165    function createUrlTree(&$doc, $loc, $lastmod = null, $changefreq = null, $priority = null) {    
00166       $url =& XMLCustomWriter::createElement($doc, 'url');
00167       
00168       XMLCustomWriter::createChildWithText($doc, $url, htmlentities('loc'), $loc, false);
00169       XMLCustomWriter::createChildWithText($doc, $url, 'lastmod', $lastmod, false);
00170       XMLCustomWriter::createChildWithText($doc, $url, 'changefreq', $changefreq, false);
00171       XMLCustomWriter::createChildWithText($doc, $url, 'priority', $priority, false);
00172       
00173       return $url;
00174    }
00175    
00176 }
00177 
00178 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7