dmBridge PHP API
DMSitemapRepresentationTransformer.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 
00013 class DMSitemapRepresentationTransformer extends DMXMLRepresentationTransformer {
00014 
00015    public function __construct() {
00016       parent::__construct();
00017    }
00018 
00024    public function transformResults(DMObjectQuery $q) {
00025       $this->dxml->loadXML("<urlset/>");
00026       $doc = $this->dxml->documentElement;
00027       $doc->setAttribute("xmlns",
00028             "http://www.sitemaps.org/schemas/sitemap/0.9");
00029       foreach ($q->getSearchResults() as $obj) {
00030          $url = $this->dxml->createElement("url");
00031          $loc = $this->dxml->createElement("loc",
00032                DMString::xmlentities($obj->getURI()));
00033          $url->appendChild($loc);
00034          $doc->appendChild($url);
00035       }
00036       return $this->output();
00037    }
00038 
00042    protected function output() {
00043       return $this->dxml->saveXML($this->dxml->documentElement);
00044    }
00045 
00046 }
 All Data Structures Functions Variables