00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 class eZTextTool
00039 {
00040
00041
00042
00043
00044
00045 function highlightHTML( $input )
00046 {
00047 $input = str_replace( "<", "<", $input );
00048 $input = str_replace( ">", ">", $input );
00049
00050 $input = preg_replace( "#<(.*?)>#m", "<font color='red'><$1></font>", $input );
00051
00052 return $input;
00053 }
00054
00055 function highlightPHP()
00056 {
00057
00058 }
00059
00060 function concatDelimited()
00061 {
00062 $numargs = func_num_args();
00063 $argList = func_get_args();
00064 $text = null;
00065 if ( $numargs > 1 )
00066 {
00067 $delimit = $argList[0];
00068 $text = implode( $delimit, eZTextTool::arrayFlatten( array_splice( $argList, 1 ) ) );
00069 }
00070 return $text;
00071 }
00072
00073 function concat()
00074 {
00075 $numargs = func_num_args();
00076 $argList = func_get_args();
00077 $text = null;
00078 if ( $numargs > 0 )
00079 {
00080 $text = implode( '', eZTextTool::arrayFlatten( $argList ) );
00081 }
00082 return $text;
00083 }
00084
00085 function arrayFlatten( $array )
00086 {
00087 $flatArray = array();
00088 $expandItems = $array;
00089 $done = false;
00090 while ( !$done )
00091 {
00092 $checkList = $expandItems;
00093 $leftOvers = array();
00094 $foundArray = false;
00095 foreach ( array_keys( $checkList ) as $key )
00096 {
00097 $item = $checkList[$key];
00098 if ( is_array ( $item ) )
00099 {
00100 $leftOvers = array_merge( $leftOvers, $item );
00101 $foundArray = true;
00102 }
00103 else
00104 {
00105 if ( $foundArray )
00106 $leftOvers[] = $item;
00107 else
00108 $flatArray[] = $item;
00109 }
00110 }
00111 $expandItems = $leftOvers;
00112 if ( count( $expandItems ) == 0 )
00113 {
00114 $done = true;
00115 }
00116 }
00117 return $flatArray;
00118 }
00119 }
00120 ?>