00001 <?php
00002 #
00003 # dmBridge: a data access framework for CONTENTdm(R)
00004 # Copyright © 2009, 2010 Board of Regents of the Nevada System of Higher
00005 # Education, on behalf of the University of Nevada, Las Vegas
00006 #
00007
00015 abstract class dmXMLOutput extends dmHTTPOutput {
00016
00017 protected $dxml, $pretty_print = false;
00018
00019
00020 public function __construct() {
00021 parent::__construct();
00022 $this->setContentType('application/xml');
00023 $this->dxml = new DOMDocument('1.0', 'utf-8');
00024 }
00025
00026
00030 public final function setPrettyPrint($bool) {
00031 $this->pretty_print = (bool) $bool;
00032 }
00033
00034
00035 protected function appendQSeconds() {
00036 $this->dxml->documentElement->appendChild(
00037 $this->dxml->createElement('querySeconds', $this->getQSeconds())
00038 );
00039 }
00040
00041
00042 protected function output() {
00043 $this->appendQSeconds();
00044 if ($this->pretty_print) $this->dxml->formatOutput = true;
00045 $this->dxml->documentElement->setAttribute('version', $this->getVersion());
00046 return $this->dxml->saveXML();
00047 }
00048
00049 }
00050