Exponential Basic 2.4.0.1 Exponential Basic CMS — PHP Class Reference

eztexttool.php
Go to the documentation of this file.
1 <?php
3 //
4 // $Id: eztexttool.php 9704 2002-08-15 10:27:46Z gl $
5 //
6 // Definition of eZTextTool class
7 //
8 // Created on: <16-Oct-2000 11:06:56 bf>
9 //
10 // This source file is part of Exponential Basic, publishing software.
11 //
12 // Copyright (C) 1999-2001 eZ Systems. All rights reserved.
13 //
14 // This program is free software; you can redistribute it and/or
15 // modify it under the terms of the GNU General Public License
16 // as published by the Free Software Foundation; either version 2
17 // of the License, or (at your option) any later version.
18 //
19 // This program is distributed in the hope that it will be useful,
20 // but WITHOUT ANY WARRANTY; without even the implied warranty of
21 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 // GNU General Public License for more details.
23 //
24 // You should have received a copy of the GNU General Public License
25 // along with this program; if not, write to the Free Software
26 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, US
27 //
28
31
54 class eZTextTool
55 {
65 static public function nl2br( $string, $xhtml=true )
66 {
67 if ( !is_bool( $xhtml ) )
68 {
69 return str_replace( "\n", "$xhtml \n", $string );
70 }
71 if ( !is_null( $string ) )
72 {
73 return nl2br($string, $xhtml);
74 } else {
75 return $string;
76 }
77 }
78
83 static public function addPre( $string, $char=">" )
84 {
85 if ( !is_string( $string ) )
86 {
87 $string = "";
88 }
89
90 $string =& wordwrap( $string, 60, "\n" );
91 return preg_replace( "#^#m", "$char ", $string );
92 }
93
105 static public function capitalize( $string, $bigClass="h1bigger" )
106 {
107 $string = strtoupper( $string );
108
109 for ( $i=0; $i<strlen( $string ); $i++)
110 {
111 $string2 .= $string[$i] . " ";
112 }
113
114 $string = trim( $string2 );
115
116 $string = str_replace ("�", "�", $string );
117 $string = str_replace ("�", "�", $string );
118 $string = str_replace ("�", "�", $string );
119
120 $string = preg_replace( "#( |^)([a-zA-Z������] )#", "\\1<span class=\"$bigClass\">\\2</span>", $string );
121
122 // $string = preg_replace( "#( |^)([^ ])#", "\\1<span class=\"$bigClass\">\\2</span>", $string );
123
124 $string = str_replace ( " ", "&nbsp;&nbsp;", $string );
125
126 return $string;
127 }
128
135 static public function boolText( $value )
136 {
137 return $value?'true':'false';
138 }
139
144 static public function htmlspecialchars( $string )
145 {
146 if( !is_null( $string ) )
147 return stripslashes( htmlspecialchars( $string ) );
148
149 return false;
150 }
151
156 static public function fixhtmlentities( $string )
157 {
158 $string = preg_replace( "/&amp;#([0-9]+);/", "&#\\1;", $string );
159 return $string;
160 }
161
169 static public function lineSplit( $in, $len = 0, $size = 72 )
170 {
171 $tmp = "";
172 $pad = str_pad( $tmp, $len, " ", STR_PAD_LEFT );
173 $temptext = "";
174 $temparray = explode( " ", $in );
175 $i = 0;
176 while( $i <= count( $temparray ) )
177 {
178 while( ( strlen( $pad . $temptext . " " . $temparray[$i] ) < $size )
179 && ($i <= count( $temparray ) ) )
180 {
181 $temptext = $temptext." ".$temparray[$i];
182 $i++;
183 }
184 $out = $out."\n" . $pad . $temptext;
185 $temptext = $temparray[$i];
186 $i++;
187 }
188 return $out;
189 }
190
220 static public function parseXML( &$xml, $inline_children = false )
221 {
222 $msg = array();
223 eZTextTool::parseXMLPart( $xml, $msg, $inline_children );
224 return $msg;
225 }
226
232 static public function parseXMLPart( &$xml, &$msg, $inline_children )
233 {
234 foreach( $xml->children as $child )
235 {
236 $part = array();
237 if ( isset( $child->attributes ) )
238 {
239 foreach( $child->attributes as $attr )
240 {
241 if ( $attr->type == 2 )
242 {
243 $part[$attr->name] =& $attr->content;
244 }
245 }
246 }
247 if ( isset( $child->children ) )
248 {
249 if ( $inline_children )
250 {
251 eZTextTool::parseXMLPart( $child, $part, $inline_children );
252 }
253 else
254 {
255 $children = array();
256 eZTextTool::parseXMLPart( $child, $children, $inline_children );
257 $part["children"] =& $children;
258 }
259 }
260 $msg[$child->name] = $part;
261 }
262 }
263 }
264
265 ?>
$i
$i
Definition: admin/adlist.php:91
$tmp
$tmp
Definition: bugview.php:99
eZTextTool
Definition: eztexttool.php:55
eZTextTool\addPre
static addPre( $string, $char=">")
Definition: eztexttool.php:83
eZTextTool\parseXMLPart
static parseXMLPart(&$xml, &$msg, $inline_children)
Definition: eztexttool.php:232
eZTextTool\capitalize
static capitalize( $string, $bigClass="h1bigger")
Definition: eztexttool.php:105
eZTextTool\parseXML
static parseXML(&$xml, $inline_children=false)
Definition: eztexttool.php:220
eZTextTool\htmlspecialchars
static htmlspecialchars( $string)
Definition: eztexttool.php:144
eZTextTool\nl2br
static nl2br( $string, $xhtml=true)
Definition: eztexttool.php:65
eZTextTool\boolText
static boolText( $value)
Definition: eztexttool.php:135
eZTextTool\fixhtmlentities
static fixhtmlentities( $string)
Definition: eztexttool.php:156
eZTextTool\lineSplit
static lineSplit( $in, $len=0, $size=72)
Definition: eztexttool.php:169
$msg
$msg
Definition: editmessage.php:47
$size
if($file_debug) $size
Definition: ezfilemanager/user/filedownload.php:165
$part
$part
Definition: tag.php:46
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.