• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

webservice/soap/classes/class.ilXMLResultSetWriter.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00004   /*
00005    +-----------------------------------------------------------------------------+
00006    | ILIAS open source                                                           |
00007    +-----------------------------------------------------------------------------+
00008    | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00009    |                                                                             |
00010    | This program is free software; you can redistribute it and/or               |
00011    | modify it under the terms of the GNU General Public License                 |
00012    | as published by the Free Software Foundation; either version 2              |
00013    | of the License, or (at your option) any later version.                      |
00014    |                                                                             |
00015    | This program is distributed in the hope that it will be useful,             |
00016    | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00017    | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00018    | GNU General Public License for more details.                                |
00019    |                                                                             |
00020    | You should have received a copy of the GNU General Public License           |
00021    | along with this program; if not, write to the Free Software                 |
00022    | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00023    +-----------------------------------------------------------------------------+
00024   */
00025 
00026 
00036 include_once "./classes/class.ilXmlWriter.php";
00037 
00038 class ilXMLResultSetWriter extends ilXmlWriter
00039 {
00040         var $xmlResultSet;
00041 
00042         function ilXMLResultSetWriter(& $xmlResultSet)
00043         {
00044                 parent::ilXmlWriter();
00045                 $this->xmlResultSet = $xmlResultSet;
00046         }
00047 
00048 
00049         function start()
00050         {
00051                 if(!is_object($this->xmlResultSet))
00052                 {
00053                         return false;
00054                 }
00055 
00056                 $this->__buildHeader();
00057 
00058                 $this->__buildColSpecs();
00059 
00060                 $this->__buildRows();
00061 
00062                 $this->__buildFooter();
00063 
00064                 return true;
00065         }
00066 
00067         function getXML()
00068         {
00069                 return $this->xmlDumpMem(FALSE);
00070         }
00071 
00072 
00073         // PRIVATE
00074         function __appendRow(& $xmlResultSetRow)
00075         {
00076                 $this->xmlStartTag('row',null);
00077 
00078                 foreach ($xmlResultSetRow->getColumns() as $value)
00079                 {
00080                         $this->xmlElement('column',null,$value);
00081 
00082                 }
00083 
00084                 $this->xmlEndTag('row');
00085 
00086         }
00087 
00088 
00089         function __buildHeader()
00090         {
00091                 $this->xmlSetDtdDef("<!DOCTYPE result PUBLIC \"-//ILIAS//DTD XMLResultSet//EN\" \"".ILIAS_HTTP_PATH."/xml/ilias_xml_resultset_3_7.dtd\">");
00092                 $this->xmlHeader();
00093 
00094                 $this->xmlStartTag("result");
00095 
00096                 return true;
00097         }
00098 
00099         function __buildColSpecs() {
00100                 $this->xmlStartTag("colspecs");
00101 
00102                 foreach ($this->xmlResultSet->getColSpecs() as $colSpec) {
00103                         $attr  = array ("idx" => $colSpec->getIndex(), "name" => $colSpec->getName());
00104 
00105                         $this->xmlElement("colspec", $attr, null);
00106                 }
00107 
00108                 $this->xmlEndTag("colspecs");
00109         }
00110 
00111         function __buildRows () {
00112                 $this->xmlStartTag("rows");
00113 
00114                 foreach($this->xmlResultSet->getRows() as $row)
00115                 {
00116                         $this->__appendRow($row);
00117                 }
00118 
00119                 $this->xmlEndTag("rows");
00120         }
00121 
00122         function __buildFooter()
00123         {
00124                 $this->xmlEndTag('result');
00125         }
00126 
00127 
00128 
00129 }
00130 
00131 
00132 ?>

Generated on Fri Dec 13 2013 17:57:03 for ILIAS Release_3_9_x_branch .rev 46835 by  doxygen 1.7.1