dmBridge PHP API
DMTESitemapController.php
00001 <?php
00002 #
00003 # dmBridge: a data access framework for CONTENTdm(R)
00004 #
00005 # Copyright © 2009, 2010, 2011 Board of Regents of the Nevada System of Higher
00006 # Education, on behalf of the University of Nevada, Las Vegas
00007 #
00008 
00015 class DMTESitemapController extends DMAbstractController {
00016 
00026    public function view() {
00027       $dxml = new DOMDocument("1.0", "utf-8");
00028       $dxml->loadXML("<urlset/>");
00029       $doc = $dxml->documentElement;
00030       $doc->setAttribute("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9");
00031 
00032       foreach (DMCollection::getAuthorized() as $col) {
00033          $num_pages = ceil($col->getNumObjects() / 50);
00034          for ($i = 1; $i <= $num_pages; $i++) {
00035             // build xml elements
00036             $node = $dxml->createElement("url");
00037             $loc = $dxml->createElement("loc",
00038                   DMInternalURI::getURIWithParams(
00039                      "objects" . $col->getAlias(),
00040                      array("page" => $i),
00041                      "sitemap"));
00042             $node->appendChild($loc);
00043             $doc->appendChild($node);
00044          }
00045       }
00046       header("Content-Type: application/xml");
00047       die($dxml->saveXML());
00048    }
00049 
00050 }
 All Data Structures Functions Variables