Blame view

class_D.inc.php 32 KB
Frederick committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php
/**
 *	@filesource 	class_D.inc.php
 *
 * @category losp
 * @copyright Copyright by mensch.coop e.G. 2009
 * @mailto	dev [at] mensch.coop
 * @version 0.4.200901
 * @link http://mensch.coop
 */


/**
 * Klasse ist für Ausgaben zuständig die
 * 	a) nur für die Entwicklung relevant sind, also nicht für das Live System
 *  b) umgeleitet werden können, also nicht einfach nur ausgegeben werden, sondern in eine extra Datei
 */
class D {

sn committed
20 21 22 23 24 25
	public static function printSession($param_string="", $param_print=true, $param_force=false, $param_htmlentities=false) {
		D::show($_SESSION, '$_SESSION   '.$param_string, $param_print, $param_force, $param_htmlentities);
		D::show($HTTP_SESSION_VARS, '$HTTP_SESSION_VARS  '.$param_string, $param_print, $param_force, $param_htmlentities);
		
	}
	
26 27
	const ALL = 'ALL';
	
Frederick committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
	private static $echo_count = 0;
	public static $echo_lines = array();

	private static function html2text($param_htmlstring) {

		$html_elements = array();
		$text_elements = array();

		foreach(mcCONST::$HTMLTAGS2TEXT as $htmlstags => $stringels) {
			$html_elements[] = $htmlstags;
			$text_elements[] = $stringels;
		}

//		$param_htmlstring = str_replace(mcCONST::LINEBREAK, '', $param_htmlstring);

		$textstring = str_replace($html_elements, $text_elements, $param_htmlstring);
44 45 46 47
		
		
		$textstring = strip_tags($textstring);
		
Frederick committed
48 49 50 51 52 53 54 55 56 57
		return $textstring;
	}


	public static function e($param_string, $param_print=true, $param_force=false) {
		self::new_echo($param_string, $param_print, $param_force);
	}

	public static function printToFile($param_filename, $param_kindof = null) {

58 59 60
		global $__mc_D_LOGFILE_ONLY_USER;


Frederick committed
61 62 63
		if($param_filename && !empty(self::$echo_lines)) {
			$file_content = '';
			foreach(self::$echo_lines as $line_nr => $line) {
64
				
65
				if($__mc_D_LOGFILE_ONLY_USER === $line['print'] || D::ALL ===$line['print']) {
66 67
					$file_content .= $line_nr.':'.mcCONST::TAB.self::html2text($line['line']).mcCONST::LINEBREAK;
				}
Frederick committed
68 69 70 71 72 73
			}
			
			mcFile::write($param_filename, $file_content, $param_kindof);
		}
	}

sn committed
74
	public static function printToScreen($param_return=false) {
Frederick committed
75

76 77
		global $__mc_D_LOGFILE_ONLY_USER;
		
Frederick committed
78 79 80
		if(!empty(self::$echo_lines)) {
			$screen_content = '<br /><br /><br />';
			foreach(self::$echo_lines as $line_nr => $line) {
81 82 83 84 85
//				echo '$__mc_D_LOGFILE_ONLY_USER = '.$__mc_D_LOGFILE_ONLY_USER.' == '.$line['print'].'<br/>';
//				if($__mc_D_LOGFILE_ONLY_USER === $line['print']) {
					$screen_content .= $line['line'];
//				}
				
Frederick committed
86
			}
sn committed
87 88 89 90 91 92
			if($param_return) {
				return $screen_content;
			} else {
				echo $screen_content;
			}
			
Frederick committed
93 94 95
		}
	}

sn committed
96 97 98 99
	
