See Release Notes
Long Term Support Release
Differences Between: [Versions 39 and 310] [Versions 39 and 311]
1 <?php 2 /** 3 * XMPPHP: The PHP XMPP Library 4 * Copyright (C) 2008 Nathanael C. Fritz 5 * This file is part of SleekXMPP. 6 * 7 * XMPPHP is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License as published by 9 * the Free Software Foundation; either version 2 of the License, or 10 * (at your option) any later version. 11 * 12 * XMPPHP is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with XMPPHP; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 * 21 * @category xmpphp 22 * @package XMPPHP 23 * @author Nathanael C. Fritz <JID: fritzy@netflint.net> 24 * @author Stephan Wentz <JID: stephan@jabber.wentz.it> 25 * @author Michael Garvin <JID: gar@netflint.net> 26 * @copyright 2008 Nathanael C. Fritz 27 */ 28 29 /** 30 * XMPPHP XML Object 31 * 32 * @category xmpphp 33 * @package XMPPHP 34 * @author Nathanael C. Fritz <JID: fritzy@netflint.net> 35 * @author Stephan Wentz <JID: stephan@jabber.wentz.it> 36 * @author Michael Garvin <JID: gar@netflint.net> 37 * @copyright 2008 Nathanael C. Fritz 38 * @version $Id$ 39 */ 40 class XMPPHP_XMLObj { 41 /** 42 * Tag name 43 * 44 * @var string 45 */ 46 public $name; 47 48 /** 49 * Namespace 50 * 51 * @var string 52 */ 53 public $ns; 54 55 /** 56 * Attributes 57 * 58 * @var array 59 */ 60 public $attrs = array(); 61 62 /** 63 * Subs? 64 * 65 * @var array 66 */ 67 public $subs = array(); 68 69 /** 70 * Node data 71 * 72 * @var string 73 */ 74 public $data = ''; 75 76 /** 77 * Constructor 78 * 79 * @param string $name 80 * @param string $ns 81 * @param array $attrs 82 * @param string $data 83 */ 84 public function __construct($name, $ns = '', $attrs = array(), $data = '') { 85 $this->name = strtolower($name); 86 $this->ns = $ns; 87 if(is_array($attrs) && count($attrs)) { 88 foreach($attrs as $key => $value) { 89 $this->attrs[strtolower($key)] = $value; 90 } 91 } 92 $this->data = $data; 93 } 94 95 /** 96 * Dump this XML Object to output. 97 * 98 * @param integer $depth 99 */ 100 public function printObj($depth = 0) { 101 print str_repeat("\t", $depth) . $this->name . " " . $this->ns . ' ' . $this->data; 102 print "\n"; 103 foreach($this->subs as $sub) { 104 $sub->printObj($depth + 1); 105 } 106 } 107 108 /** 109 * Return this XML Object in xml notation 110 * 111 * @param string $str 112 */ 113 public function toString($str = '') { 114 $str .= "<{$this->name} xmlns='{$this->ns}' "; 115 foreach($this->attrs as $key => $value) { 116 if($key != 'xmlns') { 117 $value = htmlspecialchars($value); 118 $str .= "$key='$value' "; 119 } 120 } 121 $str .= ">"; 122 foreach($this->subs as $sub) { 123 $str .= $sub->toString(); 124 } 125 $body = htmlspecialchars($this->data); 126 $str .= "$body</{$this->name}>"; 127 return $str; 128 } 129 130 /** 131 * Has this XML Object the given sub? 132 * 133 * @param string $name 134 * @return boolean 135 */ 136 public function hasSub($name, $ns = null) { 137 foreach($this->subs as $sub) { 138 if(($name == "*" or $sub->name == $name) and ($ns == null or $sub->ns == $ns)) return true; 139 } 140 return false; 141 } 142 143 /** 144 * Return a sub 145 * 146 * @param string $name 147 * @param string $attrs 148 * @param string $ns 149 */ 150 public function sub($name, $attrs = null, $ns = null) { 151 #TODO attrs is ignored 152 foreach($this->subs as $sub) { 153 if($sub->name == $name and ($ns == null or $sub->ns == $ns)) { 154 return $sub; 155 } 156 } 157 } 158 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body