![]() |
- Developper API
2.0.5
|
00001 <?php 00010 require_once("Config.php"); 00011 00018 function startsWith($str, $needle) 00019 { 00020 $length = strlen($needle); 00021 return (substr($str, 0, $length) == $needle); 00022 } 00023 00030 function endsWith($haystack, $needle) 00031 { 00032 $length = strlen($needle); 00033 $start = $length * -1; //negative 00034 return (substr($haystack, $start) == $needle); 00035 } 00036 00042 function array_copy ($aSource) 00043 { 00044 // check if input is really an array 00045 if (!is_array($aSource)) { 00046 throw new Exception("Input is not an Array"); 00047 } 00048 00049 // initialize returned array 00050 $aRetAr = array(); 00051 00052 // get array keys 00053 $aKeys = array_keys($aSource); 00054 // get array values 00055 $aVals = array_values($aSource); 00056 00057 // loop through array and assign keys+values to new return array 00058 for ($x=0;$x<count($aKeys);$x++) { 00059 // clone if object 00060 if (is_object($aVals[$x])) { 00061 $aRetAr[$aKeys[$x]]=clone $aVals[$x]; 00062 // recursively add array 00063 } elseif (is_array($aVals[$x])) { 00064 $aRetAr[$aKeys[$x]]=array_copy ($aVals[$x]); 00065 // assign just a plain scalar value 00066 } else { 00067 $aRetAr[$aKeys[$x]]=$aVals[$x]; 00068 } 00069 } 00070 00071 return $aRetAr; 00072 } 00073 00077 function debug($message) 00078 { 00079 global $debugEnable; 00080 00081 if($debugEnable) 00082 { 00083 $trace = array_shift( debug_backtrace() );; 00084 00085 $from = array_pop( explode('/', $trace["file"])); 00086 $line = $trace["line"]; 00087 $function = $trace["function"]; 00088 00089 echo "<pre style='background-color:#F0C771;padding:10px;'>"; 00090 echo "<b>DEBUG:</b> $from - line: $line<hr />"; 00091 print_r($message); 00092 echo "</pre>"; 00093 } 00094 } 00095 00099 function info($message) 00100 { 00101 global $infoEnable; 00102 00103 if($infoEnable) 00104 { 00105 $trace = array_shift( debug_backtrace() );; 00106 00107 $from = array_pop( explode('/', $trace["file"])); 00108 $line = $trace["line"]; 00109 $function = $trace["function"]; 00110 00111 echo "<pre style='background-color:#BFE289;padding:10px;'>"; 00112 echo "<b>INFO:</b> $from - line: $line<hr />"; 00113 print_r($message); 00114 echo "</pre>"; 00115 } 00116 } 00117 00121 function error($message) 00122 { 00123 global $errorEnable; 00124 00125 if($errorEnable) 00126 { 00127 $trace = array_shift( debug_backtrace() );; 00128 00129 $from = array_pop( explode('/', $trace["file"])); 00130 $line = $trace["line"]; 00131 $function = $trace["function"]; 00132 00133 echo "<pre style='background-color:#FFA3A5;padding:10px;'>"; 00134 echo "<b>ERROR:</b> $from - line: $line<hr />"; 00135 print_r($message); 00136 echo "</pre>"; 00137 } 00138 } 00139 00143 function test($title,$message) 00144 { 00145 global $testEnable; 00146 00147 if($testEnable) 00148 { 00149 $trace = array_shift( debug_backtrace() );; 00150 00151 $from = array_pop( explode('/', $trace["file"])); 00152 $line = $trace["line"]; 00153 $function = $trace["function"]; 00154 00155 echo "<pre style='background-color:#9EC2E7;padding:10px;'>"; 00156 echo "<b>TEST: $title</b><br />from: $from - line: $line<hr />"; 00157 print_r($message); 00158 echo "</pre>"; 00159 } 00160 } 00161 00165 function opentest($title) 00166 { 00167 global $testEnable; 00168 00169 if($testEnable) 00170 { 00171 $trace = array_shift( debug_backtrace() );; 00172 00173 $from = array_pop( explode('/', $trace["file"])); 00174 $line = $trace["line"]; 00175 $function = $trace["function"]; 00176 00177 echo "<pre style='background-color:#D5E6F8;padding:10px;'>"; 00178 echo "<b>OPEN TEST: $title</b><br />from $from - line:$line<hr />"; 00179 } 00180 } 00181 00185 function closetest($title,$message) 00186 { 00187 global $testEnable; 00188 00189 if($testEnable) 00190 { 00191 echo "<hr />"; 00192 echo "<b>CLOSE TEST: $title - $message</b>"; 00193 echo "</pre>"; 00194 } 00195 } 00196 00201 function hasChildren($SXMLElement) 00202 { 00203 foreach($SXMLElement->children() as $child) 00204 { 00205 return true; 00206 } 00207 00208 return false; 00209 } 00210 00218 function getSXMLElementWithNameSpace($rootnode,$namespace, $recursively) 00219 { 00220 $xmlElementsArray = array(); 00221 00222 00223 $keyArray = (is_array($recursively)) ? $recursively : array(); 00224 $propertiesElement = $rootnode->children($namespace); 00225 00226 foreach($propertiesElement as $propertyElement) 00227 { 00228 array_push($xmlElementsArray,$propertyElement); 00229 } 00230 00231 if($recursively) 00232 { 00233 foreach($rootnode->children() as $child) 00234 { 00235 $xmlElementsArray = array_merge($xmlElementsArray,getSXMLElementWithNameSpace($child,$namespace,$recursively)); 00236 } 00237 } 00238 00239 return $xmlElementsArray; 00240 } 00241 ?>