<?php
/***************************************************************
-* Copyright notice
-*
-* (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
-* All rights reserved
-*
-* This script is part of the TYPO3 project. The TYPO3 project is
-* free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2 of the License, or
-* (at your option) any later version.
-*
-* The GNU General Public License can be found at
-* http://www.gnu.org/copyleft/gpl.html.
-* A copy is found in the textfile GPL.txt and important notices to the license
-* from the author is found in LICENSE.txt distributed with these scripts.
-*
-*
-* This script is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* This copyright notice MUST APPEAR in all copies of the script!
-***************************************************************/
+ * Copyright notice
+ *
+ * (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
+ * All rights reserved
+ *
+ * This script is part of the TYPO3 project. The TYPO3 project is
+ * free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * The GNU General Public License can be found at
+ * http://www.gnu.org/copyleft/gpl.html.
+ * A copy is found in the textfile GPL.txt and important notices to the license
+ * from the author is found in LICENSE.txt distributed with these scripts.
+ *
+ *
+ * This script is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This copyright notice MUST APPEAR in all copies of the script!
+ ***************************************************************/
/**
* Contains class for creating XML output from records
*
*
*
* 86: class t3lib_xml
- * 102: function t3lib_xml($topLevelName)
- * 113: function setRecFields($table,$list)
- * 122: function getResult()
- * 132: function WAPHeader()
- * 144: function renderHeader()
- * 155: function renderFooter()
- * 167: function newLevel($name,$beginEndFlag=0,$params=array())
- * 192: function output($content)
- * 208: function indent($b)
- * 224: function renderRecords($table,$res)
- * 237: function addRecord($table,$row)
- * 255: function getRowInXML($table,$row)
- * 271: function utf8($content)
- * 281: function substNewline($string)
- * 292: function fieldWrap($field,$value)
- * 301: function WAPback()
- * 315: function addLine($str)
+ * 102: function t3lib_xml($topLevelName)
+ * 113: function setRecFields($table,$list)
+ * 122: function getResult()
+ * 132: function WAPHeader()
+ * 144: function renderHeader()
+ * 155: function renderFooter()
+ * 167: function newLevel($name,$beginEndFlag=0,$params=array())
+ * 192: function output($content)
+ * 208: function indent($b)
+ * 224: function renderRecords($table,$res)
+ * 237: function addRecord($table,$row)
+ * 255: function getRowInXML($table,$row)
+ * 271: function utf8($content)
+ * 281: function substNewline($string)
+ * 292: function fieldWrap($field,$value)
+ * 301: function WAPback()
+ * 315: function addLine($str)
*
* TOTAL FUNCTIONS: 17
* (This index is automatically created/updated by the extension "extdeveval")
*/
-
-
-
-
-
-
-
-
-
-
-
/**
* XML class, Used to create XML output from input rows.
* Doesn't contain a lot of advanced features - pretty straight forward, practical stuff
* @see user_xmlversion, user_wapversion
*/
class t3lib_xml {
- var $topLevelName = 'typo3_test'; // Top element name
- var $XML_recFields = array(); // Contains a list of fields for each table which should be presented in the XML output
+ var $topLevelName = 'typo3_test'; // Top element name
+ var $XML_recFields = array(); // Contains a list of fields for each table which should be presented in the XML output
- var $XMLIndent=0;
- var $Icode='';
- var $XMLdebug=0;
- var $includeNonEmptyValues=0; // if set, all fields from records are rendered no matter their content. If not set, only 'true' (that is '' or zero) fields make it to the document.
- var $lines=array();
+ var $XMLIndent = 0;
+ var $Icode = '';
+ var $XMLdebug = 0;
+ var $includeNonEmptyValues = 0; // if set, all fields from records are rendered no matter their content. If not set, only 'true' (that is '' or zero) fields make it to the document.
+ var $lines = array();
/**
* Constructor, setting topLevelName to the input var
* @param string Top Level Name
* @return void
*/
- function t3lib_xml($topLevelName) {
+ function t3lib_xml($topLevelName) {
$this->topLevelName = $topLevelName;
}
* @param string Commalist of fields names from the table, $table, which is supposed to be rendered in the XML output. If a field is not in this list, it is not rendered.
* @return void
*/
- function setRecFields($table,$list) {
- $this->XML_recFields[$table]=$list;
+ function setRecFields($table, $list) {
+ $this->XML_recFields[$table] = $list;
}
/**
*
* @return string
*/
- function getResult() {
- $content = implode(LF,$this->lines);
+ function getResult() {
+ $content = implode(LF, $this->lines);
return $this->output($content);
}
*
* @return void
*/
- function WAPHeader() {
- $this->lines[]='<?xml version="1.0"?>';
- $this->lines[]='<!DOCTYPE '.$this->topLevelName.' PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">';
- $this->newLevel($this->topLevelName,1);
+ function WAPHeader() {
+ $this->lines[] = '<?xml version="1.0"?>';
+ $this->lines[] = '<!DOCTYPE ' . $this->topLevelName . ' PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">';
+ $this->newLevel($this->topLevelName, 1);
}
/**
*
* @return void
*/
- function renderHeader() {
- $this->lines[]='<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
- $this->lines[]='<!DOCTYPE '.$this->topLevelName.'>';
- $this->newLevel($this->topLevelName,1);
+ function renderHeader() {
+ $this->lines[] = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>';
+ $this->lines[] = '<!DOCTYPE ' . $this->topLevelName . '>';
+ $this->newLevel($this->topLevelName, 1);
}
/**
*
* @return void
*/
- function renderFooter() {
- $this->newLevel($this->topLevelName,0);
+ function renderFooter() {
+ $this->newLevel($this->topLevelName, 0);
}
/**
* @param array Array of attributes in key/value pairs which will be added to the element (tag), $name
* @return void
*/
- function newLevel($name,$beginEndFlag=0,$params=array()) {
- if ($beginEndFlag) {
- $pList='';
- if (count($params)) {
- $par=array();
+ function newLevel($name, $beginEndFlag = 0, $params = array()) {
+ if ($beginEndFlag) {
+ $pList = '';
+ if (count($params)) {
+ $par = array();
foreach ($params as $key => $val) {
- $par[]=$key.'="'.htmlspecialchars($val).'"';
+ $par[] = $key . '="' . htmlspecialchars($val) . '"';
}
- $pList=' '.implode(' ',$par);
+ $pList = ' ' . implode(' ', $par);
}
- $this->lines[]=$this->Icode.'<'.$name.$pList.'>';
+ $this->lines[] = $this->Icode . '<' . $name . $pList . '>';
$this->indent(1);
} else {
$this->indent(0);
- $this->lines[]=$this->Icode.'</'.$name.'>';
+ $this->lines[] = $this->Icode . '</' . $name . '>';
}
}
* @param string The XML content to output
* @return string Output
*/
- function output($content) {
- if ($this->XMLdebug) {
- return '<pre>'.htmlspecialchars($content).'</pre>
- <hr /><font color="red">Size: '.strlen($content).'</font>';
+ function output($content) {
+ if ($this->XMLdebug) {
+ return '<pre>' . htmlspecialchars($content) . '</pre>
+ <hr /><font color="red">Size: ' . strlen($content) . '</font>';
} else {
return $content;
}
* @param boolean If true the XMLIndent var is increased, otherwise decreased
* @return string ->Icode - the prefix string with TAB-chars.
*/
- function indent($b) {
- if ($b) $this->XMLIndent++; else $this->XMLIndent--;
- $this->Icode='';
- for ($a=0;$a<$this->XMLIndent;$a++) {
- $this->Icode.=TAB;
+ function indent($b) {
+ if ($b) {
+ $this->XMLIndent++;
+ } else {
+ $this->XMLIndent--;
+ }
+ $this->Icode = '';
+ for ($a = 0; $a < $this->XMLIndent; $a++) {
+ $this->Icode .= TAB;
}
return $this->Icode;
}
* @param pointer SQL resource pointer, should be reset
* @return void
*/
- function renderRecords($table,$res) {
- while($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
- $this->addRecord($table,$row);
+ function renderRecords($table, $res) {
+ while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
+ $this->addRecord($table, $row);
}
}
* @param array The row to add to XML structure from the table name
* @return void
*/
- function addRecord($table,$row) {
- $this->lines[]=$this->Icode.'<'.$table.' uid="'.$row["uid"].'">';
- $this->indent(1);
- $this->getRowInXML($table,$row);
- $this->indent(0);
- $this->lines[]=$this->Icode.'</'.$table.'>';
+ function addRecord($table, $row) {
+ $this->lines[] = $this->Icode . '<' . $table . ' uid="' . $row["uid"] . '">';
+ $this->indent(1);
+ $this->getRowInXML($table, $row);
+ $this->indent(0);
+ $this->lines[] = $this->Icode . '</' . $table . '>';
}
/**
* @return void
* @access private
*/
- function getRowInXML($table,$row) {
- $fields = t3lib_div::trimExplode(',',$this->XML_recFields[$table],1);
+ function getRowInXML($table, $row) {
+ $fields = t3lib_div::trimExplode(',', $this->XML_recFields[$table], 1);
foreach ($fields as $field) {
- if ($row[$field] || $this->includeNonEmptyValues) {
- $this->lines[]=$this->Icode.$this->fieldWrap($field,$this->substNewline($this->utf8(htmlspecialchars($row[$field]))));
+ if ($row[$field] || $this->includeNonEmptyValues) {
+ $this->lines[] = $this->Icode . $this->fieldWrap($field, $this->substNewline($this->utf8(htmlspecialchars($row[$field]))));
}
}
}
* @param string String content to UTF-8 encode
* @return string Encoded content.
*/
- function utf8($content) {
+ function utf8($content) {
return utf8_encode($content);
}
* @param string Input value
* @return string Processed input value
*/
- function substNewline($string) {
- return str_replace(LF,'<newline/>',$string);
+ function substNewline($string) {
+ return str_replace(LF, '<newline/>', $string);
}
/**
* @param string Value from the field - will be wrapped in the elements.
* @return string The wrapped string.
*/
- function fieldWrap($field,$value) {
- return '<'.$field.'>'.$value.'</'.$field.'>';
+ function fieldWrap($field, $value) {
+ return '<' . $field . '>' . $value . '</' . $field . '>';
}
/**
*
* @return void
*/
- function WAPback() {
- $this->newLevel('template',1);
- $this->newLevel('do',1,array('type'=>'accept','label'=>'Back'));
- $this->addLine('<prev/>');
- $this->newLevel('do');
+ function WAPback() {
+ $this->newLevel('template', 1);
+ $this->newLevel('do', 1, array('type' => 'accept', 'label' => 'Back'));
+ $this->addLine('<prev/>');
+ $this->newLevel('do');
$this->newLevel('template');
}
* @param string Line to add to the $this->lines array
* @return void
*/
- function addLine($str) {
- $this->lines[]=$this->Icode.$str;
+ function addLine($str) {
+ $this->lines[] = $this->Icode . $str;
}
}
-if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_xml.php']) {
+if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_xml.php']) {
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_xml.php']);
}
?>
\ No newline at end of file