	public static function printToHtmlFile($param_filename, $param_kindof = 'w') {

		$screen_content = D::printToScreen(true);
sn committed
100 101
		
		$html_beginn = '
sn committed
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
			<html>
				<header>
					<title>D:'.$_SERVER['REQUEST_URI'].'</title>
					<script type="text/javascript">
					   function showText(param_divId) {
							var spoiler = document.getElementById(param_divId);
							var button  = document.getElementById(\'button\');

							if (spoiler.style.display == \'block\') {
							   spoiler.style.display=\'none\';
							   button.value = \'Text einblenden\';
							} else {

							  spoiler.style.display=\'block\';
							  button.value = \'Text ausblenden\';
							 }
							return false;
					   }
					</script>						
				</header>
				<body>
					';
					$html_beginn .= 'SCRIPT_FILENAME:'.$_SERVER['SCRIPT_FILENAME'].'';
					$html_beginn .= '<h1>'.$_SERVER['SERVER_NAME'].'/'.$_SERVER['REQUEST_URI'].'</h1>';

					$html_end = '
				</body>
			</html>
sn committed
130 131 132
		';
		
		mcFile::write($param_filename, $html_beginn.$screen_content.$html_end, $param_kindof);
sn committed
133 134 135
	}
	
	
Frederick committed
136 137 138 139 140 141
	public static function printPDOQuery($param_query, array $param_bindValueArray=null, $param_print=true, $param_force=false) {
//		$return = '';

		foreach($param_bindValueArray as $string => $value) {
			$param_query = str_replace($string, $value, $param_query);
		}
Frederick d. Maus committed
142 143
//		D::li(highlight_string($param_query, true));
		D::li($param_query, $param_print, $param_force);
Frederick committed
144 145 146 147 148 149 150
		D::show($param_bindValueArray, $param_query);
	}

	private static function new_echo($param_string, $param_print=true, $param_force=false) {


		if(trim($param_string)) {
151 152
//			if($param_htmlentities)
//				$param_string=htmlentities($param_string);
Frederick committed
153 154 155 156 157 158
			self::$echo_lines[self::$echo_count] = array(
				'line'	=> $param_string,
				'print' => $param_print,
				'force' => $param_force
			);
			if($param_force) {
159 160
//				echo 'FORCE:'.mcCONST::TAB.$param_string;
				echo 'FORCE:'.mcCONST::TAB.$param_string.'<br/>';
Frederick committed
161
			}
162
//			echo $param_string;
Frederick committed
163 164 165 166
			self::$echo_count++;
		}
	}

167 168 169 170 171 172 173 174 175 176 177 178 179 180
	/**
	 * function htmlencode a string or array values () 
	 * 
	 * @param array/string $param_val
	 */
	public static function htmlencode_arrayvalues($param_val){
		if(is_array($param_val)){
			foreach($param_val as $key => $value){
				$param_val[$key]=self::htmlencode_arrayvalues($value);
			};
			return $param_val;
		}
		return htmlentities($param_val);
	}
Frederick committed
181
	/**
sn committed
182 183 184 185 186 187 188 189
	 * 
	 * @param type $param_val
	 * @param type $param_string
	 * @param type $param_loglevel 1, 2 (classname / array), 3 (pub vars), 4 (fnc),  5 (getData), 6 (Objekt ausgeben)
	 * @param type $param_print
	 * @param type $param_force
	 * @param type $param_htmlentities
	 */
sn committed
190
	public static function s($param_val, $param_string="", $param_loglevel=5, $param_print=true, $param_force=false, $param_htmlentities=false) {
sn committed
191 192 193 194
		D::show($param_val, $param_string, $param_print, $param_force, $param_htmlentities, $param_loglevel); 
	}
	
	/**
Frederick committed
195 196 197
	 * Funktion zeigt ein Objekt/Array html strukturiert an
	 *	anstelle von var_dump
	 */
sn committed
198 199 200
	public static function show($param_val, $param_string="", $param_print=true, $param_force=false, $param_htmlentities=false, $param_loglevel=10) {
//$param_loglevel=2;
		$result = '';
sn committed
201
		
Frederick committed
202
//		self::new_echo("<br>______________________<br>", $param_print, $param_force);
sn committed
203 204 205 206 207
		
		if($param_loglevel>0) {
			self::printCurrentFunction($param_print,"<br>______________________<br>");
		}
		
Frederick committed
208 209

//		self::new_echo("<b>show(".$param_string.")</b>", $param_print, $param_force);
sn committed
210
		$string_show = "<br /><b>show(".$param_string.")</b> $param_val<br />";
sn committed
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260
		if($param_loglevel>1) {
			if(is_object($param_val) && get_class($param_val)=='DOMElement') {
				D::showdomelement($param_val, $string_show.$param_string,$param_print, $param_force);
			} else {
				if(is_array($param_val)) {
					$string_show .= "count(".$param_val.") = ".count($param_val)."";
					$result =$param_val;
	//				self::new_echo("<br/>count(".$param_val.") = ".count($param_val)."", $param_print, $param_force);
				} else if(is_object($param_val)) {
					
					$result = array();
						
					$parent = get_parent_class($param_val);
					while($parent) {
						$parents .= ' extends <b>'.$parent.'</b>';
						$parent = get_parent_class($parent);
					}
					
					$result['classname'] = '<b>'.get_class($param_val).'</b>'.$parents;

					if($param_loglevel>2) {
						$objvars = get_object_vars($param_val);
						sort($objvars);						
						$result['objvars'] = $objvars;
						
						$objfncs = get_class_methods(get_class($param_val));
						sort($objfncs);

						if($param_loglevel>3) {
							
							if($param_loglevel>4) {
								if(array_search('getData', $objfncs)) {
									try {
										$result['getData'] = $param_val->getData();
									} catch (Exception $exc) {
										echo $exc->getTraceAsString();
									}


								}
							}								
							
							
						}
						$result['objfncs'] = $objfncs;
						
						if($param_loglevel>5) {
							$result['obj'] = $param_val;
						}
					}
Frederick committed
261

sn committed
262 263
				} else {
					$result = $param_val;
sn committed
264
				}
265
			}
Frederick committed
266
		}
sn committed
267 268 269 270 271 272 273 274 275 276
	
		$string_show .= "<pre>";
		if($param_htmlentities){
			$result=self::htmlencode_arrayvalues($result);
		}
		try {
			self::new_echo($string_show.print_r($result, true).'"</pre>"', $param_print, $param_force);
		} catch (Exception $exc) {
			echo $exc->getTraceAsString();
		}
Frederick committed
277 278
	}

279
	public static function cf($param_string='', $param_print=true, $param_force=false) {
280
		D::printCurrentFunction($param_print, $param_string, true, $param_force);
Frederick d. Maus committed
281 282
	}
	
Frederick committed
283 284 285 286 287
	/**
	 * Funktion zeigt html liste
	 * <li>$param_string</li>
	 */
	public static function li($param_string, $param_print=true, $param_force=false) {
Frederick d. Maus committed
288 289
		D::printCurrentFunction($param_print);
		D::new_echo("<li>".$param_string."</li>", $param_print, $param_force);
Frederick committed
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324
	}
	public static function kindof($param_kindof, $param_string="", $param_print=true, $param_force=false) {
		self::printCurrentFunction($param_print);
		self::new_echo("<b>kindof(".$param_string.")</b><pre>", $param_print, $param_force);
		if(is_array($param_kindof)) {
			$var = 'Array count('.count($param_kindof).')';
		} else if(is_object($param_kindof)) {
			$var = 'Object('.get_class($param_kindof).') ';
			if(is_subclass_of($param_kindof, 'MultimediaText')) {
				$var .= ' extends MultimediaText Subject('.$param_kindof->getObjVar('Subject').')';
			} else if(get_class($param_kindof)=='MultimediaText') {
				$var .= ' Subject('.$param_kindof->getObjVar('Subject').')';
			}
		} else if(is_int($param_kindof)) {
			$var = 'Int('.$param_kindof.')';
		} else if(is_bool($param_kindof)) {
			$var = 'Bool('.$param_kindof.')';
		} else if(is_string($param_kindof)) {
			$var = 'String('.$param_kindof.')';
		} else {
			$var = gettype($param_kindof).'';
		}
		$var .= ' = ('.$param_kindof.')';
		if($param_kindof) {
			$var .= ' if('.$param_kindof.' ==> ?true?)';
		} else {
			$var .= ' else if(!'.$param_kindof.') ==> ?false?';
		}
		self::new_echo("<li>".$var."</li>", $param_print, $param_force);
	}
	/**
	 * Funktion zeigt html unter liste
	 * <ul><li>$param_string</li></ul>
	 */
	public static function ulli($param_string, $param_print=true, $param_force=false) {
325
//		self::printCurrentFunction($param_print);
Frederick committed
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359
		self::new_echo("<ul><li>".$param_string."</li></ul>", $param_print, $param_force);
	}
	/**
	 * Funktion zeigt html Überschrift 1 an
	 * <h1>$param_string</h1>
	 */
	public static function h1($param_string, $param_print=true, $param_force=false) {
//		self::new_echo("<br><br>|------------------------------------------------------<br>", $param_print, $param_force);
//		self::backtrace();
		self::new_echo("<h1>".$param_string."</h1>", $param_print, $param_force);
	}
	/**
	 * Funktion zeigt html Überschrift 2 an
	 * <h2>$param_string</h2>
	 */
	public static function h2($param_string, $param_print=true, $param_force=false) {
		self::new_echo("<h2>".$param_string."</h2>", $param_print, $param_force);
	}
	/**
	 * Funktion zeigt html Überschrift 3 an
	 * <h3>$param_string</h3>
	 */
	public static function h3($param_string, $param_print=true, $param_force=false) {
		self::new_echo("<h3>".$param_string."</h3>", $param_print, $param_force);
	}

	/**
	 * Funktion zeigt html Absatz an
	 * <p>$param_string</p>
	 */
	public static function p($param_string, $param_print=true, $param_force=false) {
		self::new_echo("<p>".$param_string."</p>", $param_print, $param_force);
	}

sn committed
360 361 362
	public static function compareFe($param_firstArray, $param_secondArray, $param_string=null, $param_logdepth=10, $param_ul=array(), $param_keystring='', $param_print=true, $param_force=false) {
		if($param_logdepth>=0) {
			if(!is_null($param_string)) {
sn committed
363
				$param_string = '<b>'.$param_string.'</b>';
sn committed
364 365 366 367
				$param_string .= ' countFirstArray('.count($param_firstArray).') countSecondArray('.count($param_secondArray).') loglevel('.$param_logdepth.') ||   print  '.$param_Array;
//				$eqal = mcArray::compare($param_firstArray, $param_secondArray);
				
//				$param_string .= 'equal('.$eqal.')';
sn committed
368
				D::li($param_string, $param_print, $param_force);
sn committed
369 370 371
			}
			
			
sn committed
372
			self::new_echo('<table border="1" width="100%">', $param_print, $param_force);
sn committed
373 374
			self::new_echo('<tr valign="top">', $param_print, $param_force);
			
sn committed
375
			self::new_echo('<td valign="top" width="50%">', $param_print, $param_force);
sn committed
376 377 378
			D::fe($param_firstArray, null, $param_logdepth, $param_ul,'first Param', $param_print, $param_force);
			self::new_echo('</td>', $param_print, $param_force);
			
sn committed
379
			self::new_echo('<td valign="top" width="50%">', $param_print, $param_force);
sn committed
380 381 382 383 384 385 386 387
			D::fe($param_secondArray, null, $param_logdepth, $param_ul,'second Param', $param_print, $param_force);
			self::new_echo('</td>', $param_print, $param_force);			
			
			self::new_echo('</tr>', $param_print, $param_force);
			self::new_echo('</table>', $param_print, $param_force);
		}
	}
	private static $feRekursivContent= 0;
sn committed
388 389 390
	/**
	 * 
	 * @param type $param_Array
sn committed
391
	 * @param string $param_string
sn committed
392 393 394 395
	 * @param type $param_logdepth
	 * @param type $param_ul
	 * @param type $param_keystring
	 */
sn committed
396
	public static function fe($param_Array, $param_string=null, $param_logdepth=10, $param_ul=array(), $param_keystring='', $param_print=true, $param_force=false) {
sn committed
397 398
//		D::ulli(':::::::::::::: '.$param_logdepth.' - '.$param_Array);
		if($param_logdepth>=0) {
sn committed
399
			if(!is_null($param_string)) {
sn committed
400
				$param_string = '<b>'.$param_string.'</b>';
sn committed
401 402
				$param_string .= ' count('.count($param_Array).') loglevel('.$param_logdepth.') ||   print  '.$param_Array;
				D::li($param_string, $param_print, $param_force);
sn committed
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
			}
			$param_logdepth--;
			$param_ul['start'] .= '<ul>';
			$param_ul['stop'] .= '</ul>';

			$info_toArray = '';
			if(is_array($param_Array)) {
				$var_value2Array = $param_Array;

			} else if(is_object($param_Array)) {
				$objfncs = get_class_methods(get_class($param_Array));
				if(array_search('getData', $objfncs)) {
					$var_value2Array = $param_Array->getData();
					$info_toArray = '(Obj->getData)';
				} if(array_search('toArray', $objfncs)) {
					$var_value2Array = $param_Array->toArray();
					$info_toArray = '(Obj->toArray)';
				} else {
					$var_value2Array = $param_Array;
				}
			} else if($unserialize = unserialize($param_Array)) {
				$var_value2Array = $unserialize;
				$info_toArray = '(str2unserialize)';
sn committed
426
				$param_Array = '<i title="'.  htmlentities($param_Array).'">'.substr($param_Array, 0, 20).'</i>';
sn committed
427 428 429 430
			} else {
				$var_value2Array = $param_Array;
			}
			
sn committed
431 432

			
sn committed
433
			if(is_array($var_value2Array)) {
sn committed
434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
				
				//				self::new_echo('
				//<script type="text/javascript">
				//   function showText(param_divId) {
				//        var spoiler = document.getElementById(param_divId);
				//		var button  = document.getElementById(\'button\');
				// 
				//	    if (spoiler.style.display == \'block\') {
				//		   spoiler.style.display=\'none\';
				//		   button.value = \'Text einblenden\';
				//		} else {
				// 
				//	      spoiler.style.display=\'block\';
				//		  button.value = \'Text ausblenden\';
				//		 }
				//		return false;
				//   }
				//</script>', $param_print, $param_force);
				self::$feRekursivContent++;
				$divId='spoiler_'.self::$feRekursivContent;
				self::new_echo('<style type="text/css">
					#'.$divId.' {
						display: none;
					}
				</style>', $param_print, $param_force);
				
sn committed
460
				self::new_echo($param_ul['start'].'<li>'.$param_keystring.' => '.$param_Array.' '.$info_toArray.'  <br/>
sn committed
461 462
					<input id="button" type="button" onclick="showText(\''.$divId.'\');" value="Text einblenden" /> </li> '.$param_ul['stop'], $param_print, $param_force);
				self::new_echo('<div id="'.$divId.'">', $param_print, $param_force);
sn committed
463
				foreach($var_value2Array as $var_key => $var_value) {
sn committed
464
					D::fe($var_value, null, $param_logdepth, $param_ul,$var_key, $param_print, $param_force);
sn committed
465
				}			
sn committed
466 467 468 469 470
				self::new_echo('</div>', $param_print, $param_force);
			} else {
				self::new_echo($param_ul['start'].'<li>'.$param_keystring.' => '.$param_Array.' '.$info_toArray.'  </li>'.$param_ul['stop'], $param_print, $param_force);
			}
			
Frederick committed
471
		}
sn committed
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519
	}	
	
	
//	public static function fe($param_Array, $param_Print=null, $param_logdepth=10, $param_ul=array()) {
////		D::ulli(':::::::::::::: '.$param_logdepth.' - '.$param_Array);
//		if($param_logdepth>=0) {
//			if(!is_null($param_Print)) {
//				$param_Print .= ' count('.count($param_Array).') loglevel('.$param_logdepth.') || print '.$param_Array;
//				D::li($param_Print);
//			}
//			$param_logdepth--;
//			$param_ul['start'] .= '<ul>';
//			$param_ul['stop'] .= '</ul>';
//			
//		
//			foreach($param_Array as $var_key => $var_value) {
//				$info_toArray = '';
//				
//				if(is_array($info_toArray)) {
//					$var_value2Array = $var_value;
//					
//				} else if(is_object($var_value)) {
//					$objfncs = get_class_methods(get_class($var_value));
//					if(array_search('getData', $objfncs)) {
//						$var_value2Array = $var_value->getData();
//						$info_toArray = '(Obj->getData)';
//					} if(array_search('toArray', $objfncs)) {
//						$var_value2Array = $var_value->toArray();
//						$info_toArray = '(Obj->toArray)';
//					} else {
//						$var_value2Array = $var_value;
//					}
//				} else if($unserialize = unserialize($var_value)) {
//					$var_value2Array = $unserialize;
//					$info_toArray = '(str2unserialize)';
//				} else {
//					$var_value2Array = $var_value;
//				}
//				
//				self::new_echo($param_ul['start'].'<li>'.$var_key.' => '.$var_value.' '.$info_toArray.'   loglevel('.$param_logdepth.')</li>'.$param_ul['stop']);
//
//				if(is_array($var_value2Array)) {
//					D::fe($var_value2Array, null, $param_logdepth, $param_ul);
//				}
//	//			D::ulli($var_key.' => '.$var_value);
//			}			
//		}
//	}
Frederick committed
520 521 522 523 524 525 526

	/**
	 *	Funktion gibt den Weg zur tatsächliche Funktion zurück
	 *
	 *	@static
	 */

527
	private static function printCurrentFunction($param_print, $param_string='', $param_onlyFunction=false, $param_force=false) {
Frederick committed
528 529 530 531
		if($param_print) {
			$array = debug_backtrace();
			$i=2;

Frederick d. Maus committed
532
			if($param_onlyFunction) {
533
				self::new_echo(''.$array[$i]["class"].$array[$i]["type"].$array[$i]["function"].'(Z'.$array[$i-1]["line"].'): '.$param_string, $param_print, $param_force);
Frederick d. Maus committed
534 535 536 537 538 539 540 541 542 543 544 545 546 547 548
			} else {
				if(is_array($array) && array_key_exists($i,$array)){

					//				echo 'hello<br><pre>';
					//				print_r($array[1]);
					//				echo '</pre>';
					$var_depth = 0;
					for($v=0; $v<count($array);$v++){
						if( array_key_exists('class', $array[$v]) && array_key_exists('class', $array[$i])
						&&
						$array[$v]['class'].$array[$v]['type'].$array[$v]['function']==$array[$i]['class'].$array[$i]['type'].$array[$i]['function']
						){
							$var_depth++;
						}
						//	D::ulli($v.': '.$array[$v]['class'].$array[$v]['type'].$array[$v]['function']);
Frederick committed
549
					}
550
//echo $param_string;
sn committed
551
					self::new_echo($param_string."    <i style=\"font-size:12;color:gray;\"><b>".$array[$i]["class"].$array[$i]["type"].$array[$i]["function"]."()</b> <span title='Rekursionstiefe'>(RT:$var_depth)</span> call in row ".$array[$i]["line"]." in <a href=\"".substr($array[$i]["file"],strpos($array[$i]["file"],"httpdocs")+8)."\">".basename($array[$i]["file"])."</a></i> => [<i style=\"font-size:10;color:gray;\">".$array[$i-1]['class'].$array[$i-1]['type'].$array[$i-1]['function']."() call in ".basename($array[$i-1]["file"])." Zeile: ".$array[$i-1]["line"]." </i>] <a href=".$_SERVER['REQUEST_URI']."><i title=".$_SERVER['REQUEST_URI'].">URL</i></a>", $param_print);
Frederick d. Maus committed
552 553 554 555
					//echo '___________<pre>';
					//echo	print_r($array[$i], true);
					//echo '</pre>';
				}				
Frederick committed
556 557 558 559
			}
		}
	}

sn committed
560 561 562 563 564 565 566
	/**
	 * 
	 * @param object|classname $param_class
	 * @param string $param_fncname
	 * @param bool $param_onlyReturn
	 * @return array
	 */
sn committed
567
	public static function printClassesforFunction($param_class, $param_fncname, $param_onlyReturn=false, $param_print=true, $param_force=false, $param_htmlentities=false) {
sn committed
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606
		if(is_object($param_class)) {
			$classname = get_class($param_class);
			
		} else if(class_exists($param_class)) {
			$classname = $param_class;
		}
		$result = array();
		
		do {
			$methods = get_class_methods($classname);
//			D::show($methods, $classname);
			if(array_search($param_fncname, $methods)) {
				$result[] = array($classname => $param_fncname);
			}
		} while ($classname = get_parent_class($classname));
		
		if(empty($result)) {
			return D::printClassesforFunction($param_class, '__call', $param_onlyReturn);
		}
		
		if($param_onlyReturn) {
			return $result;
		} else {
//			D::show($result, $param_fncname);
			
			self::printCurrentFunction($param_print,"<br>______________________<br>");
			$string_show = "<br /><b>printClassesforFunction(".$param_fncname.")</b><br />";
			$string_show .= "<pre>";
			if($param_htmlentities){
				$param_val=self::htmlencode_arrayvalues($result);
			}
			self::new_echo($string_show.print_r($result, true).'"</pre>"', $param_print, $param_force);
	
			
			return $result;
		}
	}
	
	
Frederick committed
607 608 609 610 611 612
	public static function  backtrace($class=null, $param_print=true, $param_force=false) {
		self::printCurrentFunction($param_print);
		//echo '<h1>backtrace('.$class.')</h1>';
		self::new_echo('<h1>backtrace('.$class.')</h1>', $param_print, $param_force);
		$array = debug_backtrace();
		$k=0;
sn committed
613 614 615 616 617
		
		$table_start = '<table border="1">' ;
		$table_start .= '<tr valign="top"><td align="right">Klasse</td><td>Funktion</td><td>Datei</td></tr>';
		self::new_echo($table_start, $param_print, $param_force);
		
Frederick committed
618 619 620
		for($i=count($array)-1; $i!=0; $i--) {
			$k++;

sn committed
621 622
			$var_string = '<tr valign="top">';
			$var_string .= '<td align="right">';
Frederick committed
623 624

			if(array_key_exists('class', $array[$i]) && array_key_exists('type', $array[$i])) {
sn committed
625
				$var_string .=	"".$array[$i]["class"].$array[$i]["type"].'';
Frederick committed
626
			}
sn committed
627 628
			$var_string .= '</td>';
			$var_string .= '<td>';
Frederick committed
629 630 631

			$var_string .= $array[$i]["function"]."(...) ";

sn committed
632 633 634 635 636
			$var_string .=	" ... fnc call in row ".$array[$i]["line"]." " .
//							"in der Datei <a title=\"".$array[$i]["file"]."\" href=\"".substr($array[$i]["file"],strpos($array[$i]["file"],"httpdocs")+8)."\">".basename($array[$i]["file"])."</a>" .
//					"in der Datei <a title=\"".$array[$i]["file"]."\" href=\"".substr($array[$i]["file"],strpos($array[$i]["file"],"httpdocs")+8)."\">".basename($array[$i]["file"])."</a>" .
//					"in der Datei <a title=\"".$array[$i]["file"]."\" href=\"".$array[$i]["file"]."\">".basename($array[$i]["file"])."</a>" .					
					"";			
Frederick committed
637 638

			//			echo($var_string);
sn committed
639 640 641
			$var_string .= '</td>';
			$var_string .= '<td><span style=\"font-size:6;\">'.  dirname($array[$i]["file"]).'/<b>'.basename($array[$i]["file"]).'</b></span></td>';
			$var_string .= '</tr>';
Frederick committed
642 643
			self::new_echo($var_string, $param_print, $param_force);
		}
sn committed
644 645
		$table_stop = '</table>' ;
		self::new_echo($table_stop, $param_print, $param_force);		
Frederick committed
646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829
	}

	/**
	 *
	 * @param bool $param_htmltags default false
	 * @param int $param_start default 1
	 * @param int $param_end default 0
	 * @return string
	 */
	public static function getBacktrace($param_htmltags=false, $param_start=1, $param_end=0) {

		if($param_htmltags) {
			$htmltag_li_strong_b = '<li><strong style=\"font-size:8;color:gray;\"><b>';
			$htmltag_b = '</b>';
			$htmltag_strong_li = '</strong></li>';
		} else {
			$htmltag_li_strong_b = '';
			$htmltag_b = '';
			$htmltag_strong_li = '';
		}

		$return_string = '';
		$array = debug_backtrace();
		$k=0;

		$start = count($array)-$param_start;

		if($start <= $param_end) {
			$param_end = $start-1;
		}

		for($i=$start; $i!=$param_end; $i--) {
			$k++;
			$ul_start="";
			$ul_end="";
			if($param_htmltags) {
				for($j=0; $j<$k; $j++) {
					$ul_start .= "<ul>";
					$ul_end .= "</ul>";
				}
				$htmltag_start_a = "<a href=\"".substr($array[$i]["file"],strpos($array[$i]["file"],"httpdocs")+8)."\">";
				$htmltag_end_a = '</a>';
				$tag_endline = '';
			} else {
				$ul_start="* ";
				$htmltag_start_a = '';
				$htmltag_end_a = '';
				$tag_endline = "\n
					".'
						';
			}


			$var_string = $ul_start."" .$htmltag_li_strong_b;

			if(array_key_exists('class', $array[$i]) && array_key_exists('type', $array[$i])) {
				$var_string .=	"".$array[$i]["class"].$array[$i]["type"];
			}


			$var_string .= $array[$i]["function"]."(...) ";

			$var_string .=	$htmltag_b." fnc call in row ".$array[$i]["line"]." " .
							"in file ".$htmltag_start_a.basename($array[$i]["file"]).$htmltag_end_a .
					$htmltag_strong_li.$ul_end.$tag_endline;

			$return_string .= $var_string;
		}
		return $return_string;
	}

	private static $StartTime;

	public static function start() {
		self::$StartTime = time();
	}
	public static function stop($param_startTime=null, $param_string=null, $param_print=true, $param_force=false) {
		if($param_startTime==null) {
			$param_startTime = self::$StartTime;
		}
		$zeit = getdate(time() - $param_startTime);

		self::new_echo("<li><b>".$param_string."</b> ==>> <b>".$zeit["minutes"]."</b> min <b>".$zeit["seconds"]."</b> sec</li>", $param_print, $param_force);
	}


	private static function showdomelement($param_XMLElement, $param_string=null,$param_print=true, $param_force=false) {


		$count_elements=0;
		foreach($param_XMLElement->childNodes as $element) {
			if($element->nodeType == 1) {
				$string .= 'nodeName: '. $element->nodeName ." | Content: ". $element->textContent  . "<br>"  ;
				$test= $element->nodeName ;
				$count_elements++;
			}
		}
		$var_label = $param_XMLElement->getAttribute('label');
		if($var_label) {
			$string_init = '<br/><b>'.$param_XMLElement->tagName.'</b>  label('.$var_label.') ';
		}
		$string_init .=  'Number of Elements: ' .$count_elements.'<br>';
		self::new_echo("$string_init <pre>", $param_print, $param_force);
		self::new_echo($string.'</pre>',$param_print, $param_force);





	}

	public static function showdomdoc($param_XMLElement, $param_string=null,$param_print=true, $param_force=false) {
		$count_elements=0;
		foreach($param_XMLElement->childNodes as $element) {
			if($element->nodeType == 1) {
				$string .= 'nodeName: '. $element->nodeName ." | Content: ". $element->textContent  . "<br>"  ;
				$test= $element->nodeName ;
				$count_elements++;
			}
		}


		$string .=  'Number of Elements: ' .$count_elements.'<br>';
		self::new_echo("<b>showdomdoc(".$param_string.")</b><pre>", $param_print, $param_force);
		self::new_echo('</pre>'.$string,$param_print, $param_force);
	}

	public static function showdomxpath($param_DOMDOC, $param_query,$param_string=null,$param_print=true, $param_force=false) {
		$xp = new domxpath($param_DOMDOC);
		$titles = $xp->query("/". $param_query ."");
		$count_elements=0;
		$string = get_class($param_DOMDOC).': => ';
		foreach ($titles as $node) {
			$string .= '<b> NodeName: </b> <br>'.$node->nodeName .'</b><br><b> NodeContent: </b><br>'.$node->textContent . " <br>";
			//    		$string .= "<br>{$node->previousSibling->previousSibling->previousSibling->previousSibling->previousSibling->previousSibling->previousSibling->previousSibling->nodeValue},<br>";

			$count_elements++;
		}
		$string .=  'Number of Elements: ' .$count_elements.'<br>';
		self::new_echo("<b>showdomxpath(".$param_string.")</b><b>query(".'/'.$param_query.")</b><pre>", $param_print, $param_force);
		self::new_echo('</pre>'.$string,$param_print, $param_force);
	}

	/**
	 *	@todo irgendwie muss das anders ....
	 *		alles was mcClasses ist in @see D::showStats und den Rest ganz raus
	 *
	 * @global <type> $time_index
	 * @global <type> $var_ErrorWarnString
	 * @global <type> $_TREE
	 */
	public static function showGeneralSoftwareAbstractInfos() {
		global $time_index;
		global $var_ErrorWarnString;
		global $_TREE;
		echo '__ <p><br /></p><div class=\'AbstractInfos\'>';
		D::stop($time_index, $var_ErrorWarnString.' ###  index ('.$_TREE.') komplett mit Temp Ausgabe');
		D::p('' .
				'TreeManipulator: runTree('.TreeManipulator::$count_runTree.') cb_getBasisClipboard('.TreeManipulator::$count_runTreeCallback_getBasisClipboard.') || runDBTree('.TreeManipulator::$count_runDBTree.')   cb_catchInfoboxData('.CatchInfoboxDataTMC::$count_callbackFunction.')<br>' .
				'MultimediaText(<b>'.MultimediaText::$counter_____construct.' / '.count(MultimediaText::$MTextArray).'[!!!'.MultimediaText::$DoppeltGeladen.'!!!]</b>) loadObject('.MySql::$count_loadObject.') getObjDOMElement(<b>'.BasisElement::$getObjDOMElement_counter.'</b>['.BasisElement::$getObjDOMElement_counter_diff.']) runTree('.Controller::$count_runTree.')<br>' .
				'Mysql(<b>'.BasicMySql::$count___construct.'</b>):  query(<b>'.BasicMySql::$MySql_count_query.'</b>/ SR<b>'.BasicMySql::$PDOSRequest_count_query.'</b>) nextRow(<b>'.BasicMySql::$count_nextRow.'</b>) checkAuthorisationQuery(<b>'.Mysql::$count_checkAuthorisationQuery.'</b>)<br> ' .
				'getMultimediaTextData('.MySql::$count_getMultimediaTextData.') => getClassNameFromMTextID('.MySql::$count_getClassNameFromMTextID.') => getPrefsBE_SQL_Data('.CONFIG::$count_getSQL_Data.')  ==>> Infobox('.Infobox::$count_Infobox.')'.
				'CONFIG transformStringToArray('.CONFIG::$count_transformStringToArray.') '.
			'');

		D::li('geladene MultimediaTexte (index.php)');
		$index=1;
		foreach(MultimediaText::$MTextArray as $key => $value) {
			$index++;

			if(!is_array($value->getObjVar('LoadLevel')) || $var_key_LoadLevel = array_keys($value->getObjVar('LoadLevel'))) {
				$var_key_LoadLevel = array();
			}
			if(!is_array($var_key_LoadLevel)) {
				$var_key_LoadLevel = array();
			}
			D::ulli($index.' $key('.$key.') ID('.$value->getObjVar('ID').')  Subject('.$value->getObjVar('Subject').') LoadLevel('.Form::arrayToVarchar($var_key_LoadLevel).')');
		}
		echo '</div>';
	}

	public static function showStats(array $__mc_Report, $__BASEPATH_EX, $__mc_D_LOGFILE) {
		$var_ErrorWarnString = date('d. m. Y  G:i:s').': ';

sn committed
830 831 832 833 834 835 836 837
		if(array_key_exists('REMOTE_HOST', $_SERVER))  {
			$HOST = $_SERVER['REMOTE_HOST'];
		} else {
			$HOST = '';
		}
		
		
		$a_start = '<a href="'.$HOST.'/'.$__mc_D_LOGFILE.'" >';
Frederick committed
838 839 840 841 842 843
		$a_end = '</a>';
		$var_ErrorWarnString .= ' '.$a_start.'D('.count(self::$echo_lines).')'.$a_end.' ';


		if(mcNoticeEvent::$count) {
			if(array_key_exists('mcNoticeEvent', $__mc_Report) && is_array($__mc_Report['mcNoticeEvent']) && array_key_exists('toFile', $__mc_Report['mcNoticeEvent']) && is_array($__mc_Report['mcNoticeEvent']['toFile'])) {
sn committed
844
				$a_start = '<a href="'.$HOST.'/'.$__mc_Report['mcNoticeEvent']['toFile']['file'].'" style=\"font-size:15;color:orange;\">';
Frederick committed
845 846 847 848 849 850 851 852 853 854 855
				$a_end = '</a>';
			} else {
				$a_start = $a_end = '';
			}
			$var_ErrorWarnString .=  ' '.$a_start.'mcNoticeEvent('.mcNoticeEvent::$count.')'.$a_end.' ';
		} else {
			$var_ErrorWarnString .= ' '.'mcNoticeEvent(0) ';
		}

		if(Error::$Quantity) {
			if(array_key_exists('Error', $__mc_Report) && is_array($__mc_Report['Error']) && array_key_exists('toFile', $__mc_Report['Error']) && is_array($__mc_Report['Error']['toFile'])) {
sn committed
856
				$a_start = '<a href="'.$HOST.'/'.$__mc_Report['Error']['toFile']['file'].'" style=\"font-size:15;color:red;\">';
Frederick committed
857 858 859 860 861 862 863 864 865 866 867
				$a_end = '</a>';
			} else {
				$a_start = $a_end = '';
			}
			$var_ErrorWarnString .=  ' '.$a_start. 'Error('.Error::$Quantity.')'.$a_end.' ';
		} else {
			$var_ErrorWarnString .= ' '.'Error(0) ';
		}

		if(mcException::$count) {
			if(array_key_exists('mcException', $__mc_Report) && is_array($__mc_Report['mcException']) && array_key_exists('toFile', $__mc_Report['mcException']) && is_array($__mc_Report['mcException']['toFile'])) {
sn committed
868
				$a_start = '<a href="'.$HOST.'/'.$__mc_Report['mcException']['toFile']['file'].'" style=\"font-size:15;color:red;\">';
Frederick committed
869 870 871 872 873 874 875 876 877 878 879 880
				$a_end = '</a>';
			} else {
				$a_start = $a_end = '';
			}
			$var_ErrorWarnString .=  ' '.$a_start.'mcException('.mcException::$count.')'.$a_end.' ';
		} else {
			$var_ErrorWarnString .= ' '.'mcException(0) ';
		}


		if(mcErrorEvent::$count) {
			if(array_key_exists('mcErrorEvent', $__mc_Report) && is_array($__mc_Report['mcErrorEvent']) && array_key_exists('toFile', $__mc_Report['mcErrorEvent']) && is_array($__mc_Report['mcErrorEvent']['toFile'])) {
sn committed
881
				$a_start = '<a href="'.$HOST.'/'.$__mc_Report['mcErrorEvent']['toFile']['file'].'" style=\"font-size:15;color:red;\">';
Frederick committed
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897
				$a_end = '</a>';
			} else {
				$a_start = $a_end = '';
			}
			$var_ErrorWarnString .= $a_start.'ErrorEvent('.mcErrorEvent::$count.')'.$a_end.' ';
		} else {
			$var_ErrorWarnString .= 'ErrorEvent(0) ';
		}

		D::stop(null, $var_ErrorWarnString);
	}


}

?>