Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

ezdomnode.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: ezdomnode.php 8837 2001-12-21 15:37:48Z bf $
5 //
6 // Definition of eZDOMNode class
7 //
8 // Created on: <16-Nov-2001 12:11:43 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 // Copyright (C) 1999-2000 eZ systems as
12 //
13 // This program is free software; you can redistribute it and/or
14 // modify it under the terms of the GNU General Public License
15 // as published by the Free Software Foundation; either version 2
16 // of the License, or (at your option) any later version.
17 //
18 // This program is distributed in the hope that it will be useful,
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 // GNU General Public License for more details.
22 //
23 // You should have received a copy of the GNU General Public License
24 // along with this program; if not, write to the Free Software
25 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
26 //
27
30
34 class eZDOMNode
35 {
38 function __construct( )
39 {
40 }
41
45 function &toString()
46 {
47 $ret = "";
48 switch ( $this->name )
49 {
50 case "text" :
51 {
52 $tagContent = $this->content;
53
54 $tagContent =& str_replace( "&", "&amp;", $tagContent );
55 $tagContent =& str_replace( ">", "&gt;", $tagContent );
56 $tagContent =& str_replace( "<", "&lt;", $tagContent );
57 $tagContent =& str_replace( "'", "&apos;", $tagContent );
58 $tagContent =& str_replace( '"', "&quot;", $tagContent );
59
60 $ret =& $tagContent;
61 }break;
62
63 case "cdata-section" :
64 {
65 $ret = "<![CDATA[";
66 $ret .= $this->content;
67 $ret .= "]]>";
68 }break;
69
70 default :
71 {
72 $isOneLiner = false;
73 // check if it's a oneliner
74 if ( count( $this->children ) == 0 and ( $this->content == "" ) )
75 $isOneLiner = true;
76
77
78 $attrStr = "";
79 // generate attributes string
80 if ( count( $this->attributes ) > 0 )
81 foreach ( $this->attributes as $attr )
82 {
83 $attrStr .= " " . $attr->name . "=\"" . $attr->content . "\" ";
84
85 }
86
87 if ( $isOneLiner )
88 $oneLinerEnd = " /";
89 else
90 $oneLinerEnd = "";
91
92 $ret = "<" . $this->name . $attrStr . $oneLinerEnd . ">";
93
94 if ( count( $this->children ) > 0 )
95 foreach ( $this->children as $child )
96 {
97 $ret .= $child->toString();
98 }
99
100 if ( !$isOneLiner )
101 $ret .= "</" . $this->name . ">";
102
103 }break;
104
105 }
106
107
108 return $ret;
109 }
110
111
113 var $name;
114
116 var $type;
117
119 var $content;
120
122 var $children;
123
125 var $attributes;
126 }
127
128 ?>
eZDOMNode
Definition: ezdomnode.php:35
eZDOMNode\toString
& toString()
Definition: ezdomnode.php:45
eZDOMNode\__construct
__construct()
Definition: ezdomnode.php:38
eZDOMNode\$type
$type
Type of the DOM node.
Definition: ezdomnode.php:116
eZDOMNode\$attributes
$attributes
Attributes.
Definition: ezdomnode.php:125
eZDOMNode\$name
$name
Name of the node.
Definition: ezdomnode.php:113
eZDOMNode\$children
$children
Subnodes.
Definition: ezdomnode.php:122
eZDOMNode\$content
$content
Content of the node.
Definition: ezdomnode.php:119
$ret
$ret
Definition: ezsitemanager/admin/filelist.php:88
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.