Completed
Push — 1.10.x ( 22bf41...ad23de )
by Yannick
297:43 queued 254:39
created
main/inc/lib/xajax/xajax.inc.php 4 patches
Doc Comments   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 	 * Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if
501 501
 	 * there is none.
502 502
 	 *
503
-	 * @return mixed
503
+	 * @return integer
504 504
 	 */
505 505
 	function getRequestMode()
506 506
 	{
@@ -1018,6 +1018,7 @@  discard block
 block discarded – undo
1018 1018
 	 *
1019 1019
 	 * @param string the root tag of the XML
1020 1020
 	 * @param string XML to convert
1021
+	 * @param string $rootTag
1021 1022
 	 * @access private
1022 1023
 	 * @return array
1023 1024
 	 */
Please login to merge, or discard this patch.
Braces   +84 added lines, -86 removed lines patch added patch discarded remove patch
@@ -173,8 +173,9 @@  discard block
 block discarded – undo
173 173
 		$this->aObjects = array();
174 174
 		$this->aFunctionIncludeFiles = array();
175 175
 		$this->sRequestURI = $sRequestURI;
176
-		if ($this->sRequestURI == "")
177
-			$this->sRequestURI = $this->_detectURI();
176
+		if ($this->sRequestURI == "") {
177
+					$this->sRequestURI = $this->_detectURI();
178
+		}
178 179
 		$this->sWrapperPrefix = $sWrapperPrefix;
179 180
 		$this->bDebug = $bDebug;
180 181
 		$this->bStatusMessages = false;
@@ -399,8 +400,7 @@  discard block
 block discarded – undo
399 400
 			$this->aFunctions[$mFunction[0]] = 1;
400 401
 			$this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType;
401 402
 			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
402
-		}
403
-		else {
403
+		} else {
404 404
 			$this->aFunctions[$mFunction] = 1;
405 405
 			$this->aFunctionRequestTypes[$mFunction] = $sRequestType;
406 406
 		}
@@ -426,8 +426,7 @@  discard block
 block discarded – undo
426 426
 
427 427
 		if (is_array($mFunction)) {
428 428
 			$this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile;
429
-		}
430
-		else {
429
+		} else {
431 430
 			$this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile;
432 431
 		}
433 432
 	}
@@ -451,8 +450,7 @@  discard block
 block discarded – undo
451 450
 		if (is_array($mFunction)) {
452 451
 			$this->sCatchAllFunction = $mFunction[0];
453 452
 			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
454
-		}
455
-		else {
453
+		} else {
456 454
 			$this->sCatchAllFunction = $mFunction;
457 455
 		}
458 456
 	}
@@ -477,8 +475,7 @@  discard block
 block discarded – undo
477 475
 		if (is_array($mFunction)) {
478 476
 			$this->sPreFunction = $mFunction[0];
479 477
 			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
480
-		}
481
-		else {
478
+		} else {
482 479
 			$this->sPreFunction = $mFunction;
483 480
 		}
484 481
 	}
@@ -492,7 +489,9 @@  discard block
 block discarded – undo
492 489
 	 */
493 490
 	function canProcessRequests()
494 491
 	{
495
-		if ($this->getRequestMode() != -1) return true;
492
+		if ($this->getRequestMode() != -1) {
493
+		    return true;
494
+		}
496 495
 		return false;
497 496
 	}
498 497
 
@@ -504,11 +503,13 @@  discard block
 block discarded – undo
504 503
 	 */
505 504
 	function getRequestMode()
506 505
 	{
507
-		if (!empty($_GET["xajax"]))
508
-			return XAJAX_GET;
506
+		if (!empty($_GET["xajax"])) {
507
+					return XAJAX_GET;
508
+		}
509 509
 
510
-		if (!empty($_POST["xajax"]))
511
-			return XAJAX_POST;
510
+		if (!empty($_POST["xajax"])) {
511
+					return XAJAX_POST;
512
+		}
512 513
 
513 514
 		return -1;
514 515
 	}
@@ -535,16 +536,18 @@  discard block
 block discarded – undo
535 536
 		$sResponse = "";
536 537
 
537 538
 		$requestMode = $this->getRequestMode();
538
-		if ($requestMode == -1) return;
539
+		if ($requestMode == -1) {
540
+		    return;
541
+		}
539 542
 
540 543
 		if ($requestMode == XAJAX_POST)
541 544
 		{
542 545
 			$sFunctionName = $_POST["xajax"];
543 546
 
544
-			if (!empty($_POST["xajaxargs"]))
545
-				$aArgs = $_POST["xajaxargs"];
546
-		}
547
-		else
547
+			if (!empty($_POST["xajaxargs"])) {
548
+							$aArgs = $_POST["xajaxargs"];
549
+			}
550
+		} else
548 551
 		{
549 552
 			header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
550 553
 			header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
@@ -553,8 +556,9 @@  discard block
 block discarded – undo
553 556
 
554 557
 			$sFunctionName = $_GET["xajax"];
555 558
 
556
-			if (!empty($_GET["xajaxargs"]))
557
-				$aArgs = $_GET["xajaxargs"];
559
+			if (!empty($_GET["xajaxargs"])) {
560
+							$aArgs = $_GET["xajaxargs"];
561
+			}
558 562
 		}
559 563
 
560 564
 		// Use xajax error handler if necessary
@@ -586,15 +590,13 @@  discard block
 block discarded – undo
586 590
 				if ($this->sCatchAllFunction) {
587 591
 					$sFunctionName = $this->sCatchAllFunction;
588 592
 					$bFunctionIsCatchAll = true;
589
-				}
590
-				else {
593
+				} else {
591 594
 					$bFoundFunction = false;
592 595
 					$objResponse = new xajaxResponse();
593 596
 					$objResponse->addAlert("Unknown Function $sFunctionName.");
594 597
 					$sResponse = $objResponse->getXML();
595 598
 				}
596
-			}
597
-			else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode)
599
+			} else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode)
598 600
 			{
599 601
 				$bFoundFunction = false;
600 602
 				$objResponse = new xajaxResponse();
@@ -615,12 +617,10 @@  discard block
 block discarded – undo
615 617
 				if (stristr($aArgs[$i],"<xjxobj>") != false)
616 618
 				{
617 619
 					$aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
618
-				}
619
-				else if (stristr($aArgs[$i],"<xjxquery>") != false)
620
+				} else if (stristr($aArgs[$i],"<xjxquery>") != false)
620 621
 				{
621 622
 					$aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
622
-				}
623
-				else if ($this->bDecodeUTF8Input)
623
+				} else if ($this->bDecodeUTF8Input)
624 624
 				{
625 625
 					$aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]);
626 626
 				}
@@ -631,14 +631,15 @@  discard block
 block discarded – undo
631 631
 				if (is_array($mPreResponse) && $mPreResponse[0] === false) {
632 632
 					$bEndRequest = true;
633 633
 					$sPreResponse = $mPreResponse[1];
634
-				}
635
-				else {
634
+				} else {
636 635
 					$sPreResponse = $mPreResponse;
637 636
 				}
638 637
 				if (is_a($sPreResponse, "xajaxResponse")) {
639 638
 					$sPreResponse = $sPreResponse->getXML();
640 639
 				}
641
-				if ($bEndRequest) $sResponse = $sPreResponse;
640
+				if ($bEndRequest) {
641
+				    $sResponse = $sPreResponse;
642
+				}
642 643
 			}
643 644
 
644 645
 			if (!$bEndRequest) {
@@ -646,8 +647,7 @@  discard block
 block discarded – undo
646 647
 					$objResponse = new xajaxResponse();
647 648
 					$objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found.");
648 649
 					$sResponse = $objResponse->getXML();
649
-				}
650
-				else {
650
+				} else {
651 651
 					if ($bFunctionIsCatchAll) {
652 652
 						$aArgs = array($sFunctionNameForSpecial, $aArgs);
653 653
 					}
@@ -660,8 +660,7 @@  discard block
 block discarded – undo
660 660
 					$objResponse = new xajaxResponse();
661 661
 					$objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName.");
662 662
 					$sResponse = $objResponse->getXML();
663
-				}
664
-				else if ($sPreResponse != "") {
663
+				} else if ($sPreResponse != "") {
665 664
 					$sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities);
666 665
 					$sNewResponse->loadXML($sPreResponse);
667 666
 					$sNewResponse->loadXML($sResponse);
@@ -671,8 +670,9 @@  discard block
 block discarded – undo
671 670
 		}
672 671
 
673 672
 		$sContentHeader = "Content-type: text/xml;";
674
-		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
675
-			$sContentHeader .= " charset=".$this->sEncoding;
673
+		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) {
674
+					$sContentHeader .= " charset=".$this->sEncoding;
675
+		}
676 676
 		header($sContentHeader);
677 677
 		if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
678 678
 			$sErrorResponse = new xajaxResponse();
@@ -681,8 +681,7 @@  discard block
 block discarded – undo
681 681
 				$fH = @fopen($this->sLogFile, "a");
682 682
 				if (!$fH) {
683 683
 					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
684
-				}
685
-				else {
684
+				} else {
686 685
 					fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
687 686
 					fclose($fH);
688 687
 				}
@@ -692,12 +691,17 @@  discard block
 block discarded – undo
692 691
 			$sResponse = $sErrorResponse->getXML();
693 692
 
694 693
 		}
695
-		if ($this->bCleanBuffer) while (@ob_end_clean());
694
+		if ($this->bCleanBuffer) {
695
+		    while (@ob_end_clean());
696
+		}
696 697
 		print $sResponse;
697
-		if ($this->bErrorHandler) restore_error_handler();
698
+		if ($this->bErrorHandler) {
699
+		    restore_error_handler();
700
+		}
698 701
 
699
-		if ($this->bExitAllowed)
700
-			exit();
702
+		if ($this->bExitAllowed) {
703
+					exit();
704
+		}
701 705
 	}
702 706
 
703 707
 	/**
@@ -806,9 +810,13 @@  discard block
 block discarded – undo
806 810
 	 */
807 811
 	function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
808 812
 	{
809
-		if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
813
+		if ($sJsFile == NULL) {
814
+		    $sJsFile = "xajax_js/xajax.js";
815
+		}
810 816
 
811
-		if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
817
+		if ($sJsURI != "" && substr($sJsURI, -1) != "/") {
818
+		    $sJsURI .= "/";
819
+		}
812 820
 
813 821
 		$html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
814 822
 		$html .= "\t<script type=\"text/javascript\">\n";
@@ -831,8 +839,7 @@  discard block
 block discarded – undo
831 839
 
832 840
 		if ($sJsFullFilename) {
833 841
 			$realJsFile = $sJsFullFilename;
834
-		}
835
-		else {
842
+		} else {
836 843
 			$realPath = realpath(dirname(__FILE__));
837 844
 			$realJsFile = $realPath . "/". $sJsFile;
838 845
 		}
@@ -849,8 +856,7 @@  discard block
 block discarded – undo
849 856
 			$fH = @fopen($realJsFile, "w");
850 857
 			if (!$fH) {
851 858
 				trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
852
-			}
853
-			else {
859
+			} else {
854 860
 				fwrite($fH, $compressedScript);
855 861
 				fclose($fH);
856 862
 			}
@@ -950,7 +956,9 @@  discard block
 block discarded – undo
950 956
 	 */
951 957
 	function _isObjectCallback($sFunction)
952 958
 	{
953
-		if (array_key_exists($sFunction, $this->aObjects)) return true;
959
+		if (array_key_exists($sFunction, $this->aObjects)) {
960
+		    return true;
961
+		}
954 962
 		return false;
955 963
 	}
956 964
 
@@ -967,12 +975,10 @@  discard block
 block discarded – undo
967 975
 		if ($this->_isObjectCallback($sFunction)) {
968 976
 			if (is_object($this->aObjects[$sFunction][0])) {
969 977
 				return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]);
970
-			}
971
-			else {
978
+			} else {
972 979
 				return is_callable($this->aObjects[$sFunction]);
973 980
 			}
974
-		}
975
-		else {
981
+		} else {
976 982
 			return function_exists($sFunction);
977 983
 		}
978 984
 	}
@@ -990,8 +996,7 @@  discard block
 block discarded – undo
990 996
 	{
991 997
 		if ($this->_isObjectCallback($sFunction)) {
992 998
 			$mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs);
993
-		}
994
-		else {
999
+		} else {
995 1000
 			$mReturn = call_user_func_array($sFunction, $aArgs);
996 1001
 		}
997 1002
 		return $mReturn;
@@ -1086,8 +1091,7 @@  discard block
 block discarded – undo
1086 1091
 								{
1087 1092
 									$value = $this->_parseObjXml("xjxobj");
1088 1093
 									$this->iPos++;
1089
-								}
1090
-								else
1094
+								} else
1091 1095
 								{
1092 1096
 									$value .= $this->aObjArray[$this->iPos];
1093 1097
 									if ($this->bDecodeUTF8Input)
@@ -1134,10 +1138,11 @@  discard block
 block discarded – undo
1134 1138
 			if (get_magic_quotes_gpc() == 1) {
1135 1139
 				$newArray = array();
1136 1140
 				foreach ($aArray as $sKey => $sValue) {
1137
-					if (is_string($sValue))
1138
-						$newArray[$sKey] = stripslashes($sValue);
1139
-					else
1140
-						$newArray[$sKey] = $sValue;
1141
+					if (is_string($sValue)) {
1142
+											$newArray[$sKey] = stripslashes($sValue);
1143
+					} else {
1144
+											$newArray[$sKey] = $sValue;
1145
+					}
1141 1146
 				}
1142 1147
 				$aArray = $newArray;
1143 1148
 			}
@@ -1166,20 +1171,18 @@  discard block
 block discarded – undo
1166 1171
 				$sFuncToUse = "api_convert_encoding";
1167 1172
 			}
1168 1173
 			//if (function_exists('iconv'))
1169
-			elseif (function_exists('iconv'))
1170
-			//
1174
+			elseif (function_exists('iconv')) {
1175
+						//
1171 1176
 			{
1172 1177
 				$sFuncToUse = "iconv";
1173 1178
 			}
1174
-			else if (function_exists('mb_convert_encoding'))
1179
+			} else if (function_exists('mb_convert_encoding'))
1175 1180
 			{
1176 1181
 				$sFuncToUse = "mb_convert_encoding";
1177
-			}
1178
-			else if ($this->sEncoding == "ISO-8859-1")
1182
+			} else if ($this->sEncoding == "ISO-8859-1")
1179 1183
 			{
1180 1184
 				$sFuncToUse = "utf8_decode";
1181
-			}
1182
-			else
1185
+			} else
1183 1186
 			{
1184 1187
 				trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE);
1185 1188
 			}
@@ -1191,8 +1194,7 @@  discard block
 block discarded – undo
1191 1194
 					if ($sFuncToUse == "iconv")
1192 1195
 					{
1193 1196
 						$sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue);
1194
-					}
1195
-					else if ($sFuncToUse == "mb_convert_encoding")
1197
+					} else if ($sFuncToUse == "mb_convert_encoding")
1196 1198
 					{
1197 1199
 						$sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1198 1200
 					}
@@ -1221,27 +1223,23 @@  discard block
 block discarded – undo
1221 1223
 function xajaxErrorHandler($errno, $errstr, $errfile, $errline)
1222 1224
 {
1223 1225
 	$errorReporting = error_reporting();
1224
-	if (($errno & $errorReporting) == 0) return;
1226
+	if (($errno & $errorReporting) == 0) {
1227
+	    return;
1228
+	}
1225 1229
 
1226 1230
 	if ($errno == E_NOTICE) {
1227 1231
 		$errTypeStr = "NOTICE";
1228
-	}
1229
-	else if ($errno == E_WARNING) {
1232
+	} else if ($errno == E_WARNING) {
1230 1233
 		$errTypeStr = "WARNING";
1231
-	}
1232
-	else if ($errno == E_USER_NOTICE) {
1234
+	} else if ($errno == E_USER_NOTICE) {
1233 1235
 		$errTypeStr = "USER NOTICE";
1234
-	}
1235
-	else if ($errno == E_USER_WARNING) {
1236
+	} else if ($errno == E_USER_WARNING) {
1236 1237
 		$errTypeStr = "USER WARNING";
1237
-	}
1238
-	else if ($errno == E_USER_ERROR) {
1238
+	} else if ($errno == E_USER_ERROR) {
1239 1239
 		$errTypeStr = "USER FATAL ERROR";
1240
-	}
1241
-	else if ($errno == E_STRICT) {
1240
+	} else if ($errno == E_STRICT) {
1242 1241
 		return;
1243
-	}
1244
-	else {
1242
+	} else {
1245 1243
 		$errTypeStr = "UNKNOWN: $errno";
1246 1244
 	}
1247 1245
 	$GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile";
Please login to merge, or discard this patch.
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -45,21 +45,21 @@  discard block
 block discarded – undo
45 45
  * Define XAJAX_DEFAULT_CHAR_ENCODING that is used by both
46 46
  * the xajax and xajaxResponse classes
47 47
  */
48
-if (!defined ('XAJAX_DEFAULT_CHAR_ENCODING'))
48
+if (!defined('XAJAX_DEFAULT_CHAR_ENCODING'))
49 49
 {
50
-	define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' );
50
+	define('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8');
51 51
 }
52 52
 
53 53
 /**
54 54
  * Communication Method Defines
55 55
  */
56
-if (!defined ('XAJAX_GET'))
56
+if (!defined('XAJAX_GET'))
57 57
 {
58
-	define ('XAJAX_GET', 0);
58
+	define('XAJAX_GET', 0);
59 59
 }
60
-if (!defined ('XAJAX_POST'))
60
+if (!defined('XAJAX_POST'))
61 61
 {
62
-	define ('XAJAX_POST', 1);
62
+	define('XAJAX_POST', 1);
63 63
 }
64 64
 
65 65
 /**
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
 	 * @param string  defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above
168 168
 	 * @param boolean defaults to false
169 169
 	 */
170
-	public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false)
170
+	public function __construct($sRequestURI = "", $sWrapperPrefix = "xajax_", $sEncoding = XAJAX_DEFAULT_CHAR_ENCODING, $bDebug = false)
171 171
 	{
172 172
 		$this->aFunctions = array();
173 173
 		$this->aObjects = array();
@@ -393,7 +393,7 @@  discard block
 block discarded – undo
393 393
 	 * @param mixed  request type (XAJAX_GET/XAJAX_POST) that should be used
394 394
 	 *               for this function.  Defaults to XAJAX_POST.
395 395
 	 */
396
-	function registerFunction($mFunction,$sRequestType=XAJAX_POST)
396
+	function registerFunction($mFunction, $sRequestType = XAJAX_POST)
397 397
 	{
398 398
 		if (is_array($mFunction)) {
399 399
 			$this->aFunctions[$mFunction[0]] = 1;
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 	 * @param mixed  the RequestType (XAJAX_GET/XAJAX_POST) that should be used
421 421
 	 *		          for this function. Defaults to XAJAX_POST.
422 422
 	 */
423
-	function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST)
423
+	function registerExternalFunction($mFunction, $sIncludeFile, $sRequestType = XAJAX_POST)
424 424
 	{
425 425
 		$this->registerFunction($mFunction, $sRequestType);
426 426
 
@@ -545,10 +545,10 @@  discard block
 block discarded – undo
545 545
 		}
546 546
 		else
547 547
 		{
548
-			header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
549
-			header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
550
-			header ("Cache-Control: no-cache, must-revalidate");
551
-			header ("Pragma: no-cache");
548
+			header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
549
+			header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");
550
+			header("Cache-Control: no-cache, must-revalidate");
551
+			header("Pragma: no-cache");
552 552
 
553 553
 			$sFunctionName = $_GET["xajax"];
554 554
 
@@ -566,12 +566,12 @@  discard block
 block discarded – undo
566 566
 			if (!$this->_isFunctionCallable($this->sPreFunction)) {
567 567
 				$bFoundFunction = false;
568 568
 				$objResponse = new xajaxResponse();
569
-				$objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction);
569
+				$objResponse->addAlert("Unknown Pre-Function ".$this->sPreFunction);
570 570
 				$sResponse = $objResponse->getXML();
571 571
 			}
572 572
 		}
573 573
 		//include any external dependencies associated with this function name
574
-		if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles))
574
+		if (array_key_exists($sFunctionName, $this->aFunctionIncludeFiles))
575 575
 		{
576 576
 			ob_start();
577 577
 			include_once($this->aFunctionIncludeFiles[$sFunctionName]);
@@ -611,13 +611,13 @@  discard block
 block discarded – undo
611 611
 
612 612
 					$aArgs[$i] = stripslashes($aArgs[$i]);
613 613
 				}
614
-				if (stristr($aArgs[$i],"<xjxobj>") != false)
614
+				if (stristr($aArgs[$i], "<xjxobj>") != false)
615 615
 				{
616
-					$aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
616
+					$aArgs[$i] = $this->_xmlToArray("xjxobj", $aArgs[$i]);
617 617
 				}
618
-				else if (stristr($aArgs[$i],"<xjxquery>") != false)
618
+				else if (stristr($aArgs[$i], "<xjxquery>") != false)
619 619
 				{
620
-					$aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
620
+					$aArgs[$i] = $this->_xmlToArray("xjxquery", $aArgs[$i]);
621 621
 				}
622 622
 				else if ($this->bDecodeUTF8Input)
623 623
 				{
@@ -673,16 +673,16 @@  discard block
 block discarded – undo
673 673
 		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
674 674
 			$sContentHeader .= " charset=".$this->sEncoding;
675 675
 		header($sContentHeader);
676
-		if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
676
+		if ($this->bErrorHandler && !empty($GLOBALS['xajaxErrorHandlerText'])) {
677 677
 			$sErrorResponse = new xajaxResponse();
678
-			$sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']);
678
+			$sErrorResponse->addAlert("** PHP Error Messages: **".$GLOBALS['xajaxErrorHandlerText']);
679 679
 			if ($this->sLogFile) {
680 680
 				$fH = @fopen($this->sLogFile, "a");
681 681
 				if (!$fH) {
682
-					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
682
+					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n".$this->sLogFile);
683 683
 				}
684 684
 				else {
685
-					fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
685
+					fwrite($fH, "** xajax Error Log - ".strftime("%b %e %Y %I:%M:%S %p")." **".$GLOBALS['xajaxErrorHandlerText']."\n\n\n");
686 686
 					fclose($fH);
687 687
 				}
688 688
 			}
@@ -724,7 +724,7 @@  discard block
 block discarded – undo
724 724
 	 *               engine located within the xajax installation folder.
725 725
 	 *               Defaults to xajax_js/xajax.js.
726 726
 	 */
727
-	function printJavascript($sJsURI="", $sJsFile=NULL)
727
+	function printJavascript($sJsURI = "", $sJsFile = NULL)
728 728
 	{
729 729
 		print $this->getJavascript($sJsURI, $sJsFile);
730 730
 	}
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	 *               Defaults to xajax_js/xajax.js.
754 754
 	 * @return string
755 755
 	 */
756
-	function getJavascript($sJsURI="", $sJsFile=NULL)
756
+	function getJavascript($sJsURI = "", $sJsFile = NULL)
757 757
 	{
758 758
 		$html = $this->getJavascriptConfig();
759 759
 		$html .= $this->getJavascriptInclude($sJsURI, $sJsFile);
@@ -771,15 +771,15 @@  discard block
 block discarded – undo
771 771
 	{
772 772
 		$html  = "\t<script type=\"text/javascript\">\n";
773 773
 		$html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n";
774
-		$html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n";
775
-		$html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n";
776
-		$html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n";
774
+		$html .= "var xajaxDebug=".($this->bDebug ? "true" : "false").";\n";
775
+		$html .= "var xajaxStatusMessages=".($this->bStatusMessages ? "true" : "false").";\n";
776
+		$html .= "var xajaxWaitCursor=".($this->bWaitCursor ? "true" : "false").";\n";
777 777
 		$html .= "var xajaxDefinedGet=".XAJAX_GET.";\n";
778 778
 		$html .= "var xajaxDefinedPost=".XAJAX_POST.";\n";
779 779
 		$html .= "var xajaxLoaded=false;\n";
780 780
 
781
-		foreach($this->aFunctions as $sFunction => $bExists) {
782
-			$html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]);
781
+		foreach ($this->aFunctions as $sFunction => $bExists) {
782
+			$html .= $this->_wrap($sFunction, $this->aFunctionRequestTypes[$sFunction]);
783 783
 		}
784 784
 
785 785
 		$html .= "\t</script>\n";
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
 	 *               Defaults to xajax_js/xajax.js.
804 804
 	 * @return string
805 805
 	 */
806
-	function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
806
+	function getJavascriptInclude($sJsURI = "", $sJsFile = NULL)
807 807
 	{
808 808
         //if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
809 809
         $sJsFile = "xajax_js/xajax.js";
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
         //if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
812 812
         $sJsURI = api_get_path(WEB_LIBRARY_JS_PATH);
813 813
 
814
-		$html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
814
+		$html = "\t<script type=\"text/javascript\" src=\"".$sJsURI.$sJsFile."\"></script>\n";
815 815
 		$html .= "\t<script type=\"text/javascript\">\n";
816 816
 		$html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n";
817 817
 		$html .= "\t</script>\n";
@@ -826,7 +826,7 @@  discard block
 block discarded – undo
826 826
 	 * @param string an optional argument containing the full server file path
827 827
 	 *               of xajax.js.
828 828
 	 */
829
-	function autoCompressJavascript($sJsFullFilename=NULL)
829
+	function autoCompressJavascript($sJsFullFilename = NULL)
830 830
 	{
831 831
 		$sJsFile = "xajax_js/xajax.js";
832 832
 
@@ -835,21 +835,21 @@  discard block
 block discarded – undo
835 835
 		}
836 836
 		else {
837 837
 			$realPath = realpath(dirname(__FILE__));
838
-			$realJsFile = $realPath . "/". $sJsFile;
838
+			$realJsFile = $realPath."/".$sJsFile;
839 839
 		}
840 840
 
841 841
 		// Create a compressed file if necessary
842 842
 		if (!file_exists($realJsFile)) {
843 843
 			$srcFile = str_replace(".js", "_uncompressed.js", $realJsFile);
844 844
 			if (!file_exists($srcFile)) {
845
-				trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
845
+				trigger_error("The xajax uncompressed Javascript file could not be found in the <b>".dirname($realJsFile)."</b> folder. Error ", E_USER_ERROR);
846 846
 			}
847 847
 			require(dirname(__FILE__)."/xajaxCompress.php");
848 848
 			$javaScript = implode('', file($srcFile));
849 849
 			$compressedScript = xajaxCompressJavascript($javaScript);
850 850
 			$fH = @fopen($realJsFile, "w");
851 851
 			if (!$fH) {
852
-				trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
852
+				trigger_error("The xajax compressed javascript file could not be written in the <b>".dirname($realJsFile)."</b> folder. Error ", E_USER_ERROR);
853 853
 			}
854 854
 			else {
855 855
 				fwrite($fH, $compressedScript);
@@ -918,23 +918,23 @@  discard block
 block discarded – undo
918 918
 		// Build the URL: Start with scheme, user and pass
919 919
 		$sURL = $aURL['scheme'].'://';
920 920
 		if (!empty($aURL['user'])) {
921
-			$sURL.= $aURL['user'];
921
+			$sURL .= $aURL['user'];
922 922
 			if (!empty($aURL['pass'])) {
923
-				$sURL.= ':'.$aURL['pass'];
923
+				$sURL .= ':'.$aURL['pass'];
924 924
 			}
925
-			$sURL.= '@';
925
+			$sURL .= '@';
926 926
 		}
927 927
 
928 928
 		// Add the host
929
-		$sURL.= $aURL['host'];
929
+		$sURL .= $aURL['host'];
930 930
 
931 931
 		// Add the port if needed
932 932
 		if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) {
933
-			$sURL.= ':'.$aURL['port'];
933
+			$sURL .= ':'.$aURL['port'];
934 934
 		}
935 935
 
936 936
 		// Add the path and the query string
937
-		$sURL.= $aURL['path'].@$aURL['query'];
937
+		$sURL .= $aURL['path'].@$aURL['query'];
938 938
 
939 939
 		// Clean up
940 940
 		unset($aURL);
@@ -1006,7 +1006,7 @@  discard block
 block discarded – undo
1006 1006
 	 * @access private
1007 1007
 	 * @return string
1008 1008
 	 */
1009
-	function _wrap($sFunction,$sRequestType=XAJAX_POST)
1009
+	function _wrap($sFunction, $sRequestType = XAJAX_POST)
1010 1010
 	{
1011 1011
 		$js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n";
1012 1012
 		return $js;
@@ -1025,18 +1025,18 @@  discard block
 block discarded – undo
1025 1025
 	function _xmlToArray($rootTag, $sXml)
1026 1026
 	{
1027 1027
 		$aArray = array();
1028
-		$sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml);
1029
-		$sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml);
1030
-		$sXml = str_replace("<e>","<e>|~|",$sXml);
1031
-		$sXml = str_replace("</e>","</e>|~|",$sXml);
1032
-		$sXml = str_replace("<k>","<k>|~|",$sXml);
1033
-		$sXml = str_replace("</k>","|~|</k>|~|",$sXml);
1034
-		$sXml = str_replace("<v>","<v>|~|",$sXml);
1035
-		$sXml = str_replace("</v>","|~|</v>|~|",$sXml);
1036
-		$sXml = str_replace("<q>","<q>|~|",$sXml);
1037
-		$sXml = str_replace("</q>","|~|</q>|~|",$sXml);
1038
-
1039
-		$this->aObjArray = explode("|~|",$sXml);
1028
+		$sXml = str_replace("<$rootTag>", "<$rootTag>|~|", $sXml);
1029
+		$sXml = str_replace("</$rootTag>", "</$rootTag>|~|", $sXml);
1030
+		$sXml = str_replace("<e>", "<e>|~|", $sXml);
1031
+		$sXml = str_replace("</e>", "</e>|~|", $sXml);
1032
+		$sXml = str_replace("<k>", "<k>|~|", $sXml);
1033
+		$sXml = str_replace("</k>", "|~|</k>|~|", $sXml);
1034
+		$sXml = str_replace("<v>", "<v>|~|", $sXml);
1035
+		$sXml = str_replace("</v>", "|~|</v>|~|", $sXml);
1036
+		$sXml = str_replace("<q>", "<q>|~|", $sXml);
1037
+		$sXml = str_replace("</q>", "|~|</q>|~|", $sXml);
1038
+
1039
+		$this->aObjArray = explode("|~|", $sXml);
1040 1040
 
1041 1041
 		$this->iPos = 0;
1042 1042
 		$aArray = $this->_parseObjXml($rootTag);
@@ -1058,32 +1058,32 @@  discard block
 block discarded – undo
1058 1058
 
1059 1059
 		if ($rootTag == "xjxobj")
1060 1060
 		{
1061
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>"))
1061
+			while (!stristr($this->aObjArray[$this->iPos], "</xjxobj>"))
1062 1062
 			{
1063 1063
 				$this->iPos++;
1064
-				if(stristr($this->aObjArray[$this->iPos],"<e>"))
1064
+				if (stristr($this->aObjArray[$this->iPos], "<e>"))
1065 1065
 				{
1066 1066
 					$key = "";
1067 1067
 					$value = null;
1068 1068
 
1069 1069
 					$this->iPos++;
1070
-					while(!stristr($this->aObjArray[$this->iPos],"</e>"))
1070
+					while (!stristr($this->aObjArray[$this->iPos], "</e>"))
1071 1071
 					{
1072
-						if(stristr($this->aObjArray[$this->iPos],"<k>"))
1072
+						if (stristr($this->aObjArray[$this->iPos], "<k>"))
1073 1073
 						{
1074 1074
 							$this->iPos++;
1075
-							while(!stristr($this->aObjArray[$this->iPos],"</k>"))
1075
+							while (!stristr($this->aObjArray[$this->iPos], "</k>"))
1076 1076
 							{
1077 1077
 								$key .= $this->aObjArray[$this->iPos];
1078 1078
 								$this->iPos++;
1079 1079
 							}
1080 1080
 						}
1081
-						if(stristr($this->aObjArray[$this->iPos],"<v>"))
1081
+						if (stristr($this->aObjArray[$this->iPos], "<v>"))
1082 1082
 						{
1083 1083
 							$this->iPos++;
1084
-							while(!stristr($this->aObjArray[$this->iPos],"</v>"))
1084
+							while (!stristr($this->aObjArray[$this->iPos], "</v>"))
1085 1085
 							{
1086
-								if(stristr($this->aObjArray[$this->iPos],"<xjxobj>"))
1086
+								if (stristr($this->aObjArray[$this->iPos], "<xjxobj>"))
1087 1087
 								{
1088 1088
 									$value = $this->_parseObjXml("xjxobj");
1089 1089
 									$this->iPos++;
@@ -1102,7 +1102,7 @@  discard block
 block discarded – undo
1102 1102
 						$this->iPos++;
1103 1103
 					}
1104 1104
 
1105
-					$aArray[$key]=$value;
1105
+					$aArray[$key] = $value;
1106 1106
 				}
1107 1107
 			}
1108 1108
 		}
@@ -1111,21 +1111,21 @@  discard block
 block discarded – undo
1111 1111
 		{
1112 1112
 			$sQuery = "";
1113 1113
 			$this->iPos++;
1114
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>"))
1114
+			while (!stristr($this->aObjArray[$this->iPos], "</xjxquery>"))
1115 1115
 			{
1116
-				if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>"))
1116
+				if (stristr($this->aObjArray[$this->iPos], "<q>") || stristr($this->aObjArray[$this->iPos], "</q>"))
1117 1117
 				{
1118 1118
 					$this->iPos++;
1119 1119
 					continue;
1120 1120
 				}
1121
-				$sQuery	.= $this->aObjArray[$this->iPos];
1121
+				$sQuery .= $this->aObjArray[$this->iPos];
1122 1122
 				$this->iPos++;
1123 1123
 			}
1124 1124
 
1125 1125
 			parse_str($sQuery, $aArray);
1126 1126
 			if ($this->bDecodeUTF8Input)
1127 1127
 			{
1128
-				foreach($aArray as $key => $value)
1128
+				foreach ($aArray as $key => $value)
1129 1129
 				{
1130 1130
 					$aArray[$key] = $this->_decodeUTF8Data($value);
1131 1131
 				}
Please login to merge, or discard this patch.
Indentation   +1165 added lines, -1165 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
  */
48 48
 if (!defined ('XAJAX_DEFAULT_CHAR_ENCODING'))
49 49
 {
50
-	define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' );
50
+    define ('XAJAX_DEFAULT_CHAR_ENCODING', 'utf-8' );
51 51
 }
52 52
 
53 53
 /**
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
  */
56 56
 if (!defined ('XAJAX_GET'))
57 57
 {
58
-	define ('XAJAX_GET', 0);
58
+    define ('XAJAX_GET', 0);
59 59
 }
60 60
 if (!defined ('XAJAX_POST'))
61 61
 {
62
-	define ('XAJAX_POST', 1);
62
+    define ('XAJAX_POST', 1);
63 63
 }
64 64
 
65 65
 /**
@@ -72,1145 +72,1145 @@  discard block
 block discarded – undo
72 72
  */
73 73
 class xajax
74 74
 {
75
-	/**#@+
75
+    /**#@+
76 76
 	 * @access protected
77 77
 	 */
78
-	/**
79
-	 * @var array Array of PHP functions that will be callable through javascript wrappers
80
-	 */
81
-	var $aFunctions;
82
-	/**
83
-	 * @var array Array of object callbacks that will allow Javascript to call PHP methods (key=function name)
84
-	 */
85
-	var $aObjects;
86
-	/**
87
-	 * @var array Array of RequestTypes to be used with each function (key=function name)
88
-	 */
89
-	var $aFunctionRequestTypes;
90
-	/**
91
-	 * @var array Array of Include Files for any external functions (key=function name)
92
-	 */
93
-	var $aFunctionIncludeFiles;
94
-	/**
95
-	 * @var string Name of the PHP function to call if no callable function was found
96
-	 */
97
-	var $sCatchAllFunction;
98
-	/**
99
-	 * @var string Name of the PHP function to call before any other function
100
-	 */
101
-	var $sPreFunction;
102
-	/**
103
-	 * @var string The URI for making requests to the xajax object
104
-	 */
105
-	var $sRequestURI;
106
-	/**
107
-	 * @var string The prefix to prepend to the javascript wraper function name
108
-	 */
109
-	var $sWrapperPrefix;
110
-	/**
111
-	 * @var boolean Show debug messages (default false)
112
-	 */
113
-	var $bDebug;
114
-	/**
115
-	 * @var boolean Show messages in the client browser's status bar (default false)
116
-	 */
117
-	var $bStatusMessages;
118
-	/**
119
-	 * @var boolean Allow xajax to exit after processing a request (default true)
120
-	 */
121
-	var $bExitAllowed;
122
-	/**
123
-	 * @var boolean Use wait cursor in browser (default true)
124
-	 */
125
-	var $bWaitCursor;
126
-	/**
127
-	 * @var boolean Use an special xajax error handler so the errors are sent to the browser properly (default false)
128
-	 */
129
-	var $bErrorHandler;
130
-	/**
131
-	 * @var string Specify what, if any, file xajax should log errors to (and more information in a future release)
132
-	 */
133
-	var $sLogFile;
134
-	/**
135
-	 * @var boolean Clean all output buffers before outputting response (default false)
136
-	 */
137
-	var $bCleanBuffer;
138
-	/**
139
-	 * @var string String containing the character encoding used
140
-	 */
141
-	var $sEncoding;
142
-	/**
143
-	 * @var boolean Decode input request args from UTF-8 (default false)
144
-	 */
145
-	var $bDecodeUTF8Input;
146
-	/**
147
-	 * @var boolean Convert special characters to HTML entities (default false)
148
-	 */
149
-	var $bOutputEntities;
150
-	/**
151
-	 * @var array Array for parsing complex objects
152
-	 */
153
-	var $aObjArray;
154
-	/**
155
-	 * @var integer Position in $aObjArray
156
-	 */
157
-	var $iPos;
158
-
159
-	/**#@-*/
160
-
161
-	/**
162
-	 * Constructor. You can set some extra xajax options right away or use
163
-	 * individual methods later to set options.
164
-	 *
165
-	 * @param string  defaults to the current browser URI
166
-	 * @param string  defaults to "xajax_";
167
-	 * @param string  defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above
168
-	 * @param boolean defaults to false
169
-	 */
170
-	public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false)
171
-	{
172
-		$this->aFunctions = array();
173
-		$this->aObjects = array();
174
-		$this->aFunctionIncludeFiles = array();
175
-		$this->sRequestURI = $sRequestURI;
176
-		if ($this->sRequestURI == "")
177
-			$this->sRequestURI = $this->_detectURI();
178
-		$this->sWrapperPrefix = $sWrapperPrefix;
179
-		$this->bDebug = $bDebug;
180
-		$this->bStatusMessages = false;
181
-		$this->bWaitCursor = true;
182
-		$this->bExitAllowed = true;
183
-		$this->bErrorHandler = false;
184
-		$this->sLogFile = "";
185
-		$this->bCleanBuffer = false;
186
-		$this->setCharEncoding($sEncoding);
187
-		$this->bDecodeUTF8Input = false;
188
-		$this->bOutputEntities = false;
189
-	}
190
-
191
-	/**
192
-	 * Sets the URI to which requests will be made.
193
-	 * <i>Usage:</i> <kbd>$xajax->setRequestURI("http://www.xajaxproject.org");</kbd>
194
-	 *
195
-	 * @param string the URI (can be absolute or relative) of the PHP script
196
-	 *               that will be accessed when an xajax request occurs
197
-	 */
198
-	function setRequestURI($sRequestURI)
199
-	{
200
-		$this->sRequestURI = $sRequestURI;
201
-	}
202
-
203
-	/**
204
-	 * Sets the prefix that will be appended to the Javascript wrapper
205
-	 * functions (default is "xajax_").
206
-	 *
207
-	 * @param string
208
-	 */
209
-	//
210
-	function setWrapperPrefix($sPrefix)
211
-	{
212
-		$this->sWrapperPrefix = $sPrefix;
213
-	}
214
-
215
-	/**
216
-	 * Enables debug messages for xajax.
217
-	 * */
218
-	function debugOn()
219
-	{
220
-		$this->bDebug = true;
221
-	}
222
-
223
-	/**
224
-	 * Disables debug messages for xajax (default behavior).
225
-	 */
226
-	function debugOff()
227
-	{
228
-		$this->bDebug = false;
229
-	}
230
-
231
-	/**
232
-	 * Enables messages in the browser's status bar for xajax.
233
-	 */
234
-	function statusMessagesOn()
235
-	{
236
-		$this->bStatusMessages = true;
237
-	}
238
-
239
-	/**
240
-	 * Disables messages in the browser's status bar for xajax (default behavior).
241
-	 */
242
-	function statusMessagesOff()
243
-	{
244
-		$this->bStatusMessages = false;
245
-	}
246
-
247
-	/**
248
-	 * Enables the wait cursor to be displayed in the browser (default behavior).
249
-	 */
250
-	function waitCursorOn()
251
-	{
252
-		$this->bWaitCursor = true;
253
-	}
254
-
255
-	/**
256
-	 * Disables the wait cursor to be displayed in the browser.
257
-	 */
258
-	function waitCursorOff()
259
-	{
260
-		$this->bWaitCursor = false;
261
-	}
262
-
263
-	/**
264
-	 * Enables xajax to exit immediately after processing a request and
265
-	 * sending the response back to the browser (default behavior).
266
-	 */
267
-	function exitAllowedOn()
268
-	{
269
-		$this->bExitAllowed = true;
270
-	}
271
-
272
-	/**
273
-	 * Disables xajax's default behavior of exiting immediately after
274
-	 * processing a request and sending the response back to the browser.
275
-	 */
276
-	function exitAllowedOff()
277
-	{
278
-		$this->bExitAllowed = false;
279
-	}
280
-
281
-	/**
282
-	 * Turns on xajax's error handling system so that PHP errors that occur
283
-	 * during a request are trapped and pushed to the browser in the form of
284
-	 * a Javascript alert.
285
-	 */
286
-	function errorHandlerOn()
287
-	{
288
-		$this->bErrorHandler = true;
289
-	}
290
-
291
-	/**
292
-	 * Turns off xajax's error handling system (default behavior).
293
-	 */
294
-	function errorHandlerOff()
295
-	{
296
-		$this->bErrorHandler = false;
297
-	}
298
-
299
-	/**
300
-	 * Specifies a log file that will be written to by xajax during a request
301
-	 * (used only by the error handling system at present). If you don't invoke
302
-	 * this method, or you pass in "", then no log file will be written to.
303
-	 * <i>Usage:</i> <kbd>$xajax->setLogFile("/xajax_logs/errors.log");</kbd>
304
-	 */
305
-	function setLogFile($sFilename)
306
-	{
307
-		$this->sLogFile = $sFilename;
308
-	}
309
-
310
-	/**
311
-	 * Causes xajax to clean out all output buffers before outputting a
312
-	 * response (default behavior).
313
-	 */
314
-	function cleanBufferOn()
315
-	{
316
-		$this->bCleanBuffer = true;
317
-	}
318
-	/**
319
-	 * Turns off xajax's output buffer cleaning.
320
-	 */
321
-	function cleanBufferOff()
322
-	{
323
-		$this->bCleanBuffer = false;
324
-	}
325
-
326
-	/**
327
-	 * Sets the character encoding for the HTTP output based on
328
-	 * <kbd>$sEncoding</kbd>, which is a string containing the character
329
-	 * encoding to use. You don't need to use this method normally, since the
330
-	 * character encoding for the response gets set automatically based on the
331
-	 * <kbd>XAJAX_DEFAULT_CHAR_ENCODING</kbd> constant.
332
-	 * <i>Usage:</i> <kbd>$xajax->setCharEncoding("utf-8");</kbd>
333
-	 *
334
-	 * @param string the encoding type to use (utf-8, iso-8859-1, etc.)
335
-	 */
336
-	function setCharEncoding($sEncoding)
337
-	{
338
-		$this->sEncoding = $sEncoding;
339
-	}
340
-
341
-	/**
342
-	 * Causes xajax to decode the input request args from UTF-8 to the current
343
-	 * encoding if possible. Either the iconv or mb_string extension must be
344
-	 * present for optimal functionality.
345
-	 */
346
-	function decodeUTF8InputOn()
347
-	{
348
-		$this->bDecodeUTF8Input = true;
349
-	}
350
-
351
-	/**
352
-	 * Turns off decoding the input request args from UTF-8 (default behavior).
353
-	 */
354
-	function decodeUTF8InputOff()
355
-	{
356
-		$this->bDecodeUTF8Input = false;
357
-	}
358
-
359
-	/**
360
-	 * Tells the response object to convert special characters to HTML entities
361
-	 * automatically (only works if the mb_string extension is available).
362
-	 */
363
-	function outputEntitiesOn()
364
-	{
365
-		$this->bOutputEntities = true;
366
-	}
367
-
368
-	/**
369
-	 * Tells the response object to output special characters intact. (default
370
-	 * behavior).
371
-	 */
372
-	function outputEntitiesOff()
373
-	{
374
-		$this->bOutputEntities = false;
375
-	}
376
-
377
-	/**
378
-	 * Registers a PHP function or method to be callable through xajax in your
379
-	 * Javascript. If you want to register a function, pass in the name of that
380
-	 * function. If you want to register a static class method, pass in an
381
-	 * array like so:
382
-	 * <kbd>array("myFunctionName", "myClass", "myMethod")</kbd>
383
-	 * For an object instance method, use an object variable for the second
384
-	 * array element (and in PHP 4 make sure you put an & before the variable
385
-	 * to pass the object by reference). Note: the function name is what you
386
-	 * call via Javascript, so it can be anything as long as it doesn't
387
-	 * conflict with any other registered function name.
388
-	 *
389
-	 * <i>Usage:</i> <kbd>$xajax->registerFunction("myFunction");</kbd>
390
-	 * or: <kbd>$xajax->registerFunction(array("myFunctionName", &$myObject, "myMethod"));</kbd>
391
-	 *
392
-	 * @param mixed  contains the function name or an object callback array
393
-	 * @param mixed  request type (XAJAX_GET/XAJAX_POST) that should be used
394
-	 *               for this function.  Defaults to XAJAX_POST.
395
-	 */
396
-	function registerFunction($mFunction,$sRequestType=XAJAX_POST)
397
-	{
398
-		if (is_array($mFunction)) {
399
-			$this->aFunctions[$mFunction[0]] = 1;
400
-			$this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType;
401
-			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
402
-		}
403
-		else {
404
-			$this->aFunctions[$mFunction] = 1;
405
-			$this->aFunctionRequestTypes[$mFunction] = $sRequestType;
406
-		}
407
-	}
408
-
409
-	/**
410
-	 * Registers a PHP function to be callable through xajax which is located
411
-	 * in some other file.  If the function is requested the external file will
412
-	 * be included to define the function before the function is called.
413
-	 *
414
-	 * <i>Usage:</i> <kbd>$xajax->registerExternalFunction("myFunction","myFunction.inc.php",XAJAX_POST);</kbd>
415
-	 *
416
-	 * @param string contains the function name or an object callback array
417
-	 *               ({@link xajax::registerFunction() see registerFunction} for
418
-	 *               more info on object callback arrays)
419
-	 * @param string contains the path and filename of the include file
420
-	 * @param mixed  the RequestType (XAJAX_GET/XAJAX_POST) that should be used
421
-	 *		          for this function. Defaults to XAJAX_POST.
422
-	 */
423
-	function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST)
424
-	{
425
-		$this->registerFunction($mFunction, $sRequestType);
426
-
427
-		if (is_array($mFunction)) {
428
-			$this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile;
429
-		}
430
-		else {
431
-			$this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile;
432
-		}
433
-	}
434
-
435
-	/**
436
-	 * Registers a PHP function to be called when xajax cannot find the
437
-	 * function being called via Javascript. Because this is technically
438
-	 * impossible when using "wrapped" functions, the catch-all feature is
439
-	 * only useful when you're directly using the xajax.call() Javascript
440
-	 * method. Use the catch-all feature when you want more dynamic ability to
441
-	 * intercept unknown calls and handle them in a custom way.
442
-	 *
443
-	 * <i>Usage:</i> <kbd>$xajax->registerCatchAllFunction("myCatchAllFunction");</kbd>
444
-	 *
445
-	 * @param string contains the function name or an object callback array
446
-	 *               ({@link xajax::registerFunction() see registerFunction} for
447
-	 *               more info on object callback arrays)
448
-	 */
449
-	function registerCatchAllFunction($mFunction)
450
-	{
451
-		if (is_array($mFunction)) {
452
-			$this->sCatchAllFunction = $mFunction[0];
453
-			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
454
-		}
455
-		else {
456
-			$this->sCatchAllFunction = $mFunction;
457
-		}
458
-	}
459
-
460
-	/**
461
-	 * Registers a PHP function to be called before xajax calls the requested
462
-	 * function. xajax will automatically add the request function's response
463
-	 * to the pre-function's response to create a single response. Another
464
-	 * feature is the ability to return not just a response, but an array with
465
-	 * the first element being false (a boolean) and the second being the
466
-	 * response. In this case, the pre-function's response will be returned to
467
-	 * the browser without xajax calling the requested function.
468
-	 *
469
-	 * <i>Usage:</i> <kbd>$xajax->registerPreFunction("myPreFunction");</kbd>
470
-	 *
471
-	 * @param string contains the function name or an object callback array
472
-	 *               ({@link xajax::registerFunction() see registerFunction} for
473
-	 *               more info on object callback arrays)
474
-	 */
475
-	function registerPreFunction($mFunction)
476
-	{
477
-		if (is_array($mFunction)) {
478
-			$this->sPreFunction = $mFunction[0];
479
-			$this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
480
-		}
481
-		else {
482
-			$this->sPreFunction = $mFunction;
483
-		}
484
-	}
485
-
486
-	/**
487
-	 * Returns true if xajax can process the request, false if otherwise.
488
-	 * You can use this to determine if xajax needs to process the request or
489
-	 * not.
490
-	 *
491
-	 * @return boolean
492
-	 */
493
-	function canProcessRequests()
494
-	{
495
-		if ($this->getRequestMode() != -1) return true;
496
-		return false;
497
-	}
498
-
499
-	/**
500
-	 * Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if
501
-	 * there is none.
502
-	 *
503
-	 * @return mixed
504
-	 */
505
-	function getRequestMode()
506
-	{
507
-		if (!empty($_GET["xajax"]))
508
-			return XAJAX_GET;
509
-
510
-		if (!empty($_POST["xajax"]))
511
-			return XAJAX_POST;
512
-
513
-		return -1;
514
-	}
515
-
516
-	/**
517
-	 * This is the main communications engine of xajax. The engine handles all
518
-	 * incoming xajax requests, calls the apporiate PHP functions (or
519
-	 * class/object methods) and passes the XML responses back to the
520
-	 * Javascript response handler. If your RequestURI is the same as your Web
521
-	 * page then this function should be called before any headers or HTML has
522
-	 * been sent.
523
-	 */
524
-	function processRequests()
525
-	{
526
-
527
-		$requestMode = -1;
528
-		$sFunctionName = "";
529
-		$bFoundFunction = true;
530
-		$bFunctionIsCatchAll = false;
531
-		$sFunctionNameForSpecial = "";
532
-		$aArgs = array();
533
-		$sPreResponse = "";
534
-		$bEndRequest = false;
535
-		$sResponse = "";
536
-
537
-		$requestMode = $this->getRequestMode();
538
-		if ($requestMode == -1) return;
539
-
540
-		if ($requestMode == XAJAX_POST)
541
-		{
542
-			$sFunctionName = $_POST["xajax"];
543
-
544
-			if (!empty($_POST["xajaxargs"]))
545
-				$aArgs = $_POST["xajaxargs"];
546
-		}
547
-		else
548
-		{
549
-			header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
550
-			header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
551
-			header ("Cache-Control: no-cache, must-revalidate");
552
-			header ("Pragma: no-cache");
553
-
554
-			$sFunctionName = $_GET["xajax"];
555
-
556
-			if (!empty($_GET["xajaxargs"]))
557
-				$aArgs = $_GET["xajaxargs"];
558
-		}
559
-
560
-		// Use xajax error handler if necessary
561
-		if ($this->bErrorHandler) {
562
-			$GLOBALS['xajaxErrorHandlerText'] = "";
563
-			set_error_handler("xajaxErrorHandler");
564
-		}
565
-
566
-		if ($this->sPreFunction) {
567
-			if (!$this->_isFunctionCallable($this->sPreFunction)) {
568
-				$bFoundFunction = false;
569
-				$objResponse = new xajaxResponse();
570
-				$objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction);
571
-				$sResponse = $objResponse->getXML();
572
-			}
573
-		}
574
-		//include any external dependencies associated with this function name
575
-		if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles))
576
-		{
577
-			ob_start();
578
-			include_once($this->aFunctionIncludeFiles[$sFunctionName]);
579
-			ob_end_clean();
580
-		}
581
-
582
-		if ($bFoundFunction) {
583
-			$sFunctionNameForSpecial = $sFunctionName;
584
-			if (!array_key_exists($sFunctionName, $this->aFunctions))
585
-			{
586
-				if ($this->sCatchAllFunction) {
587
-					$sFunctionName = $this->sCatchAllFunction;
588
-					$bFunctionIsCatchAll = true;
589
-				}
590
-				else {
591
-					$bFoundFunction = false;
592
-					$objResponse = new xajaxResponse();
593
-					$objResponse->addAlert("Unknown Function $sFunctionName.");
594
-					$sResponse = $objResponse->getXML();
595
-				}
596
-			}
597
-			else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode)
598
-			{
599
-				$bFoundFunction = false;
600
-				$objResponse = new xajaxResponse();
601
-				$objResponse->addAlert("Incorrect Request Type.");
602
-				$sResponse = $objResponse->getXML();
603
-			}
604
-		}
605
-
606
-		if ($bFoundFunction)
607
-		{
608
-			for ($i = 0; $i < sizeof($aArgs); $i++)
609
-			{
610
-				// If magic quotes is on, then we need to strip the slashes from the args
611
-				if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) {
612
-
613
-					$aArgs[$i] = stripslashes($aArgs[$i]);
614
-				}
615
-				if (stristr($aArgs[$i],"<xjxobj>") != false)
616
-				{
617
-					$aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
618
-				}
619
-				else if (stristr($aArgs[$i],"<xjxquery>") != false)
620
-				{
621
-					$aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
622
-				}
623
-				else if ($this->bDecodeUTF8Input)
624
-				{
625
-					$aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]);
626
-				}
627
-			}
628
-
629
-			if ($this->sPreFunction) {
630
-				$mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs));
631
-				if (is_array($mPreResponse) && $mPreResponse[0] === false) {
632
-					$bEndRequest = true;
633
-					$sPreResponse = $mPreResponse[1];
634
-				}
635
-				else {
636
-					$sPreResponse = $mPreResponse;
637
-				}
638
-				if (is_a($sPreResponse, "xajaxResponse")) {
639
-					$sPreResponse = $sPreResponse->getXML();
640
-				}
641
-				if ($bEndRequest) $sResponse = $sPreResponse;
642
-			}
643
-
644
-			if (!$bEndRequest) {
645
-				if (!$this->_isFunctionCallable($sFunctionName)) {
646
-					$objResponse = new xajaxResponse();
647
-					$objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found.");
648
-					$sResponse = $objResponse->getXML();
649
-				}
650
-				else {
651
-					if ($bFunctionIsCatchAll) {
652
-						$aArgs = array($sFunctionNameForSpecial, $aArgs);
653
-					}
654
-					$sResponse = $this->_callFunction($sFunctionName, $aArgs);
655
-				}
656
-				if (is_a($sResponse, "xajaxResponse")) {
657
-					$sResponse = $sResponse->getXML();
658
-				}
659
-				if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) {
660
-					$objResponse = new xajaxResponse();
661
-					$objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName.");
662
-					$sResponse = $objResponse->getXML();
663
-				}
664
-				else if ($sPreResponse != "") {
665
-					$sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities);
666
-					$sNewResponse->loadXML($sPreResponse);
667
-					$sNewResponse->loadXML($sResponse);
668
-					$sResponse = $sNewResponse->getXML();
669
-				}
670
-			}
671
-		}
672
-
673
-		$sContentHeader = "Content-type: text/xml;";
674
-		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
675
-			$sContentHeader .= " charset=".$this->sEncoding;
676
-		header($sContentHeader);
677
-		if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
678
-			$sErrorResponse = new xajaxResponse();
679
-			$sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']);
680
-			if ($this->sLogFile) {
681
-				$fH = @fopen($this->sLogFile, "a");
682
-				if (!$fH) {
683
-					$sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
684
-				}
685
-				else {
686
-					fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
687
-					fclose($fH);
688
-				}
689
-			}
690
-
691
-			$sErrorResponse->loadXML($sResponse);
692
-			$sResponse = $sErrorResponse->getXML();
693
-
694
-		}
695
-		if ($this->bCleanBuffer) while (@ob_end_clean());
696
-		print $sResponse;
697
-		if ($this->bErrorHandler) restore_error_handler();
698
-
699
-		if ($this->bExitAllowed)
700
-			exit();
701
-	}
702
-
703
-	/**
704
-	 * Prints the xajax Javascript header and wrapper code into your page by
705
-	 * printing the output of the getJavascript() method. It should only be
706
-	 * called between the <pre><head> </head></pre> tags in your HTML page.
707
-	 * Remember, if you only want to obtain the result of this function, use
708
-	 * {@link xajax::getJavascript()} instead.
709
-	 *
710
-	 * <i>Usage:</i>
711
-	 * <code>
712
-	 *  <head>
713
-	 *		...
714
-	 *		< ?php $xajax->printJavascript(); ? >
715
-	 * </code>
716
-	 *
717
-	 * @param string the relative address of the folder where xajax has been
718
-	 *               installed. For instance, if your PHP file is
719
-	 *               "http://www.myserver.com/myfolder/mypage.php"
720
-	 *               and xajax was installed in
721
-	 *               "http://www.myserver.com/anotherfolder", then $sJsURI
722
-	 *               should be set to "../anotherfolder". Defaults to assuming
723
-	 *               xajax is in the same folder as your PHP file.
724
-	 * @param string the relative folder/file pair of the xajax Javascript
725
-	 *               engine located within the xajax installation folder.
726
-	 *               Defaults to xajax_js/xajax.js.
727
-	 */
728
-	function printJavascript($sJsURI="", $sJsFile=NULL)
729
-	{
730
-		print $this->getJavascript($sJsURI, $sJsFile);
731
-	}
732
-
733
-	/**
734
-	 * Returns the xajax Javascript code that should be added to your HTML page
735
-	 * between the <kbd><head> </head></kbd> tags.
736
-	 *
737
-	 * <i>Usage:</i>
738
-	 * <code>
739
-	 *  < ?php $xajaxJSHead = $xajax->getJavascript(); ? >
740
-	 *	<head>
741
-	 *		...
742
-	 *		< ?php echo $xajaxJSHead; ? >
743
-	 * </code>
744
-	 *
745
-	 * @param string the relative address of the folder where xajax has been
746
-	 *               installed. For instance, if your PHP file is
747
-	 *               "http://www.myserver.com/myfolder/mypage.php"
748
-	 *               and xajax was installed in
749
-	 *               "http://www.myserver.com/anotherfolder", then $sJsURI
750
-	 *               should be set to "../anotherfolder". Defaults to assuming
751
-	 *               xajax is in the same folder as your PHP file.
752
-	 * @param string the relative folder/file pair of the xajax Javascript
753
-	 *               engine located within the xajax installation folder.
754
-	 *               Defaults to xajax_js/xajax.js.
755
-	 * @return string
756
-	 */
757
-	function getJavascript($sJsURI="", $sJsFile=NULL)
758
-	{
759
-		$html = $this->getJavascriptConfig();
760
-		$html .= $this->getJavascriptInclude($sJsURI, $sJsFile);
761
-
762
-		return $html;
763
-	}
764
-
765
-	/**
766
-	 * Returns a string containing inline Javascript that sets up the xajax
767
-	 * runtime (typically called internally by xajax from get/printJavascript).
768
-	 *
769
-	 * @return string
770
-	 */
771
-	function getJavascriptConfig()
772
-	{
773
-		$html  = "\t<script type=\"text/javascript\">\n";
774
-		$html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n";
775
-		$html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n";
776
-		$html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n";
777
-		$html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n";
778
-		$html .= "var xajaxDefinedGet=".XAJAX_GET.";\n";
779
-		$html .= "var xajaxDefinedPost=".XAJAX_POST.";\n";
780
-		$html .= "var xajaxLoaded=false;\n";
781
-
782
-		foreach($this->aFunctions as $sFunction => $bExists) {
783
-			$html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]);
784
-		}
785
-
786
-		$html .= "\t</script>\n";
787
-		return $html;
788
-	}
789
-
790
-	/**
791
-	 * Returns a string containing a Javascript include of the xajax.js file
792
-	 * along with a check to see if the file loaded after six seconds
793
-	 * (typically called internally by xajax from get/printJavascript).
794
-	 *
795
-	 * @param string the relative address of the folder where xajax has been
796
-	 *               installed. For instance, if your PHP file is
797
-	 *               "http://www.myserver.com/myfolder/mypage.php"
798
-	 *               and xajax was installed in
799
-	 *               "http://www.myserver.com/anotherfolder", then $sJsURI
800
-	 *               should be set to "../anotherfolder". Defaults to assuming
801
-	 *               xajax is in the same folder as your PHP file.
802
-	 * @param string the relative folder/file pair of the xajax Javascript
803
-	 *               engine located within the xajax installation folder.
804
-	 *               Defaults to xajax_js/xajax.js.
805
-	 * @return string
806
-	 */
807
-	function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
808
-	{
809
-		if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
810
-
811
-		if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
812
-
813
-		$html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
814
-		$html .= "\t<script type=\"text/javascript\">\n";
815
-		$html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n";
816
-		$html .= "\t</script>\n";
817
-		return $html;
818
-	}
819
-
820
-	/**
821
-	 * This method can be used to create a new xajax.js file out of the
822
-	 * xajax_uncompressed.js file (which will only happen if xajax.js doesn't
823
-	 * already exist on the filesystem).
824
-	 *
825
-	 * @param string an optional argument containing the full server file path
826
-	 *               of xajax.js.
827
-	 */
828
-	function autoCompressJavascript($sJsFullFilename=NULL)
829
-	{
830
-		$sJsFile = "xajax_js/xajax.js";
831
-
832
-		if ($sJsFullFilename) {
833
-			$realJsFile = $sJsFullFilename;
834
-		}
835
-		else {
836
-			$realPath = realpath(dirname(__FILE__));
837
-			$realJsFile = $realPath . "/". $sJsFile;
838
-		}
839
-
840
-		// Create a compressed file if necessary
841
-		if (!file_exists($realJsFile)) {
842
-			$srcFile = str_replace(".js", "_uncompressed.js", $realJsFile);
843
-			if (!file_exists($srcFile)) {
844
-				trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
845
-			}
846
-			require(dirname(__FILE__)."/xajaxCompress.php");
847
-			$javaScript = implode('', file($srcFile));
848
-			$compressedScript = xajaxCompressJavascript($javaScript);
849
-			$fH = @fopen($realJsFile, "w");
850
-			if (!$fH) {
851
-				trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
852
-			}
853
-			else {
854
-				fwrite($fH, $compressedScript);
855
-				fclose($fH);
856
-			}
857
-		}
858
-	}
859
-
860
-	/**
861
-	 * Returns the current URL based upon the SERVER vars.
862
-	 *
863
-	 * @access private
864
-	 * @return string
865
-	 */
866
-	function _detectURI() {
867
-		$aURL = array();
868
-
869
-		// Try to get the request URL
870
-		if (!empty($_SERVER['REQUEST_URI'])) {
871
-			$aURL = parse_url($_SERVER['REQUEST_URI']);
872
-		}
873
-
874
-		// Fill in the empty values
875
-		if (empty($aURL['scheme'])) {
876
-			if (!empty($_SERVER['HTTP_SCHEME'])) {
877
-				$aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
878
-			} else {
879
-				$aURL['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http';
880
-			}
881
-		}
882
-
883
-		if (empty($aURL['host'])) {
884
-			if (!empty($_SERVER['HTTP_HOST'])) {
885
-				if (strpos($_SERVER['HTTP_HOST'], ':') > 0) {
886
-					list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']);
887
-				} else {
888
-					$aURL['host'] = $_SERVER['HTTP_HOST'];
889
-				}
890
-			} else if (!empty($_SERVER['SERVER_NAME'])) {
891
-				$aURL['host'] = $_SERVER['SERVER_NAME'];
892
-			} else {
893
-				print "xajax Error: xajax failed to automatically identify your Request URI.";
894
-				print "Please set the Request URI explicitly when you instantiate the xajax object.";
895
-				exit();
896
-			}
897
-		}
898
-
899
-		if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) {
900
-			$aURL['port'] = $_SERVER['SERVER_PORT'];
901
-		}
902
-
903
-		if (empty($aURL['path'])) {
904
-			if (!empty($_SERVER['PATH_INFO'])) {
905
-				$sPath = parse_url($_SERVER['PATH_INFO']);
906
-			} else {
907
-				$sPath = parse_url(api_get_self());
908
-			}
909
-			$aURL['path'] = $sPath['path'];
910
-			unset($sPath);
911
-		}
912
-
913
-		if (!empty($aURL['query'])) {
914
-			$aURL['query'] = '?'.$aURL['query'];
915
-		}
916
-
917
-		// Build the URL: Start with scheme, user and pass
918
-		$sURL = $aURL['scheme'].'://';
919
-		if (!empty($aURL['user'])) {
920
-			$sURL.= $aURL['user'];
921
-			if (!empty($aURL['pass'])) {
922
-				$sURL.= ':'.$aURL['pass'];
923
-			}
924
-			$sURL.= '@';
925
-		}
926
-
927
-		// Add the host
928
-		$sURL.= $aURL['host'];
929
-
930
-		// Add the port if needed
931
-		if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) {
932
-			$sURL.= ':'.$aURL['port'];
933
-		}
934
-
935
-		// Add the path and the query string
936
-		$sURL.= $aURL['path'].@$aURL['query'];
937
-
938
-		// Clean up
939
-		unset($aURL);
940
-		return $sURL;
941
-	}
942
-
943
-	/**
944
-	 * Returns true if the function name is associated with an object callback,
945
-	 * false if not.
946
-	 *
947
-	 * @param string the name of the function
948
-	 * @access private
949
-	 * @return boolean
950
-	 */
951
-	function _isObjectCallback($sFunction)
952
-	{
953
-		if (array_key_exists($sFunction, $this->aObjects)) return true;
954
-		return false;
955
-	}
956
-
957
-	/**
958
-	 * Returns true if the function or object callback can be called, false if
959
-	 * not.
960
-	 *
961
-	 * @param string the name of the function
962
-	 * @access private
963
-	 * @return boolean
964
-	 */
965
-	function _isFunctionCallable($sFunction)
966
-	{
967
-		if ($this->_isObjectCallback($sFunction)) {
968
-			if (is_object($this->aObjects[$sFunction][0])) {
969
-				return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]);
970
-			}
971
-			else {
972
-				return is_callable($this->aObjects[$sFunction]);
973
-			}
974
-		}
975
-		else {
976
-			return function_exists($sFunction);
977
-		}
978
-	}
979
-
980
-	/**
981
-	 * Calls the function, class method, or object method with the supplied
982
-	 * arguments.
983
-	 *
984
-	 * @param string the name of the function
985
-	 * @param array  arguments to pass to the function
986
-	 * @access private
987
-	 * @return mixed the output of the called function or method
988
-	 */
989
-	function _callFunction($sFunction, $aArgs)
990
-	{
991
-		if ($this->_isObjectCallback($sFunction)) {
992
-			$mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs);
993
-		}
994
-		else {
995
-			$mReturn = call_user_func_array($sFunction, $aArgs);
996
-		}
997
-		return $mReturn;
998
-	}
999
-
1000
-	/**
1001
-	 * Generates the Javascript wrapper for the specified PHP function.
1002
-	 *
1003
-	 * @param string the name of the function
1004
-	 * @param mixed  the request type
1005
-	 * @access private
1006
-	 * @return string
1007
-	 */
1008
-	function _wrap($sFunction,$sRequestType=XAJAX_POST)
1009
-	{
1010
-		$js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n";
1011
-		return $js;
1012
-	}
1013
-
1014
-	/**
1015
-	 * Takes a string containing xajax xjxobj XML or xjxquery XML and builds an
1016
-	 * array representation of it to pass as an argument to the PHP function
1017
-	 * being called.
1018
-	 *
1019
-	 * @param string the root tag of the XML
1020
-	 * @param string XML to convert
1021
-	 * @access private
1022
-	 * @return array
1023
-	 */
1024
-	function _xmlToArray($rootTag, $sXml)
1025
-	{
1026
-		$aArray = array();
1027
-		$sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml);
1028
-		$sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml);
1029
-		$sXml = str_replace("<e>","<e>|~|",$sXml);
1030
-		$sXml = str_replace("</e>","</e>|~|",$sXml);
1031
-		$sXml = str_replace("<k>","<k>|~|",$sXml);
1032
-		$sXml = str_replace("</k>","|~|</k>|~|",$sXml);
1033
-		$sXml = str_replace("<v>","<v>|~|",$sXml);
1034
-		$sXml = str_replace("</v>","|~|</v>|~|",$sXml);
1035
-		$sXml = str_replace("<q>","<q>|~|",$sXml);
1036
-		$sXml = str_replace("</q>","|~|</q>|~|",$sXml);
1037
-
1038
-		$this->aObjArray = explode("|~|",$sXml);
1039
-
1040
-		$this->iPos = 0;
1041
-		$aArray = $this->_parseObjXml($rootTag);
1042
-
1043
-		return $aArray;
1044
-	}
1045
-
1046
-	/**
1047
-	 * A recursive function that generates an array from the contents of
1048
-	 * $this->aObjArray.
1049
-	 *
1050
-	 * @param string the root tag of the XML
1051
-	 * @access private
1052
-	 * @return array
1053
-	 */
1054
-	function _parseObjXml($rootTag)
1055
-	{
1056
-		$aArray = array();
1057
-
1058
-		if ($rootTag == "xjxobj")
1059
-		{
1060
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>"))
1061
-			{
1062
-				$this->iPos++;
1063
-				if(stristr($this->aObjArray[$this->iPos],"<e>"))
1064
-				{
1065
-					$key = "";
1066
-					$value = null;
1067
-
1068
-					$this->iPos++;
1069
-					while(!stristr($this->aObjArray[$this->iPos],"</e>"))
1070
-					{
1071
-						if(stristr($this->aObjArray[$this->iPos],"<k>"))
1072
-						{
1073
-							$this->iPos++;
1074
-							while(!stristr($this->aObjArray[$this->iPos],"</k>"))
1075
-							{
1076
-								$key .= $this->aObjArray[$this->iPos];
1077
-								$this->iPos++;
1078
-							}
1079
-						}
1080
-						if(stristr($this->aObjArray[$this->iPos],"<v>"))
1081
-						{
1082
-							$this->iPos++;
1083
-							while(!stristr($this->aObjArray[$this->iPos],"</v>"))
1084
-							{
1085
-								if(stristr($this->aObjArray[$this->iPos],"<xjxobj>"))
1086
-								{
1087
-									$value = $this->_parseObjXml("xjxobj");
1088
-									$this->iPos++;
1089
-								}
1090
-								else
1091
-								{
1092
-									$value .= $this->aObjArray[$this->iPos];
1093
-									if ($this->bDecodeUTF8Input)
1094
-									{
1095
-										$value = $this->_decodeUTF8Data($value);
1096
-									}
1097
-								}
1098
-								$this->iPos++;
1099
-							}
1100
-						}
1101
-						$this->iPos++;
1102
-					}
1103
-
1104
-					$aArray[$key]=$value;
1105
-				}
1106
-			}
1107
-		}
1108
-
1109
-		if ($rootTag == "xjxquery")
1110
-		{
1111
-			$sQuery = "";
1112
-			$this->iPos++;
1113
-			while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>"))
1114
-			{
1115
-				if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>"))
1116
-				{
1117
-					$this->iPos++;
1118
-					continue;
1119
-				}
1120
-				$sQuery	.= $this->aObjArray[$this->iPos];
1121
-				$this->iPos++;
1122
-			}
1123
-
1124
-			parse_str($sQuery, $aArray);
1125
-			if ($this->bDecodeUTF8Input)
1126
-			{
1127
-				foreach($aArray as $key => $value)
1128
-				{
1129
-					$aArray[$key] = $this->_decodeUTF8Data($value);
1130
-				}
1131
-			}
1132
-			// If magic quotes is on, then we need to strip the slashes from the
1133
-			// array values because of the parse_str pass which adds slashes
1134
-			if (get_magic_quotes_gpc() == 1) {
1135
-				$newArray = array();
1136
-				foreach ($aArray as $sKey => $sValue) {
1137
-					if (is_string($sValue))
1138
-						$newArray[$sKey] = stripslashes($sValue);
1139
-					else
1140
-						$newArray[$sKey] = $sValue;
1141
-				}
1142
-				$aArray = $newArray;
1143
-			}
1144
-		}
1145
-
1146
-		return $aArray;
1147
-	}
1148
-
1149
-	/**
1150
-	 * Decodes string data from UTF-8 to the current xajax encoding.
1151
-	 *
1152
-	 * @param string data to convert
1153
-	 * @access private
1154
-	 * @return string converted data
1155
-	 */
1156
-	function _decodeUTF8Data($sData)
1157
-	{
1158
-		$sValue = $sData;
1159
-		if ($this->bDecodeUTF8Input)
1160
-		{
1161
-			$sFuncToUse = NULL;
1162
-
1163
-			// An adaptation for the Dokeos LMS, 22-AUG-2009.
1164
-			if (function_exists('api_convert_encoding'))
1165
-			{
1166
-				$sFuncToUse = "api_convert_encoding";
1167
-			}
1168
-			//if (function_exists('iconv'))
1169
-			elseif (function_exists('iconv'))
1170
-			//
1171
-			{
1172
-				$sFuncToUse = "iconv";
1173
-			}
1174
-			else if (function_exists('mb_convert_encoding'))
1175
-			{
1176
-				$sFuncToUse = "mb_convert_encoding";
1177
-			}
1178
-			else if ($this->sEncoding == "ISO-8859-1")
1179
-			{
1180
-				$sFuncToUse = "utf8_decode";
1181
-			}
1182
-			else
1183
-			{
1184
-				trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE);
1185
-			}
1186
-
1187
-			if ($sFuncToUse)
1188
-			{
1189
-				if (is_string($sValue))
1190
-				{
1191
-					if ($sFuncToUse == "iconv")
1192
-					{
1193
-						$sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue);
1194
-					}
1195
-					else if ($sFuncToUse == "mb_convert_encoding")
1196
-					{
1197
-						$sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1198
-					}
1199
-					// Added code, an adaptation for the Dokeos LMS, 22-AUG-2009.
1200
-					else if ($sFuncToUse == "api_convert_encoding")
1201
-					{
1202
-						$sValue = api_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1203
-					}
1204
-					//
1205
-					else
1206
-					{
1207
-						$sValue = utf8_decode($sValue);
1208
-					}
1209
-				}
1210
-			}
1211
-		}
1212
-		return $sValue;
1213
-	}
78
+    /**
79
+     * @var array Array of PHP functions that will be callable through javascript wrappers
80
+     */
81
+    var $aFunctions;
82
+    /**
83
+     * @var array Array of object callbacks that will allow Javascript to call PHP methods (key=function name)
84
+     */
85
+    var $aObjects;
86
+    /**
87
+     * @var array Array of RequestTypes to be used with each function (key=function name)
88
+     */
89
+    var $aFunctionRequestTypes;
90
+    /**
91
+     * @var array Array of Include Files for any external functions (key=function name)
92
+     */
93
+    var $aFunctionIncludeFiles;
94
+    /**
95
+     * @var string Name of the PHP function to call if no callable function was found
96
+     */
97
+    var $sCatchAllFunction;
98
+    /**
99
+     * @var string Name of the PHP function to call before any other function
100
+     */
101
+    var $sPreFunction;
102
+    /**
103
+     * @var string The URI for making requests to the xajax object
104
+     */
105
+    var $sRequestURI;
106
+    /**
107
+     * @var string The prefix to prepend to the javascript wraper function name
108
+     */
109
+    var $sWrapperPrefix;
110
+    /**
111
+     * @var boolean Show debug messages (default false)
112
+     */
113
+    var $bDebug;
114
+    /**
115
+     * @var boolean Show messages in the client browser's status bar (default false)
116
+     */
117
+    var $bStatusMessages;
118
+    /**
119
+     * @var boolean Allow xajax to exit after processing a request (default true)
120
+     */
121
+    var $bExitAllowed;
122
+    /**
123
+     * @var boolean Use wait cursor in browser (default true)
124
+     */
125
+    var $bWaitCursor;
126
+    /**
127
+     * @var boolean Use an special xajax error handler so the errors are sent to the browser properly (default false)
128
+     */
129
+    var $bErrorHandler;
130
+    /**
131
+     * @var string Specify what, if any, file xajax should log errors to (and more information in a future release)
132
+     */
133
+    var $sLogFile;
134
+    /**
135
+     * @var boolean Clean all output buffers before outputting response (default false)
136
+     */
137
+    var $bCleanBuffer;
138
+    /**
139
+     * @var string String containing the character encoding used
140
+     */
141
+    var $sEncoding;
142
+    /**
143
+     * @var boolean Decode input request args from UTF-8 (default false)
144
+     */
145
+    var $bDecodeUTF8Input;
146
+    /**
147
+     * @var boolean Convert special characters to HTML entities (default false)
148
+     */
149
+    var $bOutputEntities;
150
+    /**
151
+     * @var array Array for parsing complex objects
152
+     */
153
+    var $aObjArray;
154
+    /**
155
+     * @var integer Position in $aObjArray
156
+     */
157
+    var $iPos;
158
+
159
+    /**#@-*/
160
+
161
+    /**
162
+     * Constructor. You can set some extra xajax options right away or use
163
+     * individual methods later to set options.
164
+     *
165
+     * @param string  defaults to the current browser URI
166
+     * @param string  defaults to "xajax_";
167
+     * @param string  defaults to XAJAX_DEFAULT_CHAR_ENCODING defined above
168
+     * @param boolean defaults to false
169
+     */
170
+    public function __construct($sRequestURI="",$sWrapperPrefix="xajax_",$sEncoding=XAJAX_DEFAULT_CHAR_ENCODING,$bDebug=false)
171
+    {
172
+        $this->aFunctions = array();
173
+        $this->aObjects = array();
174
+        $this->aFunctionIncludeFiles = array();
175
+        $this->sRequestURI = $sRequestURI;
176
+        if ($this->sRequestURI == "")
177
+            $this->sRequestURI = $this->_detectURI();
178
+        $this->sWrapperPrefix = $sWrapperPrefix;
179
+        $this->bDebug = $bDebug;
180
+        $this->bStatusMessages = false;
181
+        $this->bWaitCursor = true;
182
+        $this->bExitAllowed = true;
183
+        $this->bErrorHandler = false;
184
+        $this->sLogFile = "";
185
+        $this->bCleanBuffer = false;
186
+        $this->setCharEncoding($sEncoding);
187
+        $this->bDecodeUTF8Input = false;
188
+        $this->bOutputEntities = false;
189
+    }
190
+
191
+    /**
192
+     * Sets the URI to which requests will be made.
193
+     * <i>Usage:</i> <kbd>$xajax->setRequestURI("http://www.xajaxproject.org");</kbd>
194
+     *
195
+     * @param string the URI (can be absolute or relative) of the PHP script
196
+     *               that will be accessed when an xajax request occurs
197
+     */
198
+    function setRequestURI($sRequestURI)
199
+    {
200
+        $this->sRequestURI = $sRequestURI;
201
+    }
202
+
203
+    /**
204
+     * Sets the prefix that will be appended to the Javascript wrapper
205
+     * functions (default is "xajax_").
206
+     *
207
+     * @param string
208
+     */
209
+    //
210
+    function setWrapperPrefix($sPrefix)
211
+    {
212
+        $this->sWrapperPrefix = $sPrefix;
213
+    }
214
+
215
+    /**
216
+     * Enables debug messages for xajax.
217
+     * */
218
+    function debugOn()
219
+    {
220
+        $this->bDebug = true;
221
+    }
222
+
223
+    /**
224
+     * Disables debug messages for xajax (default behavior).
225
+     */
226
+    function debugOff()
227
+    {
228
+        $this->bDebug = false;
229
+    }
230
+
231
+    /**
232
+     * Enables messages in the browser's status bar for xajax.
233
+     */
234
+    function statusMessagesOn()
235
+    {
236
+        $this->bStatusMessages = true;
237
+    }
238
+
239
+    /**
240
+     * Disables messages in the browser's status bar for xajax (default behavior).
241
+     */
242
+    function statusMessagesOff()
243
+    {
244
+        $this->bStatusMessages = false;
245
+    }
246
+
247
+    /**
248
+     * Enables the wait cursor to be displayed in the browser (default behavior).
249
+     */
250
+    function waitCursorOn()
251
+    {
252
+        $this->bWaitCursor = true;
253
+    }
254
+
255
+    /**
256
+     * Disables the wait cursor to be displayed in the browser.
257
+     */
258
+    function waitCursorOff()
259
+    {
260
+        $this->bWaitCursor = false;
261
+    }
262
+
263
+    /**
264
+     * Enables xajax to exit immediately after processing a request and
265
+     * sending the response back to the browser (default behavior).
266
+     */
267
+    function exitAllowedOn()
268
+    {
269
+        $this->bExitAllowed = true;
270
+    }
271
+
272
+    /**
273
+     * Disables xajax's default behavior of exiting immediately after
274
+     * processing a request and sending the response back to the browser.
275
+     */
276
+    function exitAllowedOff()
277
+    {
278
+        $this->bExitAllowed = false;
279
+    }
280
+
281
+    /**
282
+     * Turns on xajax's error handling system so that PHP errors that occur
283
+     * during a request are trapped and pushed to the browser in the form of
284
+     * a Javascript alert.
285
+     */
286
+    function errorHandlerOn()
287
+    {
288
+        $this->bErrorHandler = true;
289
+    }
290
+
291
+    /**
292
+     * Turns off xajax's error handling system (default behavior).
293
+     */
294
+    function errorHandlerOff()
295
+    {
296
+        $this->bErrorHandler = false;
297
+    }
298
+
299
+    /**
300
+     * Specifies a log file that will be written to by xajax during a request
301
+     * (used only by the error handling system at present). If you don't invoke
302
+     * this method, or you pass in "", then no log file will be written to.
303
+     * <i>Usage:</i> <kbd>$xajax->setLogFile("/xajax_logs/errors.log");</kbd>
304
+     */
305
+    function setLogFile($sFilename)
306
+    {
307
+        $this->sLogFile = $sFilename;
308
+    }
309
+
310
+    /**
311
+     * Causes xajax to clean out all output buffers before outputting a
312
+     * response (default behavior).
313
+     */
314
+    function cleanBufferOn()
315
+    {
316
+        $this->bCleanBuffer = true;
317
+    }
318
+    /**
319
+     * Turns off xajax's output buffer cleaning.
320
+     */
321
+    function cleanBufferOff()
322
+    {
323
+        $this->bCleanBuffer = false;
324
+    }
325
+
326
+    /**
327
+     * Sets the character encoding for the HTTP output based on
328
+     * <kbd>$sEncoding</kbd>, which is a string containing the character
329
+     * encoding to use. You don't need to use this method normally, since the
330
+     * character encoding for the response gets set automatically based on the
331
+     * <kbd>XAJAX_DEFAULT_CHAR_ENCODING</kbd> constant.
332
+     * <i>Usage:</i> <kbd>$xajax->setCharEncoding("utf-8");</kbd>
333
+     *
334
+     * @param string the encoding type to use (utf-8, iso-8859-1, etc.)
335
+     */
336
+    function setCharEncoding($sEncoding)
337
+    {
338
+        $this->sEncoding = $sEncoding;
339
+    }
340
+
341
+    /**
342
+     * Causes xajax to decode the input request args from UTF-8 to the current
343
+     * encoding if possible. Either the iconv or mb_string extension must be
344
+     * present for optimal functionality.
345
+     */
346
+    function decodeUTF8InputOn()
347
+    {
348
+        $this->bDecodeUTF8Input = true;
349
+    }
350
+
351
+    /**
352
+     * Turns off decoding the input request args from UTF-8 (default behavior).
353
+     */
354
+    function decodeUTF8InputOff()
355
+    {
356
+        $this->bDecodeUTF8Input = false;
357
+    }
358
+
359
+    /**
360
+     * Tells the response object to convert special characters to HTML entities
361
+     * automatically (only works if the mb_string extension is available).
362
+     */
363
+    function outputEntitiesOn()
364
+    {
365
+        $this->bOutputEntities = true;
366
+    }
367
+
368
+    /**
369
+     * Tells the response object to output special characters intact. (default
370
+     * behavior).
371
+     */
372
+    function outputEntitiesOff()
373
+    {
374
+        $this->bOutputEntities = false;
375
+    }
376
+
377
+    /**
378
+     * Registers a PHP function or method to be callable through xajax in your
379
+     * Javascript. If you want to register a function, pass in the name of that
380
+     * function. If you want to register a static class method, pass in an
381
+     * array like so:
382
+     * <kbd>array("myFunctionName", "myClass", "myMethod")</kbd>
383
+     * For an object instance method, use an object variable for the second
384
+     * array element (and in PHP 4 make sure you put an & before the variable
385
+     * to pass the object by reference). Note: the function name is what you
386
+     * call via Javascript, so it can be anything as long as it doesn't
387
+     * conflict with any other registered function name.
388
+     *
389
+     * <i>Usage:</i> <kbd>$xajax->registerFunction("myFunction");</kbd>
390
+     * or: <kbd>$xajax->registerFunction(array("myFunctionName", &$myObject, "myMethod"));</kbd>
391
+     *
392
+     * @param mixed  contains the function name or an object callback array
393
+     * @param mixed  request type (XAJAX_GET/XAJAX_POST) that should be used
394
+     *               for this function.  Defaults to XAJAX_POST.
395
+     */
396
+    function registerFunction($mFunction,$sRequestType=XAJAX_POST)
397
+    {
398
+        if (is_array($mFunction)) {
399
+            $this->aFunctions[$mFunction[0]] = 1;
400
+            $this->aFunctionRequestTypes[$mFunction[0]] = $sRequestType;
401
+            $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
402
+        }
403
+        else {
404
+            $this->aFunctions[$mFunction] = 1;
405
+            $this->aFunctionRequestTypes[$mFunction] = $sRequestType;
406
+        }
407
+    }
408
+
409
+    /**
410
+     * Registers a PHP function to be callable through xajax which is located
411
+     * in some other file.  If the function is requested the external file will
412
+     * be included to define the function before the function is called.
413
+     *
414
+     * <i>Usage:</i> <kbd>$xajax->registerExternalFunction("myFunction","myFunction.inc.php",XAJAX_POST);</kbd>
415
+     *
416
+     * @param string contains the function name or an object callback array
417
+     *               ({@link xajax::registerFunction() see registerFunction} for
418
+     *               more info on object callback arrays)
419
+     * @param string contains the path and filename of the include file
420
+     * @param mixed  the RequestType (XAJAX_GET/XAJAX_POST) that should be used
421
+     *		          for this function. Defaults to XAJAX_POST.
422
+     */
423
+    function registerExternalFunction($mFunction,$sIncludeFile,$sRequestType=XAJAX_POST)
424
+    {
425
+        $this->registerFunction($mFunction, $sRequestType);
426
+
427
+        if (is_array($mFunction)) {
428
+            $this->aFunctionIncludeFiles[$mFunction[0]] = $sIncludeFile;
429
+        }
430
+        else {
431
+            $this->aFunctionIncludeFiles[$mFunction] = $sIncludeFile;
432
+        }
433
+    }
434
+
435
+    /**
436
+     * Registers a PHP function to be called when xajax cannot find the
437
+     * function being called via Javascript. Because this is technically
438
+     * impossible when using "wrapped" functions, the catch-all feature is
439
+     * only useful when you're directly using the xajax.call() Javascript
440
+     * method. Use the catch-all feature when you want more dynamic ability to
441
+     * intercept unknown calls and handle them in a custom way.
442
+     *
443
+     * <i>Usage:</i> <kbd>$xajax->registerCatchAllFunction("myCatchAllFunction");</kbd>
444
+     *
445
+     * @param string contains the function name or an object callback array
446
+     *               ({@link xajax::registerFunction() see registerFunction} for
447
+     *               more info on object callback arrays)
448
+     */
449
+    function registerCatchAllFunction($mFunction)
450
+    {
451
+        if (is_array($mFunction)) {
452
+            $this->sCatchAllFunction = $mFunction[0];
453
+            $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
454
+        }
455
+        else {
456
+            $this->sCatchAllFunction = $mFunction;
457
+        }
458
+    }
459
+
460
+    /**
461
+     * Registers a PHP function to be called before xajax calls the requested
462
+     * function. xajax will automatically add the request function's response
463
+     * to the pre-function's response to create a single response. Another
464
+     * feature is the ability to return not just a response, but an array with
465
+     * the first element being false (a boolean) and the second being the
466
+     * response. In this case, the pre-function's response will be returned to
467
+     * the browser without xajax calling the requested function.
468
+     *
469
+     * <i>Usage:</i> <kbd>$xajax->registerPreFunction("myPreFunction");</kbd>
470
+     *
471
+     * @param string contains the function name or an object callback array
472
+     *               ({@link xajax::registerFunction() see registerFunction} for
473
+     *               more info on object callback arrays)
474
+     */
475
+    function registerPreFunction($mFunction)
476
+    {
477
+        if (is_array($mFunction)) {
478
+            $this->sPreFunction = $mFunction[0];
479
+            $this->aObjects[$mFunction[0]] = array_slice($mFunction, 1);
480
+        }
481
+        else {
482
+            $this->sPreFunction = $mFunction;
483
+        }
484
+    }
485
+
486
+    /**
487
+     * Returns true if xajax can process the request, false if otherwise.
488
+     * You can use this to determine if xajax needs to process the request or
489
+     * not.
490
+     *
491
+     * @return boolean
492
+     */
493
+    function canProcessRequests()
494
+    {
495
+        if ($this->getRequestMode() != -1) return true;
496
+        return false;
497
+    }
498
+
499
+    /**
500
+     * Returns the current request mode (XAJAX_GET or XAJAX_POST), or -1 if
501
+     * there is none.
502
+     *
503
+     * @return mixed
504
+     */
505
+    function getRequestMode()
506
+    {
507
+        if (!empty($_GET["xajax"]))
508
+            return XAJAX_GET;
509
+
510
+        if (!empty($_POST["xajax"]))
511
+            return XAJAX_POST;
512
+
513
+        return -1;
514
+    }
515
+
516
+    /**
517
+     * This is the main communications engine of xajax. The engine handles all
518
+     * incoming xajax requests, calls the apporiate PHP functions (or
519
+     * class/object methods) and passes the XML responses back to the
520
+     * Javascript response handler. If your RequestURI is the same as your Web
521
+     * page then this function should be called before any headers or HTML has
522
+     * been sent.
523
+     */
524
+    function processRequests()
525
+    {
526
+
527
+        $requestMode = -1;
528
+        $sFunctionName = "";
529
+        $bFoundFunction = true;
530
+        $bFunctionIsCatchAll = false;
531
+        $sFunctionNameForSpecial = "";
532
+        $aArgs = array();
533
+        $sPreResponse = "";
534
+        $bEndRequest = false;
535
+        $sResponse = "";
536
+
537
+        $requestMode = $this->getRequestMode();
538
+        if ($requestMode == -1) return;
539
+
540
+        if ($requestMode == XAJAX_POST)
541
+        {
542
+            $sFunctionName = $_POST["xajax"];
543
+
544
+            if (!empty($_POST["xajaxargs"]))
545
+                $aArgs = $_POST["xajaxargs"];
546
+        }
547
+        else
548
+        {
549
+            header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
550
+            header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
551
+            header ("Cache-Control: no-cache, must-revalidate");
552
+            header ("Pragma: no-cache");
553
+
554
+            $sFunctionName = $_GET["xajax"];
555
+
556
+            if (!empty($_GET["xajaxargs"]))
557
+                $aArgs = $_GET["xajaxargs"];
558
+        }
559
+
560
+        // Use xajax error handler if necessary
561
+        if ($this->bErrorHandler) {
562
+            $GLOBALS['xajaxErrorHandlerText'] = "";
563
+            set_error_handler("xajaxErrorHandler");
564
+        }
565
+
566
+        if ($this->sPreFunction) {
567
+            if (!$this->_isFunctionCallable($this->sPreFunction)) {
568
+                $bFoundFunction = false;
569
+                $objResponse = new xajaxResponse();
570
+                $objResponse->addAlert("Unknown Pre-Function ". $this->sPreFunction);
571
+                $sResponse = $objResponse->getXML();
572
+            }
573
+        }
574
+        //include any external dependencies associated with this function name
575
+        if (array_key_exists($sFunctionName,$this->aFunctionIncludeFiles))
576
+        {
577
+            ob_start();
578
+            include_once($this->aFunctionIncludeFiles[$sFunctionName]);
579
+            ob_end_clean();
580
+        }
581
+
582
+        if ($bFoundFunction) {
583
+            $sFunctionNameForSpecial = $sFunctionName;
584
+            if (!array_key_exists($sFunctionName, $this->aFunctions))
585
+            {
586
+                if ($this->sCatchAllFunction) {
587
+                    $sFunctionName = $this->sCatchAllFunction;
588
+                    $bFunctionIsCatchAll = true;
589
+                }
590
+                else {
591
+                    $bFoundFunction = false;
592
+                    $objResponse = new xajaxResponse();
593
+                    $objResponse->addAlert("Unknown Function $sFunctionName.");
594
+                    $sResponse = $objResponse->getXML();
595
+                }
596
+            }
597
+            else if ($this->aFunctionRequestTypes[$sFunctionName] != $requestMode)
598
+            {
599
+                $bFoundFunction = false;
600
+                $objResponse = new xajaxResponse();
601
+                $objResponse->addAlert("Incorrect Request Type.");
602
+                $sResponse = $objResponse->getXML();
603
+            }
604
+        }
605
+
606
+        if ($bFoundFunction)
607
+        {
608
+            for ($i = 0; $i < sizeof($aArgs); $i++)
609
+            {
610
+                // If magic quotes is on, then we need to strip the slashes from the args
611
+                if (get_magic_quotes_gpc() == 1 && is_string($aArgs[$i])) {
612
+
613
+                    $aArgs[$i] = stripslashes($aArgs[$i]);
614
+                }
615
+                if (stristr($aArgs[$i],"<xjxobj>") != false)
616
+                {
617
+                    $aArgs[$i] = $this->_xmlToArray("xjxobj",$aArgs[$i]);
618
+                }
619
+                else if (stristr($aArgs[$i],"<xjxquery>") != false)
620
+                {
621
+                    $aArgs[$i] = $this->_xmlToArray("xjxquery",$aArgs[$i]);
622
+                }
623
+                else if ($this->bDecodeUTF8Input)
624
+                {
625
+                    $aArgs[$i] = $this->_decodeUTF8Data($aArgs[$i]);
626
+                }
627
+            }
628
+
629
+            if ($this->sPreFunction) {
630
+                $mPreResponse = $this->_callFunction($this->sPreFunction, array($sFunctionNameForSpecial, $aArgs));
631
+                if (is_array($mPreResponse) && $mPreResponse[0] === false) {
632
+                    $bEndRequest = true;
633
+                    $sPreResponse = $mPreResponse[1];
634
+                }
635
+                else {
636
+                    $sPreResponse = $mPreResponse;
637
+                }
638
+                if (is_a($sPreResponse, "xajaxResponse")) {
639
+                    $sPreResponse = $sPreResponse->getXML();
640
+                }
641
+                if ($bEndRequest) $sResponse = $sPreResponse;
642
+            }
643
+
644
+            if (!$bEndRequest) {
645
+                if (!$this->_isFunctionCallable($sFunctionName)) {
646
+                    $objResponse = new xajaxResponse();
647
+                    $objResponse->addAlert("The Registered Function $sFunctionName Could Not Be Found.");
648
+                    $sResponse = $objResponse->getXML();
649
+                }
650
+                else {
651
+                    if ($bFunctionIsCatchAll) {
652
+                        $aArgs = array($sFunctionNameForSpecial, $aArgs);
653
+                    }
654
+                    $sResponse = $this->_callFunction($sFunctionName, $aArgs);
655
+                }
656
+                if (is_a($sResponse, "xajaxResponse")) {
657
+                    $sResponse = $sResponse->getXML();
658
+                }
659
+                if (!is_string($sResponse) || strpos($sResponse, "<xjx>") === FALSE) {
660
+                    $objResponse = new xajaxResponse();
661
+                    $objResponse->addAlert("No XML Response Was Returned By Function $sFunctionName.");
662
+                    $sResponse = $objResponse->getXML();
663
+                }
664
+                else if ($sPreResponse != "") {
665
+                    $sNewResponse = new xajaxResponse($this->sEncoding, $this->bOutputEntities);
666
+                    $sNewResponse->loadXML($sPreResponse);
667
+                    $sNewResponse->loadXML($sResponse);
668
+                    $sResponse = $sNewResponse->getXML();
669
+                }
670
+            }
671
+        }
672
+
673
+        $sContentHeader = "Content-type: text/xml;";
674
+        if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
675
+            $sContentHeader .= " charset=".$this->sEncoding;
676
+        header($sContentHeader);
677
+        if ($this->bErrorHandler && !empty( $GLOBALS['xajaxErrorHandlerText'] )) {
678
+            $sErrorResponse = new xajaxResponse();
679
+            $sErrorResponse->addAlert("** PHP Error Messages: **" . $GLOBALS['xajaxErrorHandlerText']);
680
+            if ($this->sLogFile) {
681
+                $fH = @fopen($this->sLogFile, "a");
682
+                if (!$fH) {
683
+                    $sErrorResponse->addAlert("** Logging Error **\n\nxajax was unable to write to the error log file:\n" . $this->sLogFile);
684
+                }
685
+                else {
686
+                    fwrite($fH, "** xajax Error Log - " . strftime("%b %e %Y %I:%M:%S %p") . " **" . $GLOBALS['xajaxErrorHandlerText'] . "\n\n\n");
687
+                    fclose($fH);
688
+                }
689
+            }
690
+
691
+            $sErrorResponse->loadXML($sResponse);
692
+            $sResponse = $sErrorResponse->getXML();
693
+
694
+        }
695
+        if ($this->bCleanBuffer) while (@ob_end_clean());
696
+        print $sResponse;
697
+        if ($this->bErrorHandler) restore_error_handler();
698
+
699
+        if ($this->bExitAllowed)
700
+            exit();
701
+    }
702
+
703
+    /**
704
+     * Prints the xajax Javascript header and wrapper code into your page by
705
+     * printing the output of the getJavascript() method. It should only be
706
+     * called between the <pre><head> </head></pre> tags in your HTML page.
707
+     * Remember, if you only want to obtain the result of this function, use
708
+     * {@link xajax::getJavascript()} instead.
709
+     *
710
+     * <i>Usage:</i>
711
+     * <code>
712
+     *  <head>
713
+     *		...
714
+     *		< ?php $xajax->printJavascript(); ? >
715
+     * </code>
716
+     *
717
+     * @param string the relative address of the folder where xajax has been
718
+     *               installed. For instance, if your PHP file is
719
+     *               "http://www.myserver.com/myfolder/mypage.php"
720
+     *               and xajax was installed in
721
+     *               "http://www.myserver.com/anotherfolder", then $sJsURI
722
+     *               should be set to "../anotherfolder". Defaults to assuming
723
+     *               xajax is in the same folder as your PHP file.
724
+     * @param string the relative folder/file pair of the xajax Javascript
725
+     *               engine located within the xajax installation folder.
726
+     *               Defaults to xajax_js/xajax.js.
727
+     */
728
+    function printJavascript($sJsURI="", $sJsFile=NULL)
729
+    {
730
+        print $this->getJavascript($sJsURI, $sJsFile);
731
+    }
732
+
733
+    /**
734
+     * Returns the xajax Javascript code that should be added to your HTML page
735
+     * between the <kbd><head> </head></kbd> tags.
736
+     *
737
+     * <i>Usage:</i>
738
+     * <code>
739
+     *  < ?php $xajaxJSHead = $xajax->getJavascript(); ? >
740
+     *	<head>
741
+     *		...
742
+     *		< ?php echo $xajaxJSHead; ? >
743
+     * </code>
744
+     *
745
+     * @param string the relative address of the folder where xajax has been
746
+     *               installed. For instance, if your PHP file is
747
+     *               "http://www.myserver.com/myfolder/mypage.php"
748
+     *               and xajax was installed in
749
+     *               "http://www.myserver.com/anotherfolder", then $sJsURI
750
+     *               should be set to "../anotherfolder". Defaults to assuming
751
+     *               xajax is in the same folder as your PHP file.
752
+     * @param string the relative folder/file pair of the xajax Javascript
753
+     *               engine located within the xajax installation folder.
754
+     *               Defaults to xajax_js/xajax.js.
755
+     * @return string
756
+     */
757
+    function getJavascript($sJsURI="", $sJsFile=NULL)
758
+    {
759
+        $html = $this->getJavascriptConfig();
760
+        $html .= $this->getJavascriptInclude($sJsURI, $sJsFile);
761
+
762
+        return $html;
763
+    }
764
+
765
+    /**
766
+     * Returns a string containing inline Javascript that sets up the xajax
767
+     * runtime (typically called internally by xajax from get/printJavascript).
768
+     *
769
+     * @return string
770
+     */
771
+    function getJavascriptConfig()
772
+    {
773
+        $html  = "\t<script type=\"text/javascript\">\n";
774
+        $html .= "var xajaxRequestUri=\"".$this->sRequestURI."\";\n";
775
+        $html .= "var xajaxDebug=".($this->bDebug?"true":"false").";\n";
776
+        $html .= "var xajaxStatusMessages=".($this->bStatusMessages?"true":"false").";\n";
777
+        $html .= "var xajaxWaitCursor=".($this->bWaitCursor?"true":"false").";\n";
778
+        $html .= "var xajaxDefinedGet=".XAJAX_GET.";\n";
779
+        $html .= "var xajaxDefinedPost=".XAJAX_POST.";\n";
780
+        $html .= "var xajaxLoaded=false;\n";
781
+
782
+        foreach($this->aFunctions as $sFunction => $bExists) {
783
+            $html .= $this->_wrap($sFunction,$this->aFunctionRequestTypes[$sFunction]);
784
+        }
785
+
786
+        $html .= "\t</script>\n";
787
+        return $html;
788
+    }
789
+
790
+    /**
791
+     * Returns a string containing a Javascript include of the xajax.js file
792
+     * along with a check to see if the file loaded after six seconds
793
+     * (typically called internally by xajax from get/printJavascript).
794
+     *
795
+     * @param string the relative address of the folder where xajax has been
796
+     *               installed. For instance, if your PHP file is
797
+     *               "http://www.myserver.com/myfolder/mypage.php"
798
+     *               and xajax was installed in
799
+     *               "http://www.myserver.com/anotherfolder", then $sJsURI
800
+     *               should be set to "../anotherfolder". Defaults to assuming
801
+     *               xajax is in the same folder as your PHP file.
802
+     * @param string the relative folder/file pair of the xajax Javascript
803
+     *               engine located within the xajax installation folder.
804
+     *               Defaults to xajax_js/xajax.js.
805
+     * @return string
806
+     */
807
+    function getJavascriptInclude($sJsURI="", $sJsFile=NULL)
808
+    {
809
+        if ($sJsFile == NULL) $sJsFile = "xajax_js/xajax.js";
810
+
811
+        if ($sJsURI != "" && substr($sJsURI, -1) != "/") $sJsURI .= "/";
812
+
813
+        $html = "\t<script type=\"text/javascript\" src=\"" . $sJsURI . $sJsFile . "\"></script>\n";
814
+        $html .= "\t<script type=\"text/javascript\">\n";
815
+        $html .= "window.setTimeout(function () { if (!xajaxLoaded) { alert('Error: the xajax Javascript file could not be included. Perhaps the URL is incorrect?\\nURL: {$sJsURI}{$sJsFile}'); } }, 6000);\n";
816
+        $html .= "\t</script>\n";
817
+        return $html;
818
+    }
819
+
820
+    /**
821
+     * This method can be used to create a new xajax.js file out of the
822
+     * xajax_uncompressed.js file (which will only happen if xajax.js doesn't
823
+     * already exist on the filesystem).
824
+     *
825
+     * @param string an optional argument containing the full server file path
826
+     *               of xajax.js.
827
+     */
828
+    function autoCompressJavascript($sJsFullFilename=NULL)
829
+    {
830
+        $sJsFile = "xajax_js/xajax.js";
831
+
832
+        if ($sJsFullFilename) {
833
+            $realJsFile = $sJsFullFilename;
834
+        }
835
+        else {
836
+            $realPath = realpath(dirname(__FILE__));
837
+            $realJsFile = $realPath . "/". $sJsFile;
838
+        }
839
+
840
+        // Create a compressed file if necessary
841
+        if (!file_exists($realJsFile)) {
842
+            $srcFile = str_replace(".js", "_uncompressed.js", $realJsFile);
843
+            if (!file_exists($srcFile)) {
844
+                trigger_error("The xajax uncompressed Javascript file could not be found in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
845
+            }
846
+            require(dirname(__FILE__)."/xajaxCompress.php");
847
+            $javaScript = implode('', file($srcFile));
848
+            $compressedScript = xajaxCompressJavascript($javaScript);
849
+            $fH = @fopen($realJsFile, "w");
850
+            if (!$fH) {
851
+                trigger_error("The xajax compressed javascript file could not be written in the <b>" . dirname($realJsFile) . "</b> folder. Error ", E_USER_ERROR);
852
+            }
853
+            else {
854
+                fwrite($fH, $compressedScript);
855
+                fclose($fH);
856
+            }
857
+        }
858
+    }
859
+
860
+    /**
861
+     * Returns the current URL based upon the SERVER vars.
862
+     *
863
+     * @access private
864
+     * @return string
865
+     */
866
+    function _detectURI() {
867
+        $aURL = array();
868
+
869
+        // Try to get the request URL
870
+        if (!empty($_SERVER['REQUEST_URI'])) {
871
+            $aURL = parse_url($_SERVER['REQUEST_URI']);
872
+        }
873
+
874
+        // Fill in the empty values
875
+        if (empty($aURL['scheme'])) {
876
+            if (!empty($_SERVER['HTTP_SCHEME'])) {
877
+                $aURL['scheme'] = $_SERVER['HTTP_SCHEME'];
878
+            } else {
879
+                $aURL['scheme'] = (!empty($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') ? 'https' : 'http';
880
+            }
881
+        }
882
+
883
+        if (empty($aURL['host'])) {
884
+            if (!empty($_SERVER['HTTP_HOST'])) {
885
+                if (strpos($_SERVER['HTTP_HOST'], ':') > 0) {
886
+                    list($aURL['host'], $aURL['port']) = explode(':', $_SERVER['HTTP_HOST']);
887
+                } else {
888
+                    $aURL['host'] = $_SERVER['HTTP_HOST'];
889
+                }
890
+            } else if (!empty($_SERVER['SERVER_NAME'])) {
891
+                $aURL['host'] = $_SERVER['SERVER_NAME'];
892
+            } else {
893
+                print "xajax Error: xajax failed to automatically identify your Request URI.";
894
+                print "Please set the Request URI explicitly when you instantiate the xajax object.";
895
+                exit();
896
+            }
897
+        }
898
+
899
+        if (empty($aURL['port']) && !empty($_SERVER['SERVER_PORT'])) {
900
+            $aURL['port'] = $_SERVER['SERVER_PORT'];
901
+        }
902
+
903
+        if (empty($aURL['path'])) {
904
+            if (!empty($_SERVER['PATH_INFO'])) {
905
+                $sPath = parse_url($_SERVER['PATH_INFO']);
906
+            } else {
907
+                $sPath = parse_url(api_get_self());
908
+            }
909
+            $aURL['path'] = $sPath['path'];
910
+            unset($sPath);
911
+        }
912
+
913
+        if (!empty($aURL['query'])) {
914
+            $aURL['query'] = '?'.$aURL['query'];
915
+        }
916
+
917
+        // Build the URL: Start with scheme, user and pass
918
+        $sURL = $aURL['scheme'].'://';
919
+        if (!empty($aURL['user'])) {
920
+            $sURL.= $aURL['user'];
921
+            if (!empty($aURL['pass'])) {
922
+                $sURL.= ':'.$aURL['pass'];
923
+            }
924
+            $sURL.= '@';
925
+        }
926
+
927
+        // Add the host
928
+        $sURL.= $aURL['host'];
929
+
930
+        // Add the port if needed
931
+        if (!empty($aURL['port']) && (($aURL['scheme'] == 'http' && $aURL['port'] != 80) || ($aURL['scheme'] == 'https' && $aURL['port'] != 443))) {
932
+            $sURL.= ':'.$aURL['port'];
933
+        }
934
+
935
+        // Add the path and the query string
936
+        $sURL.= $aURL['path'].@$aURL['query'];
937
+
938
+        // Clean up
939
+        unset($aURL);
940
+        return $sURL;
941
+    }
942
+
943
+    /**
944
+     * Returns true if the function name is associated with an object callback,
945
+     * false if not.
946
+     *
947
+     * @param string the name of the function
948
+     * @access private
949
+     * @return boolean
950
+     */
951
+    function _isObjectCallback($sFunction)
952
+    {
953
+        if (array_key_exists($sFunction, $this->aObjects)) return true;
954
+        return false;
955
+    }
956
+
957
+    /**
958
+     * Returns true if the function or object callback can be called, false if
959
+     * not.
960
+     *
961
+     * @param string the name of the function
962
+     * @access private
963
+     * @return boolean
964
+     */
965
+    function _isFunctionCallable($sFunction)
966
+    {
967
+        if ($this->_isObjectCallback($sFunction)) {
968
+            if (is_object($this->aObjects[$sFunction][0])) {
969
+                return method_exists($this->aObjects[$sFunction][0], $this->aObjects[$sFunction][1]);
970
+            }
971
+            else {
972
+                return is_callable($this->aObjects[$sFunction]);
973
+            }
974
+        }
975
+        else {
976
+            return function_exists($sFunction);
977
+        }
978
+    }
979
+
980
+    /**
981
+     * Calls the function, class method, or object method with the supplied
982
+     * arguments.
983
+     *
984
+     * @param string the name of the function
985
+     * @param array  arguments to pass to the function
986
+     * @access private
987
+     * @return mixed the output of the called function or method
988
+     */
989
+    function _callFunction($sFunction, $aArgs)
990
+    {
991
+        if ($this->_isObjectCallback($sFunction)) {
992
+            $mReturn = call_user_func_array($this->aObjects[$sFunction], $aArgs);
993
+        }
994
+        else {
995
+            $mReturn = call_user_func_array($sFunction, $aArgs);
996
+        }
997
+        return $mReturn;
998
+    }
999
+
1000
+    /**
1001
+     * Generates the Javascript wrapper for the specified PHP function.
1002
+     *
1003
+     * @param string the name of the function
1004
+     * @param mixed  the request type
1005
+     * @access private
1006
+     * @return string
1007
+     */
1008
+    function _wrap($sFunction,$sRequestType=XAJAX_POST)
1009
+    {
1010
+        $js = "function ".$this->sWrapperPrefix."$sFunction(){return xajax.call(\"$sFunction\", arguments, ".$sRequestType.");}\n";
1011
+        return $js;
1012
+    }
1013
+
1014
+    /**
1015
+     * Takes a string containing xajax xjxobj XML or xjxquery XML and builds an
1016
+     * array representation of it to pass as an argument to the PHP function
1017
+     * being called.
1018
+     *
1019
+     * @param string the root tag of the XML
1020
+     * @param string XML to convert
1021
+     * @access private
1022
+     * @return array
1023
+     */
1024
+    function _xmlToArray($rootTag, $sXml)
1025
+    {
1026
+        $aArray = array();
1027
+        $sXml = str_replace("<$rootTag>","<$rootTag>|~|",$sXml);
1028
+        $sXml = str_replace("</$rootTag>","</$rootTag>|~|",$sXml);
1029
+        $sXml = str_replace("<e>","<e>|~|",$sXml);
1030
+        $sXml = str_replace("</e>","</e>|~|",$sXml);
1031
+        $sXml = str_replace("<k>","<k>|~|",$sXml);
1032
+        $sXml = str_replace("</k>","|~|</k>|~|",$sXml);
1033
+        $sXml = str_replace("<v>","<v>|~|",$sXml);
1034
+        $sXml = str_replace("</v>","|~|</v>|~|",$sXml);
1035
+        $sXml = str_replace("<q>","<q>|~|",$sXml);
1036
+        $sXml = str_replace("</q>","|~|</q>|~|",$sXml);
1037
+
1038
+        $this->aObjArray = explode("|~|",$sXml);
1039
+
1040
+        $this->iPos = 0;
1041
+        $aArray = $this->_parseObjXml($rootTag);
1042
+
1043
+        return $aArray;
1044
+    }
1045
+
1046
+    /**
1047
+     * A recursive function that generates an array from the contents of
1048
+     * $this->aObjArray.
1049
+     *
1050
+     * @param string the root tag of the XML
1051
+     * @access private
1052
+     * @return array
1053
+     */
1054
+    function _parseObjXml($rootTag)
1055
+    {
1056
+        $aArray = array();
1057
+
1058
+        if ($rootTag == "xjxobj")
1059
+        {
1060
+            while(!stristr($this->aObjArray[$this->iPos],"</xjxobj>"))
1061
+            {
1062
+                $this->iPos++;
1063
+                if(stristr($this->aObjArray[$this->iPos],"<e>"))
1064
+                {
1065
+                    $key = "";
1066
+                    $value = null;
1067
+
1068
+                    $this->iPos++;
1069
+                    while(!stristr($this->aObjArray[$this->iPos],"</e>"))
1070
+                    {
1071
+                        if(stristr($this->aObjArray[$this->iPos],"<k>"))
1072
+                        {
1073
+                            $this->iPos++;
1074
+                            while(!stristr($this->aObjArray[$this->iPos],"</k>"))
1075
+                            {
1076
+                                $key .= $this->aObjArray[$this->iPos];
1077
+                                $this->iPos++;
1078
+                            }
1079
+                        }
1080
+                        if(stristr($this->aObjArray[$this->iPos],"<v>"))
1081
+                        {
1082
+                            $this->iPos++;
1083
+                            while(!stristr($this->aObjArray[$this->iPos],"</v>"))
1084
+                            {
1085
+                                if(stristr($this->aObjArray[$this->iPos],"<xjxobj>"))
1086
+                                {
1087
+                                    $value = $this->_parseObjXml("xjxobj");
1088
+                                    $this->iPos++;
1089
+                                }
1090
+                                else
1091
+                                {
1092
+                                    $value .= $this->aObjArray[$this->iPos];
1093
+                                    if ($this->bDecodeUTF8Input)
1094
+                                    {
1095
+                                        $value = $this->_decodeUTF8Data($value);
1096
+                                    }
1097
+                                }
1098
+                                $this->iPos++;
1099
+                            }
1100
+                        }
1101
+                        $this->iPos++;
1102
+                    }
1103
+
1104
+                    $aArray[$key]=$value;
1105
+                }
1106
+            }
1107
+        }
1108
+
1109
+        if ($rootTag == "xjxquery")
1110
+        {
1111
+            $sQuery = "";
1112
+            $this->iPos++;
1113
+            while(!stristr($this->aObjArray[$this->iPos],"</xjxquery>"))
1114
+            {
1115
+                if (stristr($this->aObjArray[$this->iPos],"<q>") || stristr($this->aObjArray[$this->iPos],"</q>"))
1116
+                {
1117
+                    $this->iPos++;
1118
+                    continue;
1119
+                }
1120
+                $sQuery	.= $this->aObjArray[$this->iPos];
1121
+                $this->iPos++;
1122
+            }
1123
+
1124
+            parse_str($sQuery, $aArray);
1125
+            if ($this->bDecodeUTF8Input)
1126
+            {
1127
+                foreach($aArray as $key => $value)
1128
+                {
1129
+                    $aArray[$key] = $this->_decodeUTF8Data($value);
1130
+                }
1131
+            }
1132
+            // If magic quotes is on, then we need to strip the slashes from the
1133
+            // array values because of the parse_str pass which adds slashes
1134
+            if (get_magic_quotes_gpc() == 1) {
1135
+                $newArray = array();
1136
+                foreach ($aArray as $sKey => $sValue) {
1137
+                    if (is_string($sValue))
1138
+                        $newArray[$sKey] = stripslashes($sValue);
1139
+                    else
1140
+                        $newArray[$sKey] = $sValue;
1141
+                }
1142
+                $aArray = $newArray;
1143
+            }
1144
+        }
1145
+
1146
+        return $aArray;
1147
+    }
1148
+
1149
+    /**
1150
+     * Decodes string data from UTF-8 to the current xajax encoding.
1151
+     *
1152
+     * @param string data to convert
1153
+     * @access private
1154
+     * @return string converted data
1155
+     */
1156
+    function _decodeUTF8Data($sData)
1157
+    {
1158
+        $sValue = $sData;
1159
+        if ($this->bDecodeUTF8Input)
1160
+        {
1161
+            $sFuncToUse = NULL;
1162
+
1163
+            // An adaptation for the Dokeos LMS, 22-AUG-2009.
1164
+            if (function_exists('api_convert_encoding'))
1165
+            {
1166
+                $sFuncToUse = "api_convert_encoding";
1167
+            }
1168
+            //if (function_exists('iconv'))
1169
+            elseif (function_exists('iconv'))
1170
+            //
1171
+            {
1172
+                $sFuncToUse = "iconv";
1173
+            }
1174
+            else if (function_exists('mb_convert_encoding'))
1175
+            {
1176
+                $sFuncToUse = "mb_convert_encoding";
1177
+            }
1178
+            else if ($this->sEncoding == "ISO-8859-1")
1179
+            {
1180
+                $sFuncToUse = "utf8_decode";
1181
+            }
1182
+            else
1183
+            {
1184
+                trigger_error("The incoming xajax data could not be converted from UTF-8", E_USER_NOTICE);
1185
+            }
1186
+
1187
+            if ($sFuncToUse)
1188
+            {
1189
+                if (is_string($sValue))
1190
+                {
1191
+                    if ($sFuncToUse == "iconv")
1192
+                    {
1193
+                        $sValue = iconv("UTF-8", $this->sEncoding.'//TRANSLIT', $sValue);
1194
+                    }
1195
+                    else if ($sFuncToUse == "mb_convert_encoding")
1196
+                    {
1197
+                        $sValue = mb_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1198
+                    }
1199
+                    // Added code, an adaptation for the Dokeos LMS, 22-AUG-2009.
1200
+                    else if ($sFuncToUse == "api_convert_encoding")
1201
+                    {
1202
+                        $sValue = api_convert_encoding($sValue, $this->sEncoding, "UTF-8");
1203
+                    }
1204
+                    //
1205
+                    else
1206
+                    {
1207
+                        $sValue = utf8_decode($sValue);
1208
+                    }
1209
+                }
1210
+            }
1211
+        }
1212
+        return $sValue;
1213
+    }
1214 1214
 
1215 1215
 }// end class xajax
1216 1216
 
@@ -1220,31 +1220,31 @@  discard block
 block discarded – undo
1220 1220
  */
1221 1221
 function xajaxErrorHandler($errno, $errstr, $errfile, $errline)
1222 1222
 {
1223
-	$errorReporting = error_reporting();
1224
-	if (($errno & $errorReporting) == 0) return;
1225
-
1226
-	if ($errno == E_NOTICE) {
1227
-		$errTypeStr = "NOTICE";
1228
-	}
1229
-	else if ($errno == E_WARNING) {
1230
-		$errTypeStr = "WARNING";
1231
-	}
1232
-	else if ($errno == E_USER_NOTICE) {
1233
-		$errTypeStr = "USER NOTICE";
1234
-	}
1235
-	else if ($errno == E_USER_WARNING) {
1236
-		$errTypeStr = "USER WARNING";
1237
-	}
1238
-	else if ($errno == E_USER_ERROR) {
1239
-		$errTypeStr = "USER FATAL ERROR";
1240
-	}
1241
-	else if ($errno == E_STRICT) {
1242
-		return;
1243
-	}
1244
-	else {
1245
-		$errTypeStr = "UNKNOWN: $errno";
1246
-	}
1247
-	$GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile";
1223
+    $errorReporting = error_reporting();
1224
+    if (($errno & $errorReporting) == 0) return;
1225
+
1226
+    if ($errno == E_NOTICE) {
1227
+        $errTypeStr = "NOTICE";
1228
+    }
1229
+    else if ($errno == E_WARNING) {
1230
+        $errTypeStr = "WARNING";
1231
+    }
1232
+    else if ($errno == E_USER_NOTICE) {
1233
+        $errTypeStr = "USER NOTICE";
1234
+    }
1235
+    else if ($errno == E_USER_WARNING) {
1236
+        $errTypeStr = "USER WARNING";
1237
+    }
1238
+    else if ($errno == E_USER_ERROR) {
1239
+        $errTypeStr = "USER FATAL ERROR";
1240
+    }
1241
+    else if ($errno == E_STRICT) {
1242
+        return;
1243
+    }
1244
+    else {
1245
+        $errTypeStr = "UNKNOWN: $errno";
1246
+    }
1247
+    $GLOBALS['xajaxErrorHandlerText'] .= "\n----\n[$errTypeStr] $errstr\nerror in line $errline of file $errfile";
1248 1248
 }
1249 1249
 
1250 1250
 ?>
Please login to merge, or discard this patch.
main/inc/lib/xajax/xajaxCompress.php 4 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -39,6 +39,7 @@
 block discarded – undo
39 39
  * (used internally)
40 40
  *
41 41
  * @param string contains the Javascript code to compress
42
+ * @param string $sJS
42 43
  */
43 44
 function xajaxCompressJavascript($sJS)
44 45
 {
Please login to merge, or discard this patch.
Indentation   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -42,141 +42,141 @@
 block discarded – undo
42 42
  */
43 43
 function xajaxCompressJavascript($sJS)
44 44
 {
45
-	//remove windows cariage returns
46
-	$sJS = str_replace("\r","",$sJS);
47
-
48
-	//array to store replaced literal strings
49
-	$literal_strings = array();
50
-
51
-	//explode the string into lines
52
-	$lines = explode("\n",$sJS);
53
-	//loop through all the lines, building a new string at the same time as removing literal strings
54
-	$clean = "";
55
-	$inComment = false;
56
-	$literal = "";
57
-	$inQuote = false;
58
-	$escaped = false;
59
-	$quoteChar = "";
60
-
61
-	for($i=0;$i<count($lines);$i++)
62
-	{
63
-		$line = $lines[$i];
64
-		$inNormalComment = false;
65
-
66
-		//loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string
67
-		for($j=0;$j<strlen($line);$j++)
68
-		{
69
-			$c = substr($line,$j,1);
70
-			$d = substr($line,$j,2);
71
-
72
-			//look for start of quote
73
-			if(!$inQuote && !$inComment)
74
-			{
75
-				//is this character a quote or a comment
76
-				if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment)
77
-				{
78
-					$inQuote = true;
79
-					$inComment = false;
80
-					$escaped = false;
81
-					$quoteChar = $c;
82
-					$literal = $c;
83
-				}
84
-				else if($d=="/*" && !$inNormalComment)
85
-				{
86
-					$inQuote = false;
87
-					$inComment = true;
88
-					$escaped = false;
89
-					$quoteChar = $d;
90
-					$literal = $d;
91
-					$j++;
92
-				}
93
-				else if($d=="//") //ignore string markers that are found inside comments
94
-				{
95
-					$inNormalComment = true;
96
-					$clean .= $c;
97
-				}
98
-				else
99
-				{
100
-					$clean .= $c;
101
-				}
102
-			}
103
-			else //allready in a string so find end quote
104
-			{
105
-				if($c == $quoteChar && !$escaped && !$inComment)
106
-				{
107
-					$inQuote = false;
108
-					$literal .= $c;
109
-
110
-					//subsitute in a marker for the string
111
-					$clean .= "___" . count($literal_strings) . "___";
112
-
113
-					//push the string onto our array
114
-					array_push($literal_strings,$literal);
115
-
116
-				}
117
-				else if($inComment && $d=="*/")
118
-				{
119
-					$inComment = false;
120
-					$literal .= $d;
121
-
122
-					//subsitute in a marker for the string
123
-					$clean .= "___" . count($literal_strings) . "___";
124
-
125
-					//push the string onto our array
126
-					array_push($literal_strings,$literal);
127
-
128
-					$j++;
129
-				}
130
-				else if($c == "\\" && !$escaped)
131
-					$escaped = true;
132
-				else
133
-					$escaped = false;
134
-
135
-				$literal .= $c;
136
-			}
137
-		}
138
-		if($inComment) $literal .= "\n";
139
-		$clean .= "\n";
140
-	}
141
-	//explode the clean string into lines again
142
-	$lines = explode("\n",$clean);
143
-
144
-	//now process each line at a time
145
-	for($i=0;$i<count($lines);$i++)
146
-	{
147
-		$line = $lines[$i];
148
-
149
-		//remove comments
150
-		$line = preg_replace("/\/\/(.*)/","",$line);
151
-
152
-		//strip leading and trailing whitespace
153
-		$line = trim($line);
154
-
155
-		//remove all whitespace with a single space
156
-		$line = preg_replace("/\s+/"," ",$line);
157
-
158
-		//remove any whitespace that occurs after/before an operator
159
-		$line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line);
160
-
161
-		$lines[$i] = $line;
162
-	}
163
-
164
-	//implode the lines
165
-	$sJS = implode("\n",$lines);
166
-
167
-	//make sure there is a max of 1 \n after each line
168
-	$sJS = preg_replace("/[\n]+/","\n",$sJS);
169
-
170
-	//strip out line breaks that immediately follow a semi-colon
171
-	$sJS = preg_replace("/;\n/",";",$sJS);
172
-
173
-	//curly brackets aren't on their own
174
-	$sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS);
175
-
176
-	//finally loop through and replace all the literal strings:
177
-	for($i=0;$i<count($literal_strings);$i++)
178
-		$sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
179
-
180
-	return $sJS;
45
+    //remove windows cariage returns
46
+    $sJS = str_replace("\r","",$sJS);
47
+
48
+    //array to store replaced literal strings
49
+    $literal_strings = array();
50
+
51
+    //explode the string into lines
52
+    $lines = explode("\n",$sJS);
53
+    //loop through all the lines, building a new string at the same time as removing literal strings
54
+    $clean = "";
55
+    $inComment = false;
56
+    $literal = "";
57
+    $inQuote = false;
58
+    $escaped = false;
59
+    $quoteChar = "";
60
+
61
+    for($i=0;$i<count($lines);$i++)
62
+    {
63
+        $line = $lines[$i];
64
+        $inNormalComment = false;
65
+
66
+        //loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string
67
+        for($j=0;$j<strlen($line);$j++)
68
+        {
69
+            $c = substr($line,$j,1);
70
+            $d = substr($line,$j,2);
71
+
72
+            //look for start of quote
73
+            if(!$inQuote && !$inComment)
74
+            {
75
+                //is this character a quote or a comment
76
+                if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment)
77
+                {
78
+                    $inQuote = true;
79
+                    $inComment = false;
80
+                    $escaped = false;
81
+                    $quoteChar = $c;
82
+                    $literal = $c;
83
+                }
84
+                else if($d=="/*" && !$inNormalComment)
85
+                {
86
+                    $inQuote = false;
87
+                    $inComment = true;
88
+                    $escaped = false;
89
+                    $quoteChar = $d;
90
+                    $literal = $d;
91
+                    $j++;
92
+                }
93
+                else if($d=="//") //ignore string markers that are found inside comments
94
+                {
95
+                    $inNormalComment = true;
96
+                    $clean .= $c;
97
+                }
98
+                else
99
+                {
100
+                    $clean .= $c;
101
+                }
102
+            }
103
+            else //allready in a string so find end quote
104
+            {
105
+                if($c == $quoteChar && !$escaped && !$inComment)
106
+                {
107
+                    $inQuote = false;
108
+                    $literal .= $c;
109
+
110
+                    //subsitute in a marker for the string
111
+                    $clean .= "___" . count($literal_strings) . "___";
112
+
113
+                    //push the string onto our array
114
+                    array_push($literal_strings,$literal);
115
+
116
+                }
117
+                else if($inComment && $d=="*/")
118
+                {
119
+                    $inComment = false;
120
+                    $literal .= $d;
121
+
122
+                    //subsitute in a marker for the string
123
+                    $clean .= "___" . count($literal_strings) . "___";
124
+
125
+                    //push the string onto our array
126
+                    array_push($literal_strings,$literal);
127
+
128
+                    $j++;
129
+                }
130
+                else if($c == "\\" && !$escaped)
131
+                    $escaped = true;
132
+                else
133
+                    $escaped = false;
134
+
135
+                $literal .= $c;
136
+            }
137
+        }
138
+        if($inComment) $literal .= "\n";
139
+        $clean .= "\n";
140
+    }
141
+    //explode the clean string into lines again
142
+    $lines = explode("\n",$clean);
143
+
144
+    //now process each line at a time
145
+    for($i=0;$i<count($lines);$i++)
146
+    {
147
+        $line = $lines[$i];
148
+
149
+        //remove comments
150
+        $line = preg_replace("/\/\/(.*)/","",$line);
151
+
152
+        //strip leading and trailing whitespace
153
+        $line = trim($line);
154
+
155
+        //remove all whitespace with a single space
156
+        $line = preg_replace("/\s+/"," ",$line);
157
+
158
+        //remove any whitespace that occurs after/before an operator
159
+        $line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line);
160
+
161
+        $lines[$i] = $line;
162
+    }
163
+
164
+    //implode the lines
165
+    $sJS = implode("\n",$lines);
166
+
167
+    //make sure there is a max of 1 \n after each line
168
+    $sJS = preg_replace("/[\n]+/","\n",$sJS);
169
+
170
+    //strip out line breaks that immediately follow a semi-colon
171
+    $sJS = preg_replace("/;\n/",";",$sJS);
172
+
173
+    //curly brackets aren't on their own
174
+    $sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS);
175
+
176
+    //finally loop through and replace all the literal strings:
177
+    for($i=0;$i<count($literal_strings);$i++)
178
+        $sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
179
+
180
+    return $sJS;
181 181
 }
182 182
 ?>
Please login to merge, or discard this patch.
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
 function xajaxCompressJavascript($sJS)
44 44
 {
45 45
 	//remove windows cariage returns
46
-	$sJS = str_replace("\r","",$sJS);
46
+	$sJS = str_replace("\r", "", $sJS);
47 47
 
48 48
 	//array to store replaced literal strings
49 49
 	$literal_strings = array();
50 50
 
51 51
 	//explode the string into lines
52
-	$lines = explode("\n",$sJS);
52
+	$lines = explode("\n", $sJS);
53 53
 	//loop through all the lines, building a new string at the same time as removing literal strings
54 54
 	$clean = "";
55 55
 	$inComment = false;
@@ -58,22 +58,22 @@  discard block
 block discarded – undo
58 58
 	$escaped = false;
59 59
 	$quoteChar = "";
60 60
 
61
-	for($i=0;$i<count($lines);$i++)
61
+	for ($i = 0; $i < count($lines); $i++)
62 62
 	{
63 63
 		$line = $lines[$i];
64 64
 		$inNormalComment = false;
65 65
 
66 66
 		//loop through line's characters and take out any literal strings, replace them with ___i___ where i is the index of this string
67
-		for($j=0;$j<strlen($line);$j++)
67
+		for ($j = 0; $j < strlen($line); $j++)
68 68
 		{
69
-			$c = substr($line,$j,1);
70
-			$d = substr($line,$j,2);
69
+			$c = substr($line, $j, 1);
70
+			$d = substr($line, $j, 2);
71 71
 
72 72
 			//look for start of quote
73
-			if(!$inQuote && !$inComment)
73
+			if (!$inQuote && !$inComment)
74 74
 			{
75 75
 				//is this character a quote or a comment
76
-				if(($c=="\"" || $c=="'") && !$inComment && !$inNormalComment)
76
+				if (($c == "\"" || $c == "'") && !$inComment && !$inNormalComment)
77 77
 				{
78 78
 					$inQuote = true;
79 79
 					$inComment = false;
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 					$quoteChar = $c;
82 82
 					$literal = $c;
83 83
 				}
84
-				else if($d=="/*" && !$inNormalComment)
84
+				else if ($d == "/*" && !$inNormalComment)
85 85
 				{
86 86
 					$inQuote = false;
87 87
 					$inComment = true;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 					$literal = $d;
91 91
 					$j++;
92 92
 				}
93
-				else if($d=="//") //ignore string markers that are found inside comments
93
+				else if ($d == "//") //ignore string markers that are found inside comments
94 94
 				{
95 95
 					$inNormalComment = true;
96 96
 					$clean .= $c;
@@ -102,32 +102,32 @@  discard block
 block discarded – undo
102 102
 			}
103 103
 			else //allready in a string so find end quote
104 104
 			{
105
-				if($c == $quoteChar && !$escaped && !$inComment)
105
+				if ($c == $quoteChar && !$escaped && !$inComment)
106 106
 				{
107 107
 					$inQuote = false;
108 108
 					$literal .= $c;
109 109
 
110 110
 					//subsitute in a marker for the string
111
-					$clean .= "___" . count($literal_strings) . "___";
111
+					$clean .= "___".count($literal_strings)."___";
112 112
 
113 113
 					//push the string onto our array
114
-					array_push($literal_strings,$literal);
114
+					array_push($literal_strings, $literal);
115 115
 
116 116
 				}
117
-				else if($inComment && $d=="*/")
117
+				else if ($inComment && $d == "*/")
118 118
 				{
119 119
 					$inComment = false;
120 120
 					$literal .= $d;
121 121
 
122 122
 					//subsitute in a marker for the string
123
-					$clean .= "___" . count($literal_strings) . "___";
123
+					$clean .= "___".count($literal_strings)."___";
124 124
 
125 125
 					//push the string onto our array
126
-					array_push($literal_strings,$literal);
126
+					array_push($literal_strings, $literal);
127 127
 
128 128
 					$j++;
129 129
 				}
130
-				else if($c == "\\" && !$escaped)
130
+				else if ($c == "\\" && !$escaped)
131 131
 					$escaped = true;
132 132
 				else
133 133
 					$escaped = false;
@@ -135,47 +135,47 @@  discard block
 block discarded – undo
135 135
 				$literal .= $c;
136 136
 			}
137 137
 		}
138
-		if($inComment) $literal .= "\n";
138
+		if ($inComment) $literal .= "\n";
139 139
 		$clean .= "\n";
140 140
 	}
141 141
 	//explode the clean string into lines again
142
-	$lines = explode("\n",$clean);
142
+	$lines = explode("\n", $clean);
143 143
 
144 144
 	//now process each line at a time
145
-	for($i=0;$i<count($lines);$i++)
145
+	for ($i = 0; $i < count($lines); $i++)
146 146
 	{
147 147
 		$line = $lines[$i];
148 148
 
149 149
 		//remove comments
150
-		$line = preg_replace("/\/\/(.*)/","",$line);
150
+		$line = preg_replace("/\/\/(.*)/", "", $line);
151 151
 
152 152
 		//strip leading and trailing whitespace
153 153
 		$line = trim($line);
154 154
 
155 155
 		//remove all whitespace with a single space
156
-		$line = preg_replace("/\s+/"," ",$line);
156
+		$line = preg_replace("/\s+/", " ", $line);
157 157
 
158 158
 		//remove any whitespace that occurs after/before an operator
159
-		$line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/","\\1",$line);
159
+		$line = preg_replace("/\s*([!\}\{;,&=\|\-\+\*\/\)\(:])\s*/", "\\1", $line);
160 160
 
161 161
 		$lines[$i] = $line;
162 162
 	}
163 163
 
164 164
 	//implode the lines
165
-	$sJS = implode("\n",$lines);
165
+	$sJS = implode("\n", $lines);
166 166
 
167 167
 	//make sure there is a max of 1 \n after each line
168
-	$sJS = preg_replace("/[\n]+/","\n",$sJS);
168
+	$sJS = preg_replace("/[\n]+/", "\n", $sJS);
169 169
 
170 170
 	//strip out line breaks that immediately follow a semi-colon
171
-	$sJS = preg_replace("/;\n/",";",$sJS);
171
+	$sJS = preg_replace("/;\n/", ";", $sJS);
172 172
 
173 173
 	//curly brackets aren't on their own
174
-	$sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS);
174
+	$sJS = preg_replace("/[\n]*\{[\n]*/", "{", $sJS);
175 175
 
176 176
 	//finally loop through and replace all the literal strings:
177
-	for($i=0;$i<count($literal_strings);$i++)
178
-		$sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
177
+	for ($i = 0; $i < count($literal_strings); $i++)
178
+		$sJS = str_replace("___".$i."___", $literal_strings[$i], $sJS);
179 179
 
180 180
 	return $sJS;
181 181
 }
Please login to merge, or discard this patch.
Braces   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -80,8 +80,7 @@  discard block
 block discarded – undo
80 80
 					$escaped = false;
81 81
 					$quoteChar = $c;
82 82
 					$literal = $c;
83
-				}
84
-				else if($d=="/*" && !$inNormalComment)
83
+				} else if($d=="/*" && !$inNormalComment)
85 84
 				{
86 85
 					$inQuote = false;
87 86
 					$inComment = true;
@@ -89,18 +88,17 @@  discard block
 block discarded – undo
89 88
 					$quoteChar = $d;
90 89
 					$literal = $d;
91 90
 					$j++;
92
-				}
93
-				else if($d=="//") //ignore string markers that are found inside comments
91
+				} else if($d=="//") {
92
+				    //ignore string markers that are found inside comments
94 93
 				{
95 94
 					$inNormalComment = true;
96
-					$clean .= $c;
97 95
 				}
98
-				else
96
+					$clean .= $c;
97
+				} else
99 98
 				{
100 99
 					$clean .= $c;
101 100
 				}
102
-			}
103
-			else //allready in a string so find end quote
101
+			} else //allready in a string so find end quote
104 102
 			{
105 103
 				if($c == $quoteChar && !$escaped && !$inComment)
106 104
 				{
@@ -113,8 +111,7 @@  discard block
 block discarded – undo
113 111
 					//push the string onto our array
114 112
 					array_push($literal_strings,$literal);
115 113
 
116
-				}
117
-				else if($inComment && $d=="*/")
114
+				} else if($inComment && $d=="*/")
118 115
 				{
119 116
 					$inComment = false;
120 117
 					$literal .= $d;
@@ -126,16 +123,18 @@  discard block
 block discarded – undo
126 123
 					array_push($literal_strings,$literal);
127 124
 
128 125
 					$j++;
126
+				} else if($c == "\\" && !$escaped) {
127
+									$escaped = true;
128
+				} else {
129
+									$escaped = false;
129 130
 				}
130
-				else if($c == "\\" && !$escaped)
131
-					$escaped = true;
132
-				else
133
-					$escaped = false;
134 131
 
135 132
 				$literal .= $c;
136 133
 			}
137 134
 		}
138
-		if($inComment) $literal .= "\n";
135
+		if($inComment) {
136
+		    $literal .= "\n";
137
+		}
139 138
 		$clean .= "\n";
140 139
 	}
141 140
 	//explode the clean string into lines again
@@ -174,8 +173,9 @@  discard block
 block discarded – undo
174 173
 	$sJS = preg_replace("/[\n]*\{[\n]*/","{",$sJS);
175 174
 
176 175
 	//finally loop through and replace all the literal strings:
177
-	for($i=0;$i<count($literal_strings);$i++)
178
-		$sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
176
+	for($i=0;$i<count($literal_strings);$i++) {
177
+			$sJS = str_replace("___".$i."___",$literal_strings[$i],$sJS);
178
+	}
179 179
 
180 180
 	return $sJS;
181 181
 }
Please login to merge, or discard this patch.
main/inc/lib/xajax/xajaxResponse.inc.php 4 patches
Doc Comments   +4 added lines, -2 removed lines patch added patch discarded remove patch
@@ -97,6 +97,7 @@  discard block
 block discarded – undo
97 97
 	 * @param string  contains the character encoding string to use
98 98
 	 * @param boolean lets you set if you want special characters in the output
99 99
 	 *                converted to HTML entities
100
+	 * @param string $sEncoding
100 101
 	 *
101 102
 	 */
102 103
 	function xajaxResponse($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false)
@@ -223,6 +224,8 @@  discard block
 block discarded – undo
223 224
 	 * @param string contains the id of an HTML element
224 225
 	 * @param string the part of the element you wish to clear ("innerHTML",
225 226
 	 *               "value", etc.)
227
+	 * @param string $sTarget
228
+	 * @param string $sAttribute
226 229
 	 */
227 230
 	function addClear($sTarget,$sAttribute)
228 231
 	{
@@ -279,6 +282,7 @@  discard block
 block discarded – undo
279 282
 	 * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd>
280 283
 	 *
281 284
 	 * @param string contains Javascript code to be executed
285
+	 * @param string $sJS
282 286
 	 */
283 287
 	function addScript($sJS)
284 288
 	{
@@ -290,8 +294,6 @@  discard block
 block discarded – undo
290 294
 	 *
291 295
 	 * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd>
292 296
 	 *
293
-	 * @param string $sFunc the name of a Javascript function
294
-	 * @param mixed $args,... optional arguments to pass to the Javascript function
295 297
 	 */
296 298
 	function addScriptCall() {
297 299
 		$arguments = func_get_args();
Please login to merge, or discard this patch.
Braces   +21 added lines, -17 removed lines patch added patch discarded remove patch
@@ -258,8 +258,9 @@  discard block
 block discarded – undo
258 258
 		{
259 259
 			$queryStart++;
260 260
 			$queryEnd = strpos($sURL, '#', $queryStart);
261
-			if ($queryEnd === FALSE)
262
-				$queryEnd = strlen($sURL);
261
+			if ($queryEnd === FALSE) {
262
+							$queryEnd = strlen($sURL);
263
+			}
263 264
 			$queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
264 265
             $queryParts = array();
265 266
 			parse_str($queryPart, $queryParts);
@@ -487,8 +488,9 @@  discard block
 block discarded – undo
487 488
 	function getXML()
488 489
 	{
489 490
 		$sXML = "<?xml version=\"1.0\"";
490
-		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
491
-			$sXML .= " encoding=\"".$this->sEncoding."\"";
491
+		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0) {
492
+					$sXML .= " encoding=\"".$this->sEncoding."\"";
493
+		}
492 494
 		$sXML .= " ?"."><xjx>" . $this->xml . "</xjx>";
493 495
 
494 496
 		return $sXML;
@@ -538,20 +540,21 @@  discard block
 block discarded – undo
538 540
 			elseif (function_exists('mb_convert_encoding')) {
539 541
 			//
540 542
 				$sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
541
-			}
542
-			else {
543
+			} else {
543 544
 				trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE);
544 545
 			}
545 546
 		}
546 547
 		$xml = "<cmd";
547
-		foreach($aAttributes as $sAttribute => $sValue)
548
-			$xml .= " $sAttribute=\"$sValue\"";
549
-		if ($sData !== null && !stristr($sData,'<![CDATA['))
550
-			$xml .= "><![CDATA[$sData]]></cmd>";
551
-		else if ($sData !== null)
552
-			$xml .= ">$sData</cmd>";
553
-		else
554
-			$xml .= "></cmd>";
548
+		foreach($aAttributes as $sAttribute => $sValue) {
549
+					$xml .= " $sAttribute=\"$sValue\"";
550
+		}
551
+		if ($sData !== null && !stristr($sData,'<![CDATA[')) {
552
+					$xml .= "><![CDATA[$sData]]></cmd>";
553
+		} else if ($sData !== null) {
554
+					$xml .= ">$sData</cmd>";
555
+		} else {
556
+					$xml .= "></cmd>";
557
+		}
555 558
 
556 559
 		return $xml;
557 560
 	}
@@ -566,11 +569,12 @@  discard block
 block discarded – undo
566 569
 	 * @return string serialized XML
567 570
 	 */
568 571
 	function _buildObjXml($var) {
569
-		if (gettype($var) == "object") $var = get_object_vars($var);
572
+		if (gettype($var) == "object") {
573
+		    $var = get_object_vars($var);
574
+		}
570 575
 		if (!is_array($var)) {
571 576
 			return "<![CDATA[$var]]>";
572
-		}
573
-		else {
577
+		} else {
574 578
 			$data = "<xjxobj>";
575 579
 			foreach ($var as $key => $value) {
576 580
 				$data .= "<e>";
Please login to merge, or discard this patch.
Indentation   +512 added lines, -512 removed lines patch added patch discarded remove patch
@@ -67,521 +67,521 @@
 block discarded – undo
67 67
  */
68 68
 class xajaxResponse
69 69
 {
70
-	/**#@+
70
+    /**#@+
71 71
 	 * @access protected
72 72
 	 */
73
-	/**
74
-	 * @var string internal XML storage
75
-	 */
76
-	var $xml;
77
-	/**
78
-	 * @var string the encoding type to use
79
-	 */
80
-	var $sEncoding;
81
-	/**
82
-	 * @var boolean if special characters in the XML should be converted to
83
-	 *              entities
84
-	 */
85
-	var $bOutputEntities;
86
-
87
-	/**#@-*/
88
-
89
-	/**
90
-	 * The constructor's main job is to set the character encoding for the
91
-	 * response.
92
-	 *
93
-	 * <i>Note:</i> to change the character encoding for all of the
94
-	 * responses, set the XAJAX_DEFAULT_ENCODING constant before you
95
-	 * instantiate xajax.
96
-	 *
97
-	 * @param string  contains the character encoding string to use
98
-	 * @param boolean lets you set if you want special characters in the output
99
-	 *                converted to HTML entities
100
-	 *
101
-	 */
102
-	public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false)
103
-	{
104
-		$this->setCharEncoding($sEncoding);
105
-		$this->bOutputEntities = $bOutputEntities;
106
-	}
107
-
108
-	/**
109
-	 * Sets the character encoding for the response based on $sEncoding, which
110
-	 * is a string containing the character encoding to use. You don't need to
111
-	 * use this method normally, since the character encoding for the response
112
-	 * gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING
113
-	 * constant.
114
-	 *
115
-	 * @param string
116
-	 */
117
-	function setCharEncoding($sEncoding)
118
-	{
119
-		$this->sEncoding = $sEncoding;
120
-	}
121
-
122
-	/**
123
-	 * Tells the response object to convert special characters to HTML entities
124
-	 * automatically (only works if the mb_string extension is available).
125
-	 */
126
-	function outputEntitiesOn()
127
-	{
128
-		$this->bOutputEntities = true;
129
-	}
130
-
131
-	/**
132
-	 * Tells the response object to output special characters intact. (default
133
-	 * behavior)
134
-	 */
135
-	function outputEntitiesOff()
136
-	{
137
-		$this->bOutputEntities = false;
138
-	}
139
-
140
-	/**
141
-	 * Adds a confirm commands command message to the XML response.
142
-	 *
143
-	 * <i>Usage:</i> <kbd>$objResponse->addConfirmCommands(1, "Do you want to preview the new data?");</kbd>
144
-	 *
145
-	 * @param integer the number of commands to skip if the user presses
146
-	 *                Cancel in the browsers's confirm dialog
147
-	 * @param string  the message to show in the browser's confirm dialog
148
-	 */
149
-	function addConfirmCommands($iCmdNumber, $sMessage)
150
-	{
151
-		$this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage);
152
-	}
153
-
154
-	/**
155
-	 * Adds an assign command message to the XML response.
156
-	 *
157
-	 * <i>Usage:</i> <kbd>$objResponse->addAssign("contentDiv", "innerHTML", "Some Text");</kbd>
158
-	 *
159
-	 * @param string contains the id of an HTML element
160
-	 * @param string the part of the element you wish to modify ("innerHTML",
161
-	 *               "value", etc.)
162
-	 * @param string the data you want to set the attribute to
163
-	 */
164
-	function addAssign($sTarget,$sAttribute,$sData)
165
-	{
166
-		$this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData);
167
-	}
168
-
169
-	/**
170
-	 * Adds an append command message to the XML response.
171
-	 *
172
-	 * <i>Usage:</i> <kbd>$objResponse->addAppend("contentDiv", "innerHTML", "Some New Text");</kbd>
173
-	 *
174
-	 * @param string contains the id of an HTML element
175
-	 * @param string the part of the element you wish to modify ("innerHTML",
176
-	 *               "value", etc.)
177
-	 * @param string the data you want to append to the end of the attribute
178
-	 */
179
-	function addAppend($sTarget,$sAttribute,$sData)
180
-	{
181
-		$this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData);
182
-	}
183
-
184
-	/**
185
-	 * Adds an prepend command message to the XML response.
186
-	 *
187
-	 * <i>Usage:</i> <kbd>$objResponse->addPrepend("contentDiv", "innerHTML", "Some Starting Text");</kbd>
188
-	 *
189
-	 * @param string contains the id of an HTML element
190
-	 * @param string the part of the element you wish to modify ("innerHTML",
191
-	 *               "value", etc.)
192
-	 * @param string the data you want to prepend to the beginning of the
193
-	 *               attribute
194
-	 */
195
-	function addPrepend($sTarget,$sAttribute,$sData)
196
-	{
197
-		$this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData);
198
-	}
199
-
200
-	/**
201
-	 * Adds a replace command message to the XML response.
202
-	 *
203
-	 * <i>Usage:</i> <kbd>$objResponse->addReplace("contentDiv", "innerHTML", "text", "<b>text</b>");</kbd>
204
-	 *
205
-	 * @param string contains the id of an HTML element
206
-	 * @param string the part of the element you wish to modify ("innerHTML",
207
-	 *               "value", etc.)
208
-	 * @param string the string to search for
209
-	 * @param string the string to replace the search string when found in the
210
-	 *               attribute
211
-	 */
212
-	function addReplace($sTarget,$sAttribute,$sSearch,$sData)
213
-	{
214
-		$sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>";
215
-		$this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta);
216
-	}
217
-
218
-	/**
219
-	 * Adds a clear command message to the XML response.
220
-	 *
221
-	 * <i>Usage:</i> <kbd>$objResponse->addClear("contentDiv", "innerHTML");</kbd>
222
-	 *
223
-	 * @param string contains the id of an HTML element
224
-	 * @param string the part of the element you wish to clear ("innerHTML",
225
-	 *               "value", etc.)
226
-	 */
227
-	function addClear($sTarget,$sAttribute)
228
-	{
229
-		$this->addAssign($sTarget,$sAttribute,'');
230
-	}
231
-
232
-	/**
233
-	 * Adds an alert command message to the XML response.
234
-	 *
235
-	 * <i>Usage:</i> <kbd>$objResponse->addAlert("This is important information");</kbd>
236
-	 *
237
-	 * @param string the text to be displayed in the Javascript alert box
238
-	 */
239
-	function addAlert($sMsg)
240
-	{
241
-		$this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg);
242
-	}
243
-
244
-	/**
245
-	 * Uses the addScript() method to add a Javascript redirect to another URL.
246
-	 *
247
-	 * <i>Usage:</i> <kbd>$objResponse->addRedirect("http://www.xajaxproject.org");</kbd>
248
-	 *
249
-	 * @param string the URL to redirect the client browser to
250
-	 */
251
-	function addRedirect($sURL)
252
-	{
253
-		//we need to parse the query part so that the values are rawurlencode()'ed
254
-		//can't just use parse_url() cos we could be dealing with a relative URL which
255
-		//  parse_url() can't deal with.
256
-		$queryStart = strpos($sURL, '?', strrpos($sURL, '/'));
257
-		if ($queryStart !== FALSE)
258
-		{
259
-			$queryStart++;
260
-			$queryEnd = strpos($sURL, '#', $queryStart);
261
-			if ($queryEnd === FALSE)
262
-				$queryEnd = strlen($sURL);
263
-			$queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
73
+    /**
74
+     * @var string internal XML storage
75
+     */
76
+    var $xml;
77
+    /**
78
+     * @var string the encoding type to use
79
+     */
80
+    var $sEncoding;
81
+    /**
82
+     * @var boolean if special characters in the XML should be converted to
83
+     *              entities
84
+     */
85
+    var $bOutputEntities;
86
+
87
+    /**#@-*/
88
+
89
+    /**
90
+     * The constructor's main job is to set the character encoding for the
91
+     * response.
92
+     *
93
+     * <i>Note:</i> to change the character encoding for all of the
94
+     * responses, set the XAJAX_DEFAULT_ENCODING constant before you
95
+     * instantiate xajax.
96
+     *
97
+     * @param string  contains the character encoding string to use
98
+     * @param boolean lets you set if you want special characters in the output
99
+     *                converted to HTML entities
100
+     *
101
+     */
102
+    public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false)
103
+    {
104
+        $this->setCharEncoding($sEncoding);
105
+        $this->bOutputEntities = $bOutputEntities;
106
+    }
107
+
108
+    /**
109
+     * Sets the character encoding for the response based on $sEncoding, which
110
+     * is a string containing the character encoding to use. You don't need to
111
+     * use this method normally, since the character encoding for the response
112
+     * gets set automatically based on the XAJAX_DEFAULT_CHAR_ENCODING
113
+     * constant.
114
+     *
115
+     * @param string
116
+     */
117
+    function setCharEncoding($sEncoding)
118
+    {
119
+        $this->sEncoding = $sEncoding;
120
+    }
121
+
122
+    /**
123
+     * Tells the response object to convert special characters to HTML entities
124
+     * automatically (only works if the mb_string extension is available).
125
+     */
126
+    function outputEntitiesOn()
127
+    {
128
+        $this->bOutputEntities = true;
129
+    }
130
+
131
+    /**
132
+     * Tells the response object to output special characters intact. (default
133
+     * behavior)
134
+     */
135
+    function outputEntitiesOff()
136
+    {
137
+        $this->bOutputEntities = false;
138
+    }
139
+
140
+    /**
141
+     * Adds a confirm commands command message to the XML response.
142
+     *
143
+     * <i>Usage:</i> <kbd>$objResponse->addConfirmCommands(1, "Do you want to preview the new data?");</kbd>
144
+     *
145
+     * @param integer the number of commands to skip if the user presses
146
+     *                Cancel in the browsers's confirm dialog
147
+     * @param string  the message to show in the browser's confirm dialog
148
+     */
149
+    function addConfirmCommands($iCmdNumber, $sMessage)
150
+    {
151
+        $this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage);
152
+    }
153
+
154
+    /**
155
+     * Adds an assign command message to the XML response.
156
+     *
157
+     * <i>Usage:</i> <kbd>$objResponse->addAssign("contentDiv", "innerHTML", "Some Text");</kbd>
158
+     *
159
+     * @param string contains the id of an HTML element
160
+     * @param string the part of the element you wish to modify ("innerHTML",
161
+     *               "value", etc.)
162
+     * @param string the data you want to set the attribute to
163
+     */
164
+    function addAssign($sTarget,$sAttribute,$sData)
165
+    {
166
+        $this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData);
167
+    }
168
+
169
+    /**
170
+     * Adds an append command message to the XML response.
171
+     *
172
+     * <i>Usage:</i> <kbd>$objResponse->addAppend("contentDiv", "innerHTML", "Some New Text");</kbd>
173
+     *
174
+     * @param string contains the id of an HTML element
175
+     * @param string the part of the element you wish to modify ("innerHTML",
176
+     *               "value", etc.)
177
+     * @param string the data you want to append to the end of the attribute
178
+     */
179
+    function addAppend($sTarget,$sAttribute,$sData)
180
+    {
181
+        $this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData);
182
+    }
183
+
184
+    /**
185
+     * Adds an prepend command message to the XML response.
186
+     *
187
+     * <i>Usage:</i> <kbd>$objResponse->addPrepend("contentDiv", "innerHTML", "Some Starting Text");</kbd>
188
+     *
189
+     * @param string contains the id of an HTML element
190
+     * @param string the part of the element you wish to modify ("innerHTML",
191
+     *               "value", etc.)
192
+     * @param string the data you want to prepend to the beginning of the
193
+     *               attribute
194
+     */
195
+    function addPrepend($sTarget,$sAttribute,$sData)
196
+    {
197
+        $this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData);
198
+    }
199
+
200
+    /**
201
+     * Adds a replace command message to the XML response.
202
+     *
203
+     * <i>Usage:</i> <kbd>$objResponse->addReplace("contentDiv", "innerHTML", "text", "<b>text</b>");</kbd>
204
+     *
205
+     * @param string contains the id of an HTML element
206
+     * @param string the part of the element you wish to modify ("innerHTML",
207
+     *               "value", etc.)
208
+     * @param string the string to search for
209
+     * @param string the string to replace the search string when found in the
210
+     *               attribute
211
+     */
212
+    function addReplace($sTarget,$sAttribute,$sSearch,$sData)
213
+    {
214
+        $sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>";
215
+        $this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta);
216
+    }
217
+
218
+    /**
219
+     * Adds a clear command message to the XML response.
220
+     *
221
+     * <i>Usage:</i> <kbd>$objResponse->addClear("contentDiv", "innerHTML");</kbd>
222
+     *
223
+     * @param string contains the id of an HTML element
224
+     * @param string the part of the element you wish to clear ("innerHTML",
225
+     *               "value", etc.)
226
+     */
227
+    function addClear($sTarget,$sAttribute)
228
+    {
229
+        $this->addAssign($sTarget,$sAttribute,'');
230
+    }
231
+
232
+    /**
233
+     * Adds an alert command message to the XML response.
234
+     *
235
+     * <i>Usage:</i> <kbd>$objResponse->addAlert("This is important information");</kbd>
236
+     *
237
+     * @param string the text to be displayed in the Javascript alert box
238
+     */
239
+    function addAlert($sMsg)
240
+    {
241
+        $this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg);
242
+    }
243
+
244
+    /**
245
+     * Uses the addScript() method to add a Javascript redirect to another URL.
246
+     *
247
+     * <i>Usage:</i> <kbd>$objResponse->addRedirect("http://www.xajaxproject.org");</kbd>
248
+     *
249
+     * @param string the URL to redirect the client browser to
250
+     */
251
+    function addRedirect($sURL)
252
+    {
253
+        //we need to parse the query part so that the values are rawurlencode()'ed
254
+        //can't just use parse_url() cos we could be dealing with a relative URL which
255
+        //  parse_url() can't deal with.
256
+        $queryStart = strpos($sURL, '?', strrpos($sURL, '/'));
257
+        if ($queryStart !== FALSE)
258
+        {
259
+            $queryStart++;
260
+            $queryEnd = strpos($sURL, '#', $queryStart);
261
+            if ($queryEnd === FALSE)
262
+                $queryEnd = strlen($sURL);
263
+            $queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
264 264
             $queryParts = array();
265
-			parse_str($queryPart, $queryParts);
266
-			$newQueryPart = "";
267
-			foreach($queryParts as $key => $value)
268
-			{
269
-				$newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output');
270
-			}
271
-			$sURL = str_replace($queryPart, $newQueryPart, $sURL);
272
-		}
273
-		$this->addScript('window.location = "'.$sURL.'";');
274
-	}
275
-
276
-	/**
277
-	 * Adds a Javascript command message to the XML response.
278
-	 *
279
-	 * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd>
280
-	 *
281
-	 * @param string contains Javascript code to be executed
282
-	 */
283
-	function addScript($sJS)
284
-	{
285
-		$this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS);
286
-	}
287
-
288
-	/**
289
-	 * Adds a Javascript function call command message to the XML response.
290
-	 *
291
-	 * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd>
292
-	 *
293
-	 * @param string $sFunc the name of a Javascript function
294
-	 * @param mixed $args,... optional arguments to pass to the Javascript function
295
-	 */
296
-	function addScriptCall() {
297
-		$arguments = func_get_args();
298
-		$sFunc = array_shift($arguments);
299
-		$sData = $this->_buildObjXml($arguments);
300
-		$this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData);
301
-	}
302
-
303
-	/**
304
-	 * Adds a remove element command message to the XML response.
305
-	 *
306
-	 * <i>Usage:</i> <kbd>$objResponse->addRemove("Div2");</kbd>
307
-	 *
308
-	 * @param string contains the id of an HTML element to be removed
309
-	 */
310
-	function addRemove($sTarget)
311
-	{
312
-		$this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),'');
313
-	}
314
-
315
-	/**
316
-	 * Adds a create element command message to the XML response.
317
-	 *
318
-	 * <i>Usage:</i> <kbd>$objResponse->addCreate("parentDiv", "h3", "myid");</kbd>
319
-	 *
320
-	 * @param string contains the id of an HTML element to to which the new
321
-	 *               element will be appended.
322
-	 * @param string the tag to be added
323
-	 * @param string the id to be assigned to the new element
324
-	 * @param string deprecated, use the addCreateInput() method instead
325
-	 */
326
-	function addCreate($sParent, $sTag, $sId, $sType="")
327
-	{
328
-		if ($sType)
329
-		{
330
-			trigger_error("The \$sType parameter of addCreate has been deprecated.  Use the addCreateInput() method instead.", E_USER_WARNING);
331
-			return;
332
-		}
333
-		$this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag);
334
-	}
335
-
336
-	/**
337
-	 * Adds a insert element command message to the XML response.
338
-	 *
339
-	 * <i>Usage:</i> <kbd>$objResponse->addInsert("childDiv", "h3", "myid");</kbd>
340
-	 *
341
-	 * @param string contains the id of the child before which the new element
342
-	 *               will be inserted
343
-	 * @param string the tag to be added
344
-	 * @param string the id to be assigned to the new element
345
-	 */
346
-	function addInsert($sBefore, $sTag, $sId)
347
-	{
348
-		$this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag);
349
-	}
350
-
351
-	/**
352
-	 * Adds a insert element command message to the XML response.
353
-	 *
354
-	 * <i>Usage:</i> <kbd>$objResponse->addInsertAfter("childDiv", "h3", "myid");</kbd>
355
-	 *
356
-	 * @param string contains the id of the child after which the new element
357
-	 *               will be inserted
358
-	 * @param string the tag to be added
359
-	 * @param string the id to be assigned to the new element
360
-	 */
361
-	function addInsertAfter($sAfter, $sTag, $sId)
362
-	{
363
-		$this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag);
364
-	}
365
-
366
-	/**
367
-	 * Adds a create input command message to the XML response.
368
-	 *
369
-	 * <i>Usage:</i> <kbd>$objResponse->addCreateInput("form1", "text", "username", "input1");</kbd>
370
-	 *
371
-	 * @param string contains the id of an HTML element to which the new input
372
-	 *               will be appended
373
-	 * @param string the type of input to be created (text, radio, checkbox,
374
-	 *               etc.)
375
-	 * @param string the name to be assigned to the new input and the variable
376
-	 *               name when it is submitted
377
-	 * @param string the id to be assigned to the new input
378
-	 */
379
-	function addCreateInput($sParent, $sType, $sName, $sId)
380
-	{
381
-		$this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName);
382
-	}
383
-
384
-	/**
385
-	 * Adds an insert input command message to the XML response.
386
-	 *
387
-	 * <i>Usage:</i> <kbd>$objResponse->addInsertInput("input5", "text", "username", "input1");</kbd>
388
-	 *
389
-	 * @param string contains the id of the child before which the new element
390
-	 *               will be inserted
391
-	 * @param string the type of input to be created (text, radio, checkbox,
392
-	 *               etc.)
393
-	 * @param string the name to be assigned to the new input and the variable
394
-	 *               name when it is submitted
395
-	 * @param string the id to be assigned to the new input
396
-	 */
397
-	function addInsertInput($sBefore, $sType, $sName, $sId)
398
-	{
399
-		$this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName);
400
-	}
401
-
402
-	/**
403
-	 * Adds an insert input command message to the XML response.
404
-	 *
405
-	 * <i>Usage:</i> <kbd>$objResponse->addInsertInputAfter("input7", "text", "email", "input2");</kbd>
406
-	 *
407
-	 * @param string contains the id of the child after which the new element
408
-	 *               will be inserted
409
-	 * @param string the type of input to be created (text, radio, checkbox,
410
-	 *               etc.)
411
-	 * @param string the name to be assigned to the new input and the variable
412
-	 *               name when it is submitted
413
-	 * @param string the id to be assigned to the new input
414
-	 */
415
-	function addInsertInputAfter($sAfter, $sType, $sName, $sId)
416
-	{
417
-		$this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName);
418
-	}
419
-
420
-	/**
421
-	 * Adds an event command message to the XML response.
422
-	 *
423
-	 * <i>Usage:</i> <kbd>$objResponse->addEvent("contentDiv", "onclick", "alert(\'Hello World\');");</kbd>
424
-	 *
425
-	 * @param string contains the id of an HTML element
426
-	 * @param string the event you wish to set ("onclick", "onmouseover", etc.)
427
-	 * @param string the Javascript string you want the event to invoke
428
-	 */
429
-	function addEvent($sTarget,$sEvent,$sScript)
430
-	{
431
-		$this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript);
432
-	}
433
-
434
-	/**
435
-	 * Adds a handler command message to the XML response.
436
-	 *
437
-	 * <i>Usage:</i> <kbd>$objResponse->addHandler("contentDiv", "onclick", "content_click");</kbd>
438
-	 *
439
-	 * @param string contains the id of an HTML element
440
-	 * @param string the event you wish to set ("onclick", "onmouseover", etc.)
441
-	 * @param string the name of a Javascript function that will handle the
442
-	 *               event. Multiple handlers can be added for the same event
443
-	 */
444
-	function addHandler($sTarget,$sEvent,$sHandler)
445
-	{
446
-		$this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler);
447
-	}
448
-
449
-	/**
450
-	 * Adds a remove handler command message to the XML response.
451
-	 *
452
-	 * <i>Usage:</i> <kbd>$objResponse->addRemoveHandler("contentDiv", "onclick", "content_click");</kbd>
453
-	 *
454
-	 * @param string contains the id of an HTML element
455
-	 * @param string the event you wish to remove ("onclick", "onmouseover",
456
-	 *               etc.)
457
-	 * @param string the name of a Javascript handler function that you want to
458
-	 *               remove
459
-	 */
460
-	function addRemoveHandler($sTarget,$sEvent,$sHandler)
461
-	{
462
-		$this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler);
463
-	}
464
-
465
-	/**
466
-	 * Adds an include script command message to the XML response.
467
-	 *
468
-	 * <i>Usage:</i> <kbd>$objResponse->addIncludeScript("functions.js");</kbd>
469
-	 *
470
-	 * @param string URL of the Javascript file to include
471
-	 */
472
-	function addIncludeScript($sFileName)
473
-	{
474
-		$this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName);
475
-	}
476
-
477
-	/**
478
-	 * Returns the XML to be returned from your function to the xajax processor
479
-	 * on your page. Since xajax 0.2, you can also return an xajaxResponse
480
-	 * object from your function directly, and xajax will automatically request
481
-	 * the XML using this method call.
482
-	 *
483
-	 * <i>Usage:</i> <kbd>return $objResponse->getXML();</kbd>
484
-	 *
485
-	 * @return string response XML data
486
-	 */
487
-	function getXML()
488
-	{
489
-		$sXML = "<?xml version=\"1.0\"";
490
-		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
491
-			$sXML .= " encoding=\"".$this->sEncoding."\"";
492
-		$sXML .= " ?"."><xjx>" . $this->xml . "</xjx>";
493
-
494
-		return $sXML;
495
-	}
496
-
497
-	/**
498
-	 * Adds the commands of the provided response XML output to this response
499
-	 * object
500
-	 *
501
-	 * <i>Usage:</i>
502
-	 * <code>$r1 = $objResponse1->getXML();
503
-	 * $objResponse2->loadXML($r1);
504
-	 * return $objResponse2->getXML();</code>
505
-	 *
506
-	 * @param string the response XML (returned from a getXML() method) to add
507
-	 *               to the end of this response object
508
-	 */
509
-	function loadXML($mXML)
510
-	{
511
-		if (is_a($mXML, "xajaxResponse")) {
512
-			$mXML = $mXML->getXML();
513
-		}
514
-		$sNewXML = "";
515
-		$iStartPos = strpos($mXML, "<xjx>") + 5;
516
-		$sNewXML = substr($mXML, $iStartPos);
517
-		$iEndPos = strpos($sNewXML, "</xjx>");
518
-		$sNewXML = substr($sNewXML, 0, $iEndPos);
519
-		$this->xml .= $sNewXML;
520
-	}
521
-
522
-	/**
523
-	 * Generates XML from command data
524
-	 *
525
-	 * @access private
526
-	 * @param array associative array of attributes
527
-	 * @param string data
528
-	 * @return string XML command
529
-	 */
530
-	function _cmdXML($aAttributes, $sData)
531
-	{
532
-		if ($this->bOutputEntities) {
533
-			// An adaptation for the Dokeos LMS, 22-AUG-2009.
534
-			if (function_exists('api_convert_encoding')) {
535
-				$sData = call_user_func_array('api_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
536
-			}
537
-			//if (function_exists('mb_convert_encoding')) {
538
-			elseif (function_exists('mb_convert_encoding')) {
539
-			//
540
-				$sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
541
-			}
542
-			else {
543
-				trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE);
544
-			}
545
-		}
546
-		$xml = "<cmd";
547
-		foreach($aAttributes as $sAttribute => $sValue)
548
-			$xml .= " $sAttribute=\"$sValue\"";
549
-		if ($sData !== null && !stristr($sData,'<![CDATA['))
550
-			$xml .= "><![CDATA[$sData]]></cmd>";
551
-		else if ($sData !== null)
552
-			$xml .= ">$sData</cmd>";
553
-		else
554
-			$xml .= "></cmd>";
555
-
556
-		return $xml;
557
-	}
558
-
559
-	/**
560
-	 * Recursively serializes a data structure in XML so it can be sent to
561
-	 * the client. It could be thought of as the opposite of
562
-	 * {@link xajax::_parseObjXml()}.
563
-	 *
564
-	 * @access private
565
-	 * @param mixed data structure to serialize to XML
566
-	 * @return string serialized XML
567
-	 */
568
-	function _buildObjXml($var) {
569
-		if (gettype($var) == "object") $var = get_object_vars($var);
570
-		if (!is_array($var)) {
571
-			return "<![CDATA[$var]]>";
572
-		}
573
-		else {
574
-			$data = "<xjxobj>";
575
-			foreach ($var as $key => $value) {
576
-				$data .= "<e>";
577
-				$data .= "<k>" . htmlspecialchars($key) . "</k>";
578
-				$data .= "<v>" . $this->_buildObjXml($value) . "</v>";
579
-				$data .= "</e>";
580
-			}
581
-			$data .= "</xjxobj>";
582
-			return $data;
583
-		}
584
-	}
265
+            parse_str($queryPart, $queryParts);
266
+            $newQueryPart = "";
267
+            foreach($queryParts as $key => $value)
268
+            {
269
+                $newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output');
270
+            }
271
+            $sURL = str_replace($queryPart, $newQueryPart, $sURL);
272
+        }
273
+        $this->addScript('window.location = "'.$sURL.'";');
274
+    }
275
+
276
+    /**
277
+     * Adds a Javascript command message to the XML response.
278
+     *
279
+     * <i>Usage:</i> <kbd>$objResponse->addScript("var x = prompt('get some text');");</kbd>
280
+     *
281
+     * @param string contains Javascript code to be executed
282
+     */
283
+    function addScript($sJS)
284
+    {
285
+        $this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS);
286
+    }
287
+
288
+    /**
289
+     * Adds a Javascript function call command message to the XML response.
290
+     *
291
+     * <i>Usage:</i> <kbd>$objResponse->addScriptCall("myJSFunction", "arg 1", "arg 2", 12345);</kbd>
292
+     *
293
+     * @param string $sFunc the name of a Javascript function
294
+     * @param mixed $args,... optional arguments to pass to the Javascript function
295
+     */
296
+    function addScriptCall() {
297
+        $arguments = func_get_args();
298
+        $sFunc = array_shift($arguments);
299
+        $sData = $this->_buildObjXml($arguments);
300
+        $this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData);
301
+    }
302
+
303
+    /**
304
+     * Adds a remove element command message to the XML response.
305
+     *
306
+     * <i>Usage:</i> <kbd>$objResponse->addRemove("Div2");</kbd>
307
+     *
308
+     * @param string contains the id of an HTML element to be removed
309
+     */
310
+    function addRemove($sTarget)
311
+    {
312
+        $this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),'');
313
+    }
314
+
315
+    /**
316
+     * Adds a create element command message to the XML response.
317
+     *
318
+     * <i>Usage:</i> <kbd>$objResponse->addCreate("parentDiv", "h3", "myid");</kbd>
319
+     *
320
+     * @param string contains the id of an HTML element to to which the new
321
+     *               element will be appended.
322
+     * @param string the tag to be added
323
+     * @param string the id to be assigned to the new element
324
+     * @param string deprecated, use the addCreateInput() method instead
325
+     */
326
+    function addCreate($sParent, $sTag, $sId, $sType="")
327
+    {
328
+        if ($sType)
329
+        {
330
+            trigger_error("The \$sType parameter of addCreate has been deprecated.  Use the addCreateInput() method instead.", E_USER_WARNING);
331
+            return;
332
+        }
333
+        $this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag);
334
+    }
335
+
336
+    /**
337
+     * Adds a insert element command message to the XML response.
338
+     *
339
+     * <i>Usage:</i> <kbd>$objResponse->addInsert("childDiv", "h3", "myid");</kbd>
340
+     *
341
+     * @param string contains the id of the child before which the new element
342
+     *               will be inserted
343
+     * @param string the tag to be added
344
+     * @param string the id to be assigned to the new element
345
+     */
346
+    function addInsert($sBefore, $sTag, $sId)
347
+    {
348
+        $this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag);
349
+    }
350
+
351
+    /**
352
+     * Adds a insert element command message to the XML response.
353
+     *
354
+     * <i>Usage:</i> <kbd>$objResponse->addInsertAfter("childDiv", "h3", "myid");</kbd>
355
+     *
356
+     * @param string contains the id of the child after which the new element
357
+     *               will be inserted
358
+     * @param string the tag to be added
359
+     * @param string the id to be assigned to the new element
360
+     */
361
+    function addInsertAfter($sAfter, $sTag, $sId)
362
+    {
363
+        $this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag);
364
+    }
365
+
366
+    /**
367
+     * Adds a create input command message to the XML response.
368
+     *
369
+     * <i>Usage:</i> <kbd>$objResponse->addCreateInput("form1", "text", "username", "input1");</kbd>
370
+     *
371
+     * @param string contains the id of an HTML element to which the new input
372
+     *               will be appended
373
+     * @param string the type of input to be created (text, radio, checkbox,
374
+     *               etc.)
375
+     * @param string the name to be assigned to the new input and the variable
376
+     *               name when it is submitted
377
+     * @param string the id to be assigned to the new input
378
+     */
379
+    function addCreateInput($sParent, $sType, $sName, $sId)
380
+    {
381
+        $this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName);
382
+    }
383
+
384
+    /**
385
+     * Adds an insert input command message to the XML response.
386
+     *
387
+     * <i>Usage:</i> <kbd>$objResponse->addInsertInput("input5", "text", "username", "input1");</kbd>
388
+     *
389
+     * @param string contains the id of the child before which the new element
390
+     *               will be inserted
391
+     * @param string the type of input to be created (text, radio, checkbox,
392
+     *               etc.)
393
+     * @param string the name to be assigned to the new input and the variable
394
+     *               name when it is submitted
395
+     * @param string the id to be assigned to the new input
396
+     */
397
+    function addInsertInput($sBefore, $sType, $sName, $sId)
398
+    {
399
+        $this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName);
400
+    }
401
+
402
+    /**
403
+     * Adds an insert input command message to the XML response.
404
+     *
405
+     * <i>Usage:</i> <kbd>$objResponse->addInsertInputAfter("input7", "text", "email", "input2");</kbd>
406
+     *
407
+     * @param string contains the id of the child after which the new element
408
+     *               will be inserted
409
+     * @param string the type of input to be created (text, radio, checkbox,
410
+     *               etc.)
411
+     * @param string the name to be assigned to the new input and the variable
412
+     *               name when it is submitted
413
+     * @param string the id to be assigned to the new input
414
+     */
415
+    function addInsertInputAfter($sAfter, $sType, $sName, $sId)
416
+    {
417
+        $this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName);
418
+    }
419
+
420
+    /**
421
+     * Adds an event command message to the XML response.
422
+     *
423
+     * <i>Usage:</i> <kbd>$objResponse->addEvent("contentDiv", "onclick", "alert(\'Hello World\');");</kbd>
424
+     *
425
+     * @param string contains the id of an HTML element
426
+     * @param string the event you wish to set ("onclick", "onmouseover", etc.)
427
+     * @param string the Javascript string you want the event to invoke
428
+     */
429
+    function addEvent($sTarget,$sEvent,$sScript)
430
+    {
431
+        $this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript);
432
+    }
433
+
434
+    /**
435
+     * Adds a handler command message to the XML response.
436
+     *
437
+     * <i>Usage:</i> <kbd>$objResponse->addHandler("contentDiv", "onclick", "content_click");</kbd>
438
+     *
439
+     * @param string contains the id of an HTML element
440
+     * @param string the event you wish to set ("onclick", "onmouseover", etc.)
441
+     * @param string the name of a Javascript function that will handle the
442
+     *               event. Multiple handlers can be added for the same event
443
+     */
444
+    function addHandler($sTarget,$sEvent,$sHandler)
445
+    {
446
+        $this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler);
447
+    }
448
+
449
+    /**
450
+     * Adds a remove handler command message to the XML response.
451
+     *
452
+     * <i>Usage:</i> <kbd>$objResponse->addRemoveHandler("contentDiv", "onclick", "content_click");</kbd>
453
+     *
454
+     * @param string contains the id of an HTML element
455
+     * @param string the event you wish to remove ("onclick", "onmouseover",
456
+     *               etc.)
457
+     * @param string the name of a Javascript handler function that you want to
458
+     *               remove
459
+     */
460
+    function addRemoveHandler($sTarget,$sEvent,$sHandler)
461
+    {
462
+        $this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler);
463
+    }
464
+
465
+    /**
466
+     * Adds an include script command message to the XML response.
467
+     *
468
+     * <i>Usage:</i> <kbd>$objResponse->addIncludeScript("functions.js");</kbd>
469
+     *
470
+     * @param string URL of the Javascript file to include
471
+     */
472
+    function addIncludeScript($sFileName)
473
+    {
474
+        $this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName);
475
+    }
476
+
477
+    /**
478
+     * Returns the XML to be returned from your function to the xajax processor
479
+     * on your page. Since xajax 0.2, you can also return an xajaxResponse
480
+     * object from your function directly, and xajax will automatically request
481
+     * the XML using this method call.
482
+     *
483
+     * <i>Usage:</i> <kbd>return $objResponse->getXML();</kbd>
484
+     *
485
+     * @return string response XML data
486
+     */
487
+    function getXML()
488
+    {
489
+        $sXML = "<?xml version=\"1.0\"";
490
+        if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
491
+            $sXML .= " encoding=\"".$this->sEncoding."\"";
492
+        $sXML .= " ?"."><xjx>" . $this->xml . "</xjx>";
493
+
494
+        return $sXML;
495
+    }
496
+
497
+    /**
498
+     * Adds the commands of the provided response XML output to this response
499
+     * object
500
+     *
501
+     * <i>Usage:</i>
502
+     * <code>$r1 = $objResponse1->getXML();
503
+     * $objResponse2->loadXML($r1);
504
+     * return $objResponse2->getXML();</code>
505
+     *
506
+     * @param string the response XML (returned from a getXML() method) to add
507
+     *               to the end of this response object
508
+     */
509
+    function loadXML($mXML)
510
+    {
511
+        if (is_a($mXML, "xajaxResponse")) {
512
+            $mXML = $mXML->getXML();
513
+        }
514
+        $sNewXML = "";
515
+        $iStartPos = strpos($mXML, "<xjx>") + 5;
516
+        $sNewXML = substr($mXML, $iStartPos);
517
+        $iEndPos = strpos($sNewXML, "</xjx>");
518
+        $sNewXML = substr($sNewXML, 0, $iEndPos);
519
+        $this->xml .= $sNewXML;
520
+    }
521
+
522
+    /**
523
+     * Generates XML from command data
524
+     *
525
+     * @access private
526
+     * @param array associative array of attributes
527
+     * @param string data
528
+     * @return string XML command
529
+     */
530
+    function _cmdXML($aAttributes, $sData)
531
+    {
532
+        if ($this->bOutputEntities) {
533
+            // An adaptation for the Dokeos LMS, 22-AUG-2009.
534
+            if (function_exists('api_convert_encoding')) {
535
+                $sData = call_user_func_array('api_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
536
+            }
537
+            //if (function_exists('mb_convert_encoding')) {
538
+            elseif (function_exists('mb_convert_encoding')) {
539
+            //
540
+                $sData = call_user_func_array('mb_convert_encoding', array(&$sData, 'HTML-ENTITIES', $this->sEncoding));
541
+            }
542
+            else {
543
+                trigger_error("The xajax XML response output could not be converted to HTML entities because the mb_convert_encoding function is not available", E_USER_NOTICE);
544
+            }
545
+        }
546
+        $xml = "<cmd";
547
+        foreach($aAttributes as $sAttribute => $sValue)
548
+            $xml .= " $sAttribute=\"$sValue\"";
549
+        if ($sData !== null && !stristr($sData,'<![CDATA['))
550
+            $xml .= "><![CDATA[$sData]]></cmd>";
551
+        else if ($sData !== null)
552
+            $xml .= ">$sData</cmd>";
553
+        else
554
+            $xml .= "></cmd>";
555
+
556
+        return $xml;
557
+    }
558
+
559
+    /**
560
+     * Recursively serializes a data structure in XML so it can be sent to
561
+     * the client. It could be thought of as the opposite of
562
+     * {@link xajax::_parseObjXml()}.
563
+     *
564
+     * @access private
565
+     * @param mixed data structure to serialize to XML
566
+     * @return string serialized XML
567
+     */
568
+    function _buildObjXml($var) {
569
+        if (gettype($var) == "object") $var = get_object_vars($var);
570
+        if (!is_array($var)) {
571
+            return "<![CDATA[$var]]>";
572
+        }
573
+        else {
574
+            $data = "<xjxobj>";
575
+            foreach ($var as $key => $value) {
576
+                $data .= "<e>";
577
+                $data .= "<k>" . htmlspecialchars($key) . "</k>";
578
+                $data .= "<v>" . $this->_buildObjXml($value) . "</v>";
579
+                $data .= "</e>";
580
+            }
581
+            $data .= "</xjxobj>";
582
+            return $data;
583
+        }
584
+    }
585 585
 
586 586
 }// end class xajaxResponse
587 587
 ?>
Please login to merge, or discard this patch.
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 *                converted to HTML entities
100 100
 	 *
101 101
 	 */
102
-	public function __construct($sEncoding=XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities=false)
102
+	public function __construct($sEncoding = XAJAX_DEFAULT_CHAR_ENCODING, $bOutputEntities = false)
103 103
 	{
104 104
 		$this->setCharEncoding($sEncoding);
105 105
 		$this->bOutputEntities = $bOutputEntities;
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 	 */
149 149
 	function addConfirmCommands($iCmdNumber, $sMessage)
150 150
 	{
151
-		$this->xml .= $this->_cmdXML(array("n"=>"cc","t"=>$iCmdNumber),$sMessage);
151
+		$this->xml .= $this->_cmdXML(array("n"=>"cc", "t"=>$iCmdNumber), $sMessage);
152 152
 	}
153 153
 
154 154
 	/**
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 	 *               "value", etc.)
162 162
 	 * @param string the data you want to set the attribute to
163 163
 	 */
164
-	function addAssign($sTarget,$sAttribute,$sData)
164
+	function addAssign($sTarget, $sAttribute, $sData)
165 165
 	{
166
-		$this->xml .= $this->_cmdXML(array("n"=>"as","t"=>$sTarget,"p"=>$sAttribute),$sData);
166
+		$this->xml .= $this->_cmdXML(array("n"=>"as", "t"=>$sTarget, "p"=>$sAttribute), $sData);
167 167
 	}
168 168
 
169 169
 	/**
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 *               "value", etc.)
177 177
 	 * @param string the data you want to append to the end of the attribute
178 178
 	 */
179
-	function addAppend($sTarget,$sAttribute,$sData)
179
+	function addAppend($sTarget, $sAttribute, $sData)
180 180
 	{
181
-		$this->xml .= $this->_cmdXML(array("n"=>"ap","t"=>$sTarget,"p"=>$sAttribute),$sData);
181
+		$this->xml .= $this->_cmdXML(array("n"=>"ap", "t"=>$sTarget, "p"=>$sAttribute), $sData);
182 182
 	}
183 183
 
184 184
 	/**
@@ -192,9 +192,9 @@  discard block
 block discarded – undo
192 192
 	 * @param string the data you want to prepend to the beginning of the
193 193
 	 *               attribute
194 194
 	 */
195
-	function addPrepend($sTarget,$sAttribute,$sData)
195
+	function addPrepend($sTarget, $sAttribute, $sData)
196 196
 	{
197
-		$this->xml .= $this->_cmdXML(array("n"=>"pp","t"=>$sTarget,"p"=>$sAttribute),$sData);
197
+		$this->xml .= $this->_cmdXML(array("n"=>"pp", "t"=>$sTarget, "p"=>$sAttribute), $sData);
198 198
 	}
199 199
 
200 200
 	/**
@@ -209,10 +209,10 @@  discard block
 block discarded – undo
209 209
 	 * @param string the string to replace the search string when found in the
210 210
 	 *               attribute
211 211
 	 */
212
-	function addReplace($sTarget,$sAttribute,$sSearch,$sData)
212
+	function addReplace($sTarget, $sAttribute, $sSearch, $sData)
213 213
 	{
214 214
 		$sDta = "<s><![CDATA[$sSearch]]></s><r><![CDATA[$sData]]></r>";
215
-		$this->xml .= $this->_cmdXML(array("n"=>"rp","t"=>$sTarget,"p"=>$sAttribute),$sDta);
215
+		$this->xml .= $this->_cmdXML(array("n"=>"rp", "t"=>$sTarget, "p"=>$sAttribute), $sDta);
216 216
 	}
217 217
 
218 218
 	/**
@@ -224,9 +224,9 @@  discard block
 block discarded – undo
224 224
 	 * @param string the part of the element you wish to clear ("innerHTML",
225 225
 	 *               "value", etc.)
226 226
 	 */
227
-	function addClear($sTarget,$sAttribute)
227
+	function addClear($sTarget, $sAttribute)
228 228
 	{
229
-		$this->addAssign($sTarget,$sAttribute,'');
229
+		$this->addAssign($sTarget, $sAttribute, '');
230 230
 	}
231 231
 
232 232
 	/**
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 */
239 239
 	function addAlert($sMsg)
240 240
 	{
241
-		$this->xml .= $this->_cmdXML(array("n"=>"al"),$sMsg);
241
+		$this->xml .= $this->_cmdXML(array("n"=>"al"), $sMsg);
242 242
 	}
243 243
 
244 244
 	/**
@@ -260,11 +260,11 @@  discard block
 block discarded – undo
260 260
 			$queryEnd = strpos($sURL, '#', $queryStart);
261 261
 			if ($queryEnd === FALSE)
262 262
 				$queryEnd = strlen($sURL);
263
-			$queryPart = substr($sURL, $queryStart, $queryEnd-$queryStart);
263
+			$queryPart = substr($sURL, $queryStart, $queryEnd - $queryStart);
264 264
             $queryParts = array();
265 265
 			parse_str($queryPart, $queryParts);
266 266
 			$newQueryPart = "";
267
-			foreach($queryParts as $key => $value)
267
+			foreach ($queryParts as $key => $value)
268 268
 			{
269 269
 				$newQueryPart .= rawurlencode($key).'='.rawurlencode($value).ini_get('arg_separator.output');
270 270
 			}
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 */
283 283
 	function addScript($sJS)
284 284
 	{
285
-		$this->xml .= $this->_cmdXML(array("n"=>"js"),$sJS);
285
+		$this->xml .= $this->_cmdXML(array("n"=>"js"), $sJS);
286 286
 	}
287 287
 
288 288
 	/**
@@ -297,7 +297,7 @@  discard block
 block discarded – undo
297 297
 		$arguments = func_get_args();
298 298
 		$sFunc = array_shift($arguments);
299 299
 		$sData = $this->_buildObjXml($arguments);
300
-		$this->xml .= $this->_cmdXML(array("n"=>"jc","t"=>$sFunc),$sData);
300
+		$this->xml .= $this->_cmdXML(array("n"=>"jc", "t"=>$sFunc), $sData);
301 301
 	}
302 302
 
303 303
 	/**
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 */
310 310
 	function addRemove($sTarget)
311 311
 	{
312
-		$this->xml .= $this->_cmdXML(array("n"=>"rm","t"=>$sTarget),'');
312
+		$this->xml .= $this->_cmdXML(array("n"=>"rm", "t"=>$sTarget), '');
313 313
 	}
314 314
 
315 315
 	/**
@@ -323,14 +323,14 @@  discard block
 block discarded – undo
323 323
 	 * @param string the id to be assigned to the new element
324 324
 	 * @param string deprecated, use the addCreateInput() method instead
325 325
 	 */
326
-	function addCreate($sParent, $sTag, $sId, $sType="")
326
+	function addCreate($sParent, $sTag, $sId, $sType = "")
327 327
 	{
328 328
 		if ($sType)
329 329
 		{
330 330
 			trigger_error("The \$sType parameter of addCreate has been deprecated.  Use the addCreateInput() method instead.", E_USER_WARNING);
331 331
 			return;
332 332
 		}
333
-		$this->xml .= $this->_cmdXML(array("n"=>"ce","t"=>$sParent,"p"=>$sId),$sTag);
333
+		$this->xml .= $this->_cmdXML(array("n"=>"ce", "t"=>$sParent, "p"=>$sId), $sTag);
334 334
 	}
335 335
 
336 336
 	/**
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	function addInsert($sBefore, $sTag, $sId)
347 347
 	{
348
-		$this->xml .= $this->_cmdXML(array("n"=>"ie","t"=>$sBefore,"p"=>$sId),$sTag);
348
+		$this->xml .= $this->_cmdXML(array("n"=>"ie", "t"=>$sBefore, "p"=>$sId), $sTag);
349 349
 	}
350 350
 
351 351
 	/**
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 */
361 361
 	function addInsertAfter($sAfter, $sTag, $sId)
362 362
 	{
363
-		$this->xml .= $this->_cmdXML(array("n"=>"ia","t"=>$sAfter,"p"=>$sId),$sTag);
363
+		$this->xml .= $this->_cmdXML(array("n"=>"ia", "t"=>$sAfter, "p"=>$sId), $sTag);
364 364
 	}
365 365
 
366 366
 	/**
@@ -378,7 +378,7 @@  discard block
 block discarded – undo
378 378
 	 */
379 379
 	function addCreateInput($sParent, $sType, $sName, $sId)
380 380
 	{
381
-		$this->xml .= $this->_cmdXML(array("n"=>"ci","t"=>$sParent,"p"=>$sId,"c"=>$sType),$sName);
381
+		$this->xml .= $this->_cmdXML(array("n"=>"ci", "t"=>$sParent, "p"=>$sId, "c"=>$sType), $sName);
382 382
 	}
383 383
 
384 384
 	/**
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 	 */
397 397
 	function addInsertInput($sBefore, $sType, $sName, $sId)
398 398
 	{
399
-		$this->xml .= $this->_cmdXML(array("n"=>"ii","t"=>$sBefore,"p"=>$sId,"c"=>$sType),$sName);
399
+		$this->xml .= $this->_cmdXML(array("n"=>"ii", "t"=>$sBefore, "p"=>$sId, "c"=>$sType), $sName);
400 400
 	}
401 401
 
402 402
 	/**
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 	 */
415 415
 	function addInsertInputAfter($sAfter, $sType, $sName, $sId)
416 416
 	{
417
-		$this->xml .= $this->_cmdXML(array("n"=>"iia","t"=>$sAfter,"p"=>$sId,"c"=>$sType),$sName);
417
+		$this->xml .= $this->_cmdXML(array("n"=>"iia", "t"=>$sAfter, "p"=>$sId, "c"=>$sType), $sName);
418 418
 	}
419 419
 
420 420
 	/**
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
 	 * @param string the event you wish to set ("onclick", "onmouseover", etc.)
427 427
 	 * @param string the Javascript string you want the event to invoke
428 428
 	 */
429
-	function addEvent($sTarget,$sEvent,$sScript)
429
+	function addEvent($sTarget, $sEvent, $sScript)
430 430
 	{
431
-		$this->xml .= $this->_cmdXML(array("n"=>"ev","t"=>$sTarget,"p"=>$sEvent),$sScript);
431
+		$this->xml .= $this->_cmdXML(array("n"=>"ev", "t"=>$sTarget, "p"=>$sEvent), $sScript);
432 432
 	}
433 433
 
434 434
 	/**
@@ -441,9 +441,9 @@  discard block
 block discarded – undo
441 441
 	 * @param string the name of a Javascript function that will handle the
442 442
 	 *               event. Multiple handlers can be added for the same event
443 443
 	 */
444
-	function addHandler($sTarget,$sEvent,$sHandler)
444
+	function addHandler($sTarget, $sEvent, $sHandler)
445 445
 	{
446
-		$this->xml .= $this->_cmdXML(array("n"=>"ah","t"=>$sTarget,"p"=>$sEvent),$sHandler);
446
+		$this->xml .= $this->_cmdXML(array("n"=>"ah", "t"=>$sTarget, "p"=>$sEvent), $sHandler);
447 447
 	}
448 448
 
449 449
 	/**
@@ -457,9 +457,9 @@  discard block
 block discarded – undo
457 457
 	 * @param string the name of a Javascript handler function that you want to
458 458
 	 *               remove
459 459
 	 */
460
-	function addRemoveHandler($sTarget,$sEvent,$sHandler)
460
+	function addRemoveHandler($sTarget, $sEvent, $sHandler)
461 461
 	{
462
-		$this->xml .= $this->_cmdXML(array("n"=>"rh","t"=>$sTarget,"p"=>$sEvent),$sHandler);
462
+		$this->xml .= $this->_cmdXML(array("n"=>"rh", "t"=>$sTarget, "p"=>$sEvent), $sHandler);
463 463
 	}
464 464
 
465 465
 	/**
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
 	 */
472 472
 	function addIncludeScript($sFileName)
473 473
 	{
474
-		$this->xml .= $this->_cmdXML(array("n"=>"in"),$sFileName);
474
+		$this->xml .= $this->_cmdXML(array("n"=>"in"), $sFileName);
475 475
 	}
476 476
 
477 477
 	/**
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
 		$sXML = "<?xml version=\"1.0\"";
490 490
 		if ($this->sEncoding && strlen(trim($this->sEncoding)) > 0)
491 491
 			$sXML .= " encoding=\"".$this->sEncoding."\"";
492
-		$sXML .= " ?"."><xjx>" . $this->xml . "</xjx>";
492
+		$sXML .= " ?"."><xjx>".$this->xml."</xjx>";
493 493
 
494 494
 		return $sXML;
495 495
 	}
@@ -544,9 +544,9 @@  discard block
 block discarded – undo
544 544
 			}
545 545
 		}
546 546
 		$xml = "<cmd";
547
-		foreach($aAttributes as $sAttribute => $sValue)
547
+		foreach ($aAttributes as $sAttribute => $sValue)
548 548
 			$xml .= " $sAttribute=\"$sValue\"";
549
-		if ($sData !== null && !stristr($sData,'<![CDATA['))
549
+		if ($sData !== null && !stristr($sData, '<![CDATA['))
550 550
 			$xml .= "><![CDATA[$sData]]></cmd>";
551 551
 		else if ($sData !== null)
552 552
 			$xml .= ">$sData</cmd>";
@@ -574,8 +574,8 @@  discard block
 block discarded – undo
574 574
 			$data = "<xjxobj>";
575 575
 			foreach ($var as $key => $value) {
576 576
 				$data .= "<e>";
577
-				$data .= "<k>" . htmlspecialchars($key) . "</k>";
578
-				$data .= "<v>" . $this->_buildObjXml($value) . "</v>";
577
+				$data .= "<k>".htmlspecialchars($key)."</k>";
578
+				$data .= "<v>".$this->_buildObjXml($value)."</v>";
579 579
 				$data .= "</e>";
580 580
 			}
581 581
 			$data .= "</xjxobj>";
Please login to merge, or discard this patch.
main/inc/lib/zombie/zombie_report.class.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -121,6 +121,9 @@
 block discarded – undo
121 121
         return $form->isSubmitted() == false || $form->validate();
122 122
     }
123 123
 
124
+    /**
125
+     * @param string $format
126
+     */
124 127
     function get_ceiling($format = null)
125 128
     {
126 129
         $result = Request::get('ceiling');
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -167,7 +167,7 @@  discard block
 block discarded – undo
167 167
         }
168 168
 
169 169
         $action = $this->get_action();
170
-        $f = array($this, 'action_' . $action);
170
+        $f = array($this, 'action_'.$action);
171 171
         if (is_callable($f)) {
172 172
             return call_user_func($f, $ids);
173 173
         }
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
             $text = get_lang('No');
293 293
         }
294 294
 
295
-        $result = Display::return_icon($image . '.png', $text);
295
+        $result = Display::return_icon($image.'.png', $text);
296 296
         return $result;
297 297
     }
298 298
 
Please login to merge, or discard this patch.
main/install/install.lib.php 4 patches
Doc Comments   +14 added lines, -5 removed lines patch added patch discarded remove patch
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
  * This function return the value of a php.ini setting if not "" or if exists,
98 98
  * otherwise return false
99 99
  * @param   string  $phpSetting The name of a PHP setting
100
- * @return  mixed   The value of the setting, or false if not found
100
+ * @return  string|false   The value of the setting, or false if not found
101 101
  */
102 102
 function checkPhpSettingExists($phpSetting)
103 103
 {
@@ -1268,6 +1268,10 @@  discard block
 block discarded – undo
1268 1268
  * @param   string  Extra notice (to show on the right side)
1269 1269
  * @param   boolean Whether to display in update mode
1270 1270
  * @param   string  Additional attribute for the <tr> element
1271
+ * @param string $installType
1272
+ * @param string $parameterName
1273
+ * @param string $formFieldName
1274
+ * @param string $extra_notice
1271 1275
  * @return  void    Direct output
1272 1276
  */
1273 1277
 function displayDatabaseParameter(
@@ -1481,6 +1485,11 @@  discard block
 block discarded – undo
1481 1485
 
1482 1486
     <?php
1483 1487
 }
1488
+/**
1489
+ * @param string $content
1490
+ * @param string $title
1491
+ * @param string $id
1492
+ */
1484 1493
 function panel($content = null, $title = null, $id = null, $style = null) {
1485 1494
     $html = '';
1486 1495
     if (empty($style)) {
@@ -1837,8 +1846,8 @@  discard block
 block discarded – undo
1837 1846
 }
1838 1847
 
1839 1848
 /**
1840
- * @param $current_value
1841
- * @param $wanted_value
1849
+ * @param string $current_value
1850
+ * @param string $wanted_value
1842 1851
  * @return string
1843 1852
  */
1844 1853
 function compare_setting_values($current_value, $wanted_value)
@@ -1855,8 +1864,8 @@  discard block
 block discarded – undo
1855 1864
 }
1856 1865
 
1857 1866
 /**
1858
- * @param $course_dir
1859
- * @param $course_attempt_name
1867
+ * @param string $course_dir
1868
+ * @param string $course_attempt_name
1860 1869
  * @param string $file
1861 1870
  * @return bool
1862 1871
  */
Please login to merge, or discard this patch.
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
     if (!is_array($result)) {
397 397
         $result = array();
398 398
         $exceptions = array('.', '..', 'CVS', '.svn');
399
-        $search       = array('_latin',   '_unicode',   '_corporate',   '_org'  , '_KM',   '_');
399
+        $search       = array('_latin', '_unicode', '_corporate', '_org', '_KM', '_');
400 400
         $replace_with = array(' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' ');
401 401
         $dirname = api_get_path(SYS_LANG_PATH);
402 402
         $handle = opendir($dirname);
@@ -430,9 +430,9 @@  discard block
 block discarded – undo
430 430
     if ($handle = opendir($directory)) {
431 431
         while (false !== ($file = readdir($handle))) {
432 432
             if ($file != "." && $file != "..") {
433
-                if (is_dir($directory. "/" . $file)) {
434
-                    $array_items = array_merge($array_items, my_directory_to_array($directory. '/' . $file));
435
-                    $file = $directory . "/" . $file;
433
+                if (is_dir($directory."/".$file)) {
434
+                    $array_items = array_merge($array_items, my_directory_to_array($directory.'/'.$file));
435
+                    $file = $directory."/".$file;
436 436
                     $array_items[] = preg_replace("/\/\//si", '/', $file);
437 437
                 }
438 438
             }
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
     <h2><?php get_lang('WelcomeToTheChamiloInstaller'); ?></h2>
637 637
     <div class="RequirementHeading">
638 638
         <h2><?php echo display_step_sequence(); ?>
639
-            <?php echo get_lang('InstallationLanguage');?>
639
+            <?php echo get_lang('InstallationLanguage'); ?>
640 640
         </h2>
641 641
         <p><?php echo get_lang('PleaseSelectInstallationProcessLanguage'); ?>:</p>
642 642
         <form id="lang_form" method="post" action="<?php echo api_get_self(); ?>">
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
     if (phpversion() < REQUIRED_PHP_VERSION) {
710 710
         echo '<strong><font color="red">'.get_lang('PHPVersionError').'</font></strong>';
711 711
     } else {
712
-        echo '<strong><font color="green">'.get_lang('PHPVersionOK'). ' '.phpversion().'</font></strong>';
712
+        echo '<strong><font color="green">'.get_lang('PHPVersionOK').' '.phpversion().'</font></strong>';
713 713
     }
714 714
     echo '</td>
715 715
             </tr>
@@ -881,7 +881,7 @@  discard block
 block discarded – undo
881 881
             if ($file_course_test_was_created == true) {
882 882
                 break;
883 883
             }
884
-            $r = @touch($course_dir.'/test.php',$perm);
884
+            $r = @touch($course_dir.'/test.php', $perm);
885 885
             if ($r === true) {
886 886
                 $fil_perm_verified = $perm;
887 887
                 if (check_course_script_interpretation($course_dir, $course_attempt_name, 'test.php')) {
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 function get_contact_registration_form()
1138 1138
 {
1139 1139
 
1140
-    $html ='
1140
+    $html = '
1141 1141
    <form class="form-horizontal">
1142 1142
     <div class="panel panel-default">
1143 1143
     <div class="panel-body">
@@ -1234,7 +1234,7 @@  discard block
 block discarded – undo
1234 1234
             <div class="col-sm-9">
1235 1235
                 <div class="radio">
1236 1236
                     <label>
1237
-                        <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes') . '
1237
+                        <input type="radio" name="financial_decision" id="financial_decision1" value="1" checked /> ' . get_lang('Yes').'
1238 1238
                     </label>
1239 1239
                 </div>
1240 1240
                 <div class="radio">
@@ -1293,8 +1293,8 @@  discard block
 block discarded – undo
1293 1293
             echo '<input type="hidden" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />';
1294 1294
             echo api_htmlentities($parameterValue);
1295 1295
         } else {
1296
-            echo '<div class="col-sm-5"><input type="' . $inputType . '" class="form-control" size="' . DATABASE_FORM_FIELD_DISPLAY_LENGTH . '" maxlength="' . $maxLength . '" name="' . $formFieldName . '" id="' . $formFieldName . '" value="' . api_htmlentities($parameterValue) . '" />' . "</div>";
1297
-            echo '<div class="col-sm-3">' . $extra_notice . '</div>';
1296
+            echo '<div class="col-sm-5"><input type="'.$inputType.'" class="form-control" size="'.DATABASE_FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.$maxLength.'" name="'.$formFieldName.'" id="'.$formFieldName.'" value="'.api_htmlentities($parameterValue).'" />'."</div>";
1297
+            echo '<div class="col-sm-3">'.$extra_notice.'</div>';
1298 1298
         }
1299 1299
 
1300 1300
     }
@@ -1330,12 +1330,12 @@  discard block
 block discarded – undo
1330 1330
         $dbNameForm = $_configuration['main_database'];
1331 1331
         $dbPortForm = isset($_configuration['db_port']) ? $_configuration['db_port'] : '';
1332 1332
 
1333
-        echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
1333
+        echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
1334 1334
         echo '<div class="RequirementContent">';
1335 1335
         echo get_lang('DBSettingUpgradeIntro');
1336 1336
         echo '</div>';
1337 1337
     } else {
1338
-        echo '<div class="RequirementHeading"><h2>' . display_step_sequence() .get_lang('DBSetting') . '</h2></div>';
1338
+        echo '<div class="RequirementHeading"><h2>'.display_step_sequence().get_lang('DBSetting').'</h2></div>';
1339 1339
         echo '<div class="RequirementContent">';
1340 1340
         echo get_lang('DBSettingIntro');
1341 1341
         echo '</div>';
@@ -1345,12 +1345,12 @@  discard block
 block discarded – undo
1345 1345
         <div class="panel-body">
1346 1346
         <div class="form-group">
1347 1347
             <label class="col-sm-4"><?php echo get_lang('DBHost'); ?> </label>
1348
-            <?php if ($installType == 'update'){ ?>
1348
+            <?php if ($installType == 'update') { ?>
1349 1349
             <div class="col-sm-5">
1350 1350
                 <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?>
1351 1351
             </div>
1352 1352
             <div class="col-sm-3"></div>
1353
-            <?php }else{ ?>
1353
+            <?php } else { ?>
1354 1354
             <div class="col-sm-5">
1355 1355
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
1356 1356
             </div>
@@ -1359,12 +1359,12 @@  discard block
 block discarded – undo
1359 1359
         </div>
1360 1360
         <div class="form-group">
1361 1361
             <label class="col-sm-4"><?php echo get_lang('DBPort'); ?> </label>
1362
-            <?php if ($installType == 'update'){ ?>
1362
+            <?php if ($installType == 'update') { ?>
1363 1363
             <div class="col-sm-5">
1364 1364
                 <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?>
1365 1365
             </div>
1366 1366
             <div class="col-sm-3"></div>
1367
-            <?php }else{ ?>
1367
+            <?php } else { ?>
1368 1368
             <div class="col-sm-5">
1369 1369
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" />
1370 1370
             </div>
@@ -1390,7 +1390,7 @@  discard block
 block discarded – undo
1390 1390
             <?php
1391 1391
             //Database Name fix replace weird chars
1392 1392
             if ($installType != INSTALL_TYPE_UPDATE) {
1393
-                $dbNameForm = str_replace(array('-','*', '$', ' ', '.'), '', $dbNameForm);
1393
+                $dbNameForm = str_replace(array('-', '*', '$', ' ', '.'), '', $dbNameForm);
1394 1394
             }
1395 1395
 
1396 1396
             displayDatabaseParameter(
@@ -1489,7 +1489,7 @@  discard block
 block discarded – undo
1489 1489
     if (!empty($title)) {
1490 1490
         $panelTitle = Display::div($title, array('class' => 'panel-heading'));
1491 1491
         $panelBody = Display::div($content, array('class' => 'panel-body'));
1492
-        $panelParent = Display::div($panelTitle . $panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
1492
+        $panelParent = Display::div($panelTitle.$panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
1493 1493
     } else {
1494 1494
         $panelBody = Display::div($html, array('class' => 'panel-body'));
1495 1495
         $panelParent = Display::div($panelBody, array('id' => $id, 'class' => 'panel panel-'.$style));
@@ -1514,9 +1514,9 @@  discard block
 block discarded – undo
1514 1514
     $displayWhenUpdate = 'true'
1515 1515
 ) {
1516 1516
     $html = '<div class="form-group">';
1517
-    $html .= '<label class="col-sm-6 control-label">' . $parameterName . '</label>';
1517
+    $html .= '<label class="col-sm-6 control-label">'.$parameterName.'</label>';
1518 1518
     if ($installType == INSTALL_TYPE_UPDATE && $displayWhenUpdate) {
1519
-        $html .= '<input type="hidden" name="' . $formFieldName . '" value="'. api_htmlentities($parameterValue, ENT_QUOTES). '" />' . $parameterValue;
1519
+        $html .= '<input type="hidden" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'.$parameterValue;
1520 1520
     } else {
1521 1521
         $html .= '<div class="col-sm-6"><input class="form-control" type="text" size="'.FORM_FIELD_DISPLAY_LENGTH.'" maxlength="'.MAX_FORM_FIELD_LENGTH.'" name="'.$formFieldName.'" value="'.api_htmlentities($parameterValue, ENT_QUOTES).'" />'."</div>";
1522 1522
     }
@@ -1563,7 +1563,7 @@  discard block
 block discarded – undo
1563 1563
         $languageForm = $_SESSION['install_language'];
1564 1564
     }
1565 1565
     echo '<div class="RequirementHeading">';
1566
-    echo "<h2>" . display_step_sequence() . get_lang("CfgSetting") . "</h2>";
1566
+    echo "<h2>".display_step_sequence().get_lang("CfgSetting")."</h2>";
1567 1567
     echo '</div>';
1568 1568
 
1569 1569
     echo '<p>'.get_lang('ConfigSettingsInfo').' <strong>app/config/configuration.php</strong></p>';
@@ -1581,14 +1581,14 @@  discard block
 block discarded – undo
1581 1581
 
1582 1582
     // Parameters 3 and 4: administrator's names
1583 1583
 
1584
-    $html .=  display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
1585
-    $html .=  display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
1584
+    $html .= display_configuration_parameter($installType, get_lang('AdminFirstName'), 'adminFirstName', $adminFirstName);
1585
+    $html .= display_configuration_parameter($installType, get_lang('AdminLastName'), 'adminLastName', $adminLastName);
1586 1586
 
1587 1587
     //Parameter 3: administrator's email
1588
-    $html .=  display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
1588
+    $html .= display_configuration_parameter($installType, get_lang('AdminEmail'), 'emailForm', $emailForm);
1589 1589
 
1590 1590
     //Parameter 6: administrator's telephone
1591
-    $html .=  display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
1591
+    $html .= display_configuration_parameter($installType, get_lang('AdminPhone'), 'adminPhoneForm', $adminPhoneForm);
1592 1592
 
1593 1593
 
1594 1594
     echo panel($html, get_lang('Administrator'), 'administrator');
@@ -1607,12 +1607,12 @@  discard block
 block discarded – undo
1607 1607
         $html .= display_language_selection_box('languageForm', $languageForm);
1608 1608
         $html .= '</div>';
1609 1609
     }
1610
-    $html.= "</div>";
1610
+    $html .= "</div>";
1611 1611
 
1612 1612
 
1613 1613
     //Second parameter: Chamilo URL
1614 1614
     $html .= '<div class="form-group">';
1615
-    $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL') .get_lang('ThisFieldIsRequired').'</label>';
1615
+    $html .= '<label class="col-sm-6 control-label">'.get_lang('ChamiloURL').get_lang('ThisFieldIsRequired').'</label>';
1616 1616
 
1617 1617
 
1618 1618
 
@@ -1636,34 +1636,34 @@  discard block
 block discarded – undo
1636 1636
 
1637 1637
 
1638 1638
     $html .= '<div class="form-group">
1639
-            <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass") . '</label>
1639
+            <label class="col-sm-6 control-label">' . get_lang("EncryptMethodUserPass").'</label>
1640 1640
         <div class="col-sm-6">';
1641 1641
     if ($installType == 'update') {
1642
-        $html .= '<input type="hidden" name="encryptPassForm" value="'. $encryptPassForm .'" />'. $encryptPassForm;
1642
+        $html .= '<input type="hidden" name="encryptPassForm" value="'.$encryptPassForm.'" />'.$encryptPassForm;
1643 1643
     } else {
1644 1644
 
1645 1645
         $html .= '<div class="checkbox">
1646 1646
                     <label>
1647
-                        <input  type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ':'') .'/> bcrypt
1647
+                        <input  type="radio" name="encryptPassForm" value="bcrypt" id="encryptPass1" '. ($encryptPassForm == 'bcrypt' ? 'checked="checked" ' : '').'/> bcrypt
1648 1648
                     </label>';
1649 1649
 
1650 1650
         $html .= '<label>
1651
-                        <input  type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ':'') .'/> sha1
1651
+                        <input  type="radio" name="encryptPassForm" value="sha1" id="encryptPass1" '. ($encryptPassForm == 'sha1' ? 'checked="checked" ' : '').'/> sha1
1652 1652
                     </label>';
1653 1653
 
1654 1654
         $html .= '<label>
1655
-                        <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ':'') .'/> md5
1655
+                        <input type="radio" name="encryptPassForm" value="md5" id="encryptPass0" '. ($encryptPassForm == 'md5' ? 'checked="checked" ' : '').'/> md5
1656 1656
                     </label>';
1657 1657
 
1658 1658
         $html .= '<label>
1659
-                        <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ':'') .'/>'. get_lang('None').'
1659
+                        <input type="radio" name="encryptPassForm" value="none" id="encryptPass2" '. ($encryptPassForm == 'none' ? 'checked="checked" ' : '').'/>'.get_lang('None').'
1660 1660
                     </label>';
1661 1661
         $html .= '</div>';
1662 1662
     }
1663 1663
     $html .= '</div></div>';
1664 1664
 
1665 1665
     $html .= '<div class="form-group">
1666
-            <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg') . '</label>
1666
+            <label class="col-sm-6 control-label">' . get_lang('AllowSelfReg').'</label>
1667 1667
             <div class="col-sm-6">';
1668 1668
     if ($installType == 'update') {
1669 1669
         if ($allowSelfReg == 'true') {
@@ -1673,17 +1673,17 @@  discard block
 block discarded – undo
1673 1673
         } else {
1674 1674
             $label = get_lang('AfterApproval');
1675 1675
         }
1676
-        $html .= '<input type="hidden" name="allowSelfReg" value="'. $allowSelfReg .'" />'. $label;
1676
+        $html .= '<input type="hidden" name="allowSelfReg" value="'.$allowSelfReg.'" />'.$label;
1677 1677
     } else {
1678 1678
         $html .= '<div class="control-group">';
1679 1679
         $html .= '<label class="checkbox-inline">
1680
-                        <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '') . ' /> '. get_lang('Yes') .'
1680
+                        <input type="radio" name="allowSelfReg" value="1" id="allowSelfReg1" '. ($allowSelfReg == 'true' ? 'checked="checked" ' : '').' /> '.get_lang('Yes').'
1681 1681
                     </label>';
1682 1682
         $html .= '<label class="checkbox-inline">
1683
-                        <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .'
1683
+                        <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ').' /> '.get_lang('No').'
1684 1684
                     </label>';
1685 1685
          $html .= '<label class="checkbox-inline">
1686
-                    <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .'
1686
+                    <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ').' /> '.get_lang('AfterApproval').'
1687 1687
                 </label>';
1688 1688
         $html .= '</div>';
1689 1689
     }
@@ -1691,7 +1691,7 @@  discard block
 block discarded – undo
1691 1691
     $html .= '</div>';
1692 1692
 
1693 1693
     $html .= '<div class="form-group">';
1694
-    $html .= '<label class="col-sm-6 control-label">'. get_lang('AllowSelfRegProf') .'</label>
1694
+    $html .= '<label class="col-sm-6 control-label">'.get_lang('AllowSelfRegProf').'</label>
1695 1695
         <div class="col-sm-6">';
1696 1696
     if ($installType == 'update') {
1697 1697
         if ($allowSelfRegProf == 'true') {
@@ -1699,16 +1699,16 @@  discard block
 block discarded – undo
1699 1699
         } else {
1700 1700
             $label = get_lang('No');
1701 1701
         }
1702
-        $html .= '<input type="hidden" name="allowSelfRegProf" value="'. $allowSelfRegProf.'" />'. $label;
1702
+        $html .= '<input type="hidden" name="allowSelfRegProf" value="'.$allowSelfRegProf.'" />'.$label;
1703 1703
     } else {
1704 1704
         $html .= '<div class="control-group">
1705 1705
                 <label class="checkbox-inline">
1706
-                    <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '') .'/>
1707
-                ' . get_lang('Yes') .'
1706
+                    <input type="radio" name="allowSelfRegProf" value="1" id="allowSelfRegProf1" '. ($allowSelfRegProf ? 'checked="checked" ' : '').'/>
1707
+                ' . get_lang('Yes').'
1708 1708
                 </label>';
1709 1709
         $html .= '<label class="checkbox-inline">
1710
-                    <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ') .' />
1711
-                   '. get_lang('No') .'
1710
+                    <input type="radio" name="allowSelfRegProf" value="0" id="allowSelfRegProf0" '. ($allowSelfRegProf ? '' : 'checked="checked" ').' />
1711
+                   '. get_lang('No').'
1712 1712
                 </label>';
1713 1713
         $html .= '</div>';
1714 1714
     }
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
         "Macedonia", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Mauritania", "Mauritius", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Morocco", "Mozambique", "Myanmar",
1774 1774
         "Namibia", "Nauru", "Nepa", "Netherlands", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Norway",
1775 1775
         "Oman",
1776
-        "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland","Portugal",
1776
+        "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Poland", "Portugal",
1777 1777
         "Qatar",
1778 1778
         "Romania", "Russia", "Rwanda",
1779 1779
         "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent", "Samoa", "San Marino", "Sao Tome and Principe", "Saudi Arabia", "Senegal", "Serbia and Montenegro", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "Spain", "Sri Lanka", "Sudan", "Suriname", "Swaziland", "Sweden", "Switzerland", "Syria",
@@ -1820,11 +1820,11 @@  discard block
 block discarded – undo
1820 1820
     $permissions_for_new_directories = isset($_SESSION['permissions_for_new_directories']) ? $_SESSION['permissions_for_new_directories'] : 0770;
1821 1821
     $permissions_for_new_files = isset($_SESSION['permissions_for_new_files']) ? $_SESSION['permissions_for_new_files'] : 0660;
1822 1822
     // use decoct() to store as string
1823
-    $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_directories) . "'
1823
+    $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_directories)."'
1824 1824
               WHERE variable  = 'permissions_for_new_directories'";
1825 1825
     Database::query($sql);
1826 1826
 
1827
-    $sql = "UPDATE $table SET selected_value = '0" . decoct($permissions_for_new_files) . "' WHERE variable  = 'permissions_for_new_files'";
1827
+    $sql = "UPDATE $table SET selected_value = '0".decoct($permissions_for_new_files)."' WHERE variable  = 'permissions_for_new_files'";
1828 1828
     Database::query($sql);
1829 1829
 
1830 1830
     if (isset($_SESSION['permissions_for_new_directories'])) {
@@ -1844,8 +1844,8 @@  discard block
 block discarded – undo
1844 1844
 function compare_setting_values($current_value, $wanted_value)
1845 1845
 {
1846 1846
     $current_value_string = $current_value;
1847
-    $current_value = (float)$current_value;
1848
-    $wanted_value = (float)$wanted_value;
1847
+    $current_value = (float) $current_value;
1848
+    $wanted_value = (float) $wanted_value;
1849 1849
 
1850 1850
     if ($current_value >= $wanted_value) {
1851 1851
         return Display::label($current_value_string, 'success');
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 
1897 1897
                     fwrite($fp, $out);
1898 1898
                     while (!feof($fp)) {
1899
-                        $result = str_replace("\r\n", '',fgets($fp, 128));
1899
+                        $result = str_replace("\r\n", '', fgets($fp, 128));
1900 1900
                         if (!empty($result) && $result == '123') {
1901 1901
                             $output = true;
1902 1902
                         }
@@ -1919,7 +1919,7 @@  discard block
 block discarded – undo
1919 1919
                     curl_setopt($ch, CURLOPT_URL, $url);
1920 1920
                     //curl_setopt($ch, CURLOPT_TIMEOUT, 30);
1921 1921
                     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
1922
-                    $result = curl_exec ($ch);
1922
+                    $result = curl_exec($ch);
1923 1923
                     if (!empty($result) && $result == '123') {
1924 1924
                         $output = true;
1925 1925
                     }
@@ -2679,12 +2679,12 @@  discard block
 block discarded – undo
2679 2679
         $adminPhoneForm,
2680 2680
         '', //$picture_uri = '',
2681 2681
         PLATFORM_AUTH_SOURCE,
2682
-        '',//$expirationDate,
2682
+        '', //$expirationDate,
2683 2683
         1,
2684 2684
         0,
2685 2685
         null,
2686 2686
         '',
2687
-        false,  //$send_mail = false,
2687
+        false, //$send_mail = false,
2688 2688
         true //$isAdmin = false
2689 2689
     );
2690 2690
 
@@ -2706,7 +2706,7 @@  discard block
 block discarded – undo
2706 2706
         0,
2707 2707
         null,
2708 2708
         '',
2709
-        false,  //$send_mail = false,
2709
+        false, //$send_mail = false,
2710 2710
         false //$isAdmin = false
2711 2711
     );
2712 2712
 
@@ -2772,7 +2772,7 @@  discard block
 block discarded – undo
2772 2772
                 SET selected_value = '".$param->selected_value."'
2773 2773
                 WHERE variable = '".$param->variable."'";
2774 2774
         if (!empty($param->subkey)) {
2775
-            $sql .= " AND subkey='" . $param->subkey . "'";
2775
+            $sql .= " AND subkey='".$param->subkey."'";
2776 2776
         }
2777 2777
         Database::query($sql);
2778 2778
     }
Please login to merge, or discard this patch.
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1682,7 +1682,7 @@  discard block
 block discarded – undo
1682 1682
         $html .= '<label class="checkbox-inline">
1683 1683
                         <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'false' ? '' : 'checked="checked" ') .' /> '. get_lang('No') .'
1684 1684
                     </label>';
1685
-         $html .= '<label class="checkbox-inline">
1685
+            $html .= '<label class="checkbox-inline">
1686 1686
                     <input type="radio" name="allowSelfReg" value="0" id="allowSelfReg0" '. ($allowSelfReg == 'approval' ? '' : 'checked="checked" ') .' /> '. get_lang('AfterApproval') .'
1687 1687
                 </label>';
1688 1688
         $html .= '</div>';
@@ -1716,7 +1716,7 @@  discard block
 block discarded – undo
1716 1716
     </div>';
1717 1717
 
1718 1718
     echo panel($html, get_lang('Platform'), 'platform');
1719
- ?>
1719
+    ?>
1720 1720
     <div class='form-group'>
1721 1721
         <div class="col-sm-6">
1722 1722
             <button type="submit" class="btn btn-default pull-right" name="step3" value="&lt; <?php echo get_lang('Previous'); ?>" ><em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?></button>
Please login to merge, or discard this patch.
Braces   +15 added lines, -8 removed lines patch added patch discarded remove patch
@@ -973,8 +973,7 @@  discard block
 block discarded – undo
973 973
                 <?php echo get_lang('Error'); ?>!<br />
974 974
                 Chamilo <?php echo implode('|', $update_from_version_8).' '.get_lang('HasNotBeenFoundInThatDir'); ?>.
975 975
             </div>
976
-        <?php }
977
-        else {
976
+        <?php } else {
978 977
             echo '<br />';
979 978
         }
980 979
         ?>
@@ -1060,14 +1059,19 @@  discard block
 block discarded – undo
1060 1059
         <button type="submit" name="step1" class="btn btn-default" onclick="javascript: window.location='index.php'; return false;" value="<?php echo get_lang('Previous'); ?>" >
1061 1060
             <em class="fa fa-backward"> </em> <?php echo get_lang('Previous'); ?>
1062 1061
         </button>
1063
-        <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) echo 'disabled="disabled"'; ?> >
1062
+        <button type="submit" name="step2_install" class="btn btn-success" value="<?php echo get_lang("NewInstallation"); ?>" <?php if ($error) {
1063
+    echo 'disabled="disabled"';
1064
+}
1065
+?> >
1064 1066
             <em class="fa fa-forward"> </em> <?php echo get_lang('NewInstallation'); ?>
1065 1067
         </button>
1066 1068
         <input type="hidden" name="is_executable" id="is_executable" value="-" />
1067 1069
         <?php
1068 1070
         // Real code
1069 1071
         echo '<button type="submit" class="btn btn-default" name="step2_update_8" value="Upgrade from Chamilo 1.9.x"';
1070
-        if ($error) echo ' disabled="disabled"';
1072
+        if ($error) {
1073
+            echo ' disabled="disabled"';
1074
+        }
1071 1075
         echo ' ><em class="fa fa-forward"> </em> '.get_lang('UpgradeFromLMS19x').'</button>';
1072 1076
 
1073 1077
         echo '</p>';
@@ -1350,7 +1354,7 @@  discard block
 block discarded – undo
1350 1354
                 <input type="hidden" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" /><?php echo $dbHostForm; ?>
1351 1355
             </div>
1352 1356
             <div class="col-sm-3"></div>
1353
-            <?php }else{ ?>
1357
+            <?php } else{ ?>
1354 1358
             <div class="col-sm-5">
1355 1359
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbHostForm" value="<?php echo htmlentities($dbHostForm); ?>" />
1356 1360
             </div>
@@ -1364,7 +1368,7 @@  discard block
 block discarded – undo
1364 1368
                 <input type="hidden" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" /><?php echo $dbPortForm; ?>
1365 1369
             </div>
1366 1370
             <div class="col-sm-3"></div>
1367
-            <?php }else{ ?>
1371
+            <?php } else{ ?>
1368 1372
             <div class="col-sm-5">
1369 1373
                 <input type="text" class="form-control" size="25" maxlength="50" name="dbPortForm" value="<?php echo htmlentities($dbPortForm); ?>" />
1370 1374
             </div>
@@ -1446,9 +1450,12 @@  discard block
 block discarded – undo
1446 1450
             Database port: <strong><?php echo $manager->getConnection()->getPort(); ?></strong><br/>
1447 1451
             Database driver: <strong><?php echo $manager->getConnection()->getDriver()->getName(); ?></strong><br/>
1448 1452
         </div>
1449
-    <?php else: ?>
1453
+    <?php else {
1454
+    : ?>
1450 1455
         <div id="db_status" class="alert alert-danger">
1451
-            <p><?php echo get_lang('FailedConectionDatabase'); ?></strong></p>
1456
+            <p><?php echo get_lang('FailedConectionDatabase');
1457
+}
1458
+?></strong></p>
1452 1459
             <code><?php echo $database_exists_text ?></code>
1453 1460
         </div>
1454 1461
     <?php endif; ?>
Please login to merge, or discard this patch.
main/newscorm/aicc.class.php 4 patches
Doc Comments   +5 added lines, -3 removed lines patch added patch discarded remove patch
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
     /**
217 217
      * Import the aicc object (as a result from the parse_config_files function) into the database structure
218 218
      * @param	string	$course_code
219
-     * @return	bool	Returns -1 on error
219
+     * @return	false|null	Returns -1 on error
220 220
      */
221 221
     public function import_aicc($course_code)
222 222
     {
@@ -780,7 +780,8 @@  discard block
 block discarded – undo
780 780
      * Static function to parse AICC ini files.
781 781
      * Based on work by sinedeo at gmail dot com published on php.net (parse_ini_file()).
782 782
      * @param	string	File path
783
-     * @return	array	Structured array
783
+     * @param string $f
784
+     * @return	string	Structured array
784 785
      */
785 786
     function parse_ini_file_quotes_safe($f) {
786 787
         $null = '';
@@ -831,7 +832,7 @@  discard block
 block discarded – undo
831 832
      * Based on work by sinedeo at gmail dot com published on php.net (parse_ini_file()).
832 833
      * @param		string	INI File string
833 834
      * @param		array	List of names of sections that should be considered as containing only hard string data (no variables), provided in lower case
834
-     * @return	array	Structured array
835
+     * @return	string	Structured array
835 836
      */
836 837
     function parse_ini_string_quotes_safe($s, $pure_strings = array()) {
837 838
         $null = '';
@@ -894,6 +895,7 @@  discard block
 block discarded – undo
894 895
      * @param	string	CSV delimiter
895 896
      * @param	string	CSV enclosure
896 897
      * @param	boolean	Might one field name happen more than once on the same line? (then split by comma in the values)
898
+     * @param string $f
897 899
      * @return array	Simple structured array
898 900
      */
899 901
     function parse_csv_file($f, $delim = ',', $enclosure = '"', $multiples = false) {
Please login to merge, or discard this patch.
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -320,12 +320,12 @@  discard block
 block discarded – undo
320 320
         }
321 321
     }
322 322
 
323
-     /**
324
-     * Intermediate to import_package only to allow import from local zip files
325
-     * @param	string	Path to the zip file, from the dokeos sys root
326
-     * @param	string	Current path (optional)
327
-     * @return string	Absolute path to the AICC description files or empty string on error
328
-     */
323
+        /**
324
+         * Intermediate to import_package only to allow import from local zip files
325
+         * @param	string	Path to the zip file, from the dokeos sys root
326
+         * @param	string	Current path (optional)
327
+         * @return string	Absolute path to the AICC description files or empty string on error
328
+         */
329 329
     function import_local_package($file_path, $current_dir = '')
330 330
     {
331 331
         // TODO: Prepare info as given by the $_FILES[''] vector.
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
         $current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/
356 356
         if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir, 0); }
357 357
 
358
-         //$uploaded_filename = $_FILES['userFile']['name'];
358
+            //$uploaded_filename = $_FILES['userFile']['name'];
359 359
         // Get the name of the zip file without the extension.
360 360
         if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Received zip file name: '.$zip_file_path, 0); }
361 361
         $file_info = pathinfo($zip_file_name);
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 class aicc extends learnpath
13 13
 {
14 14
     public $config = array();
15
-    public $config_basename = '';	// The configuration files might be multiple and might have
15
+    public $config_basename = ''; // The configuration files might be multiple and might have
16 16
                                     // funny names. We need to keep the name of that file while we
17 17
                                     // install the content.
18 18
     public $config_files = array();
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
     public $cstlist = array();
33 33
     public $orelist = array();
34 34
 
35
-    public $subdir = '';	// Path between the scorm/ directory and the config files e.g. maritime_nav/maritime_nav. This is the path that will be used in the lp_path when importing a package.
36
-    public $zipname = '';	// Keeps the zipfile safe for the object's life so that we can use it if there is no title available.
37
-    public $lastzipnameindex = 0;	// Keeps an index of the number of uses of the zipname so far.
35
+    public $subdir = ''; // Path between the scorm/ directory and the config files e.g. maritime_nav/maritime_nav. This is the path that will be used in the lp_path when importing a package.
36
+    public $zipname = ''; // Keeps the zipfile safe for the object's life so that we can use it if there is no title available.
37
+    public $lastzipnameindex = 0; // Keeps an index of the number of uses of the zipname so far.
38 38
     public $config_encoding = 'ISO-8859-1';
39 39
     public $debug = 0;
40 40
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
             //echo '<pre>des:'.print_r($des_params, true).'</pre>';
133 133
             if ($this->debug > 1) { error_log('New LP - In aicc::parse_config_files() - '.$des_file.' has been parsed', 0); }
134 134
             // Distribute des params into the aicc object.
135
-            foreach ($des_params as $des){
135
+            foreach ($des_params as $des) {
136 136
                 // One AU in AICC is equivalent to one SCO in SCORM (scormItem class).
137 137
                 $oDes = new aiccResource('config', $des);
138 138
                 $this->deslist[$oDes->identifier] = $oDes;
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
 
243 243
         $this->config_encoding = "ISO-8859-1"; // TODO: We may apply detection for this value, see the function api_detect_encoding().
244 244
 
245
-        $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib, content_maker,display_order)" .
246
-                "VALUES " .
247
-                "($course_id, 3, '".$this->course_title."', '".$this->course_id."','".$this->course_description."'," .
248
-                "'".$this->subdir."', 0, 'embedded', '".$this->config_encoding."'," .
245
+        $sql = "INSERT INTO $new_lp (c_id, lp_type, name, ref, description, path, force_commit, default_view_mod, default_encoding, js_lib, content_maker,display_order)".
246
+                "VALUES ".
247
+                "($course_id, 3, '".$this->course_title."', '".$this->course_id."','".$this->course_description."',".
248
+                "'".$this->subdir."', 0, 'embedded', '".$this->config_encoding."',".
249 249
                 "'aicc_api.php','".$this->course_creator."',$dsp)";
250
-        if ($this->debug > 2) { error_log('New LP - In import_aicc(), inserting path: '. $sql, 0); }
250
+        if ($this->debug > 2) { error_log('New LP - In import_aicc(), inserting path: '.$sql, 0); }
251 251
         Database::query($sql);
252 252
         $lp_id = Database::insert_id();
253 253
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
         $previous = 0;
278 278
         foreach ($this->aulist as $identifier => $dummy) {
279
-            $oAu =& $this->aulist[$identifier];
279
+            $oAu = & $this->aulist[$identifier];
280 280
             //echo "Item ".$oAu->identifier;
281 281
             $field_add = '';
282 282
             $value_add = '';
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
             $parent = 0; // TODO: Deal with the parent.
295 295
             $previous = 0;
296 296
             $prereq = $oAu->prereq_string;
297
-            $sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,parameters) " .
298
-                    "VALUES " .
299
-                    "($course_id, $lp_id, 'au','".$oAu->identifier."','".$title."'," .
300
-                    "'$path',0,100, $value_add" .
301
-                    "$parent, $previous, 0, " .
302
-                    "'$prereq', 0,'".(!empty($oAu->parameters)?Database::escape_string($oAu->parameters):'')."'" .
297
+            $sql_item = "INSERT INTO $new_lp_item (c_id, lp_id,item_type,ref,title, path,min_score,max_score, $field_add parent_item_id,previous_item_id,next_item_id, prerequisite,display_order,parameters) ".
298
+                    "VALUES ".
299
+                    "($course_id, $lp_id, 'au','".$oAu->identifier."','".$title."',".
300
+                    "'$path',0,100, $value_add".
301
+                    "$parent, $previous, 0, ".
302
+                    "'$prereq', 0,'".(!empty($oAu->parameters) ? Database::escape_string($oAu->parameters) : '')."'".
303 303
                     ")";
304 304
             Database::query($sql_item);
305 305
             if ($this->debug > 1) { error_log('New LP - In aicc::import_aicc() - inserting item : '.$sql_item.' : ', 0); }
@@ -350,7 +350,7 @@  discard block
 block discarded – undo
350 350
         $zip_file_name = $zip_file_info['name'];
351 351
 
352 352
         if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Zip file path = '.$zip_file_path.', zip file name = '.$zip_file_name, 0); }
353
-        $course_rel_dir  = api_get_course_path().'/scorm'; // Scorm dir web path starting from /courses
353
+        $course_rel_dir = api_get_course_path().'/scorm'; // Scorm dir web path starting from /courses
354 354
         $course_sys_dir = api_get_path(SYS_COURSE_PATH).$course_rel_dir; // The absolute system path of this course.
355 355
         $current_dir = api_replace_dangerous_char(trim($current_dir)); // Current dir we are in, inside scorm/
356 356
         if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Current_dir = '.$current_dir, 0); }
@@ -367,7 +367,7 @@  discard block
 block discarded – undo
367 367
         if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Base file name is : '.$file_base_name, 0); }
368 368
         $new_dir = api_replace_dangerous_char(trim($file_base_name));
369 369
         $this->subdir = $new_dir;
370
-        if($this->debug > 0) { error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0); }
370
+        if ($this->debug > 0) { error_log('New LP - aicc::import_package() - Subdir is first set to : '.$this->subdir, 0); }
371 371
 
372 372
         /*
373 373
         if (check_name_exist($course_sys_dir.$current_dir.'/'.$new_dir)) {
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
                         $subdir_isset = true;
414 414
                     } else {
415 415
                         if (!$subdir_isset) {
416
-                            if (preg_match('?^.*/aicc$?i',dirname($thisContent['filename']))) {
416
+                            if (preg_match('?^.*/aicc$?i', dirname($thisContent['filename']))) {
417 417
                                 //echo "Cutting subdir<br/>";
418 418
                                 $this->subdir .= '/'.substr(dirname($thisContent['filename']), 0, -5);
419 419
                             } else {
@@ -516,7 +516,7 @@  discard block
 block discarded – undo
516 516
                         // TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible!
517 517
                         //$safe_file = api_replace_dangerous_char($file, 'strict');
518 518
                         $find_str = array('\\', '.php', '.phtml');
519
-                        $repl_str = array('/',  '.txt', '.txt');
519
+                        $repl_str = array('/', '.txt', '.txt');
520 520
                         $safe_file = str_replace($find_str, $repl_str, $file);
521 521
 
522 522
                         if ($safe_file != $file) {
@@ -717,7 +717,7 @@  discard block
 block discarded – undo
717 717
         if ($this->debug > 0) { error_log('In aicc::get_res_path('.$id.') method', 0); }
718 718
         $path = '';
719 719
         if (isset($this->resources[$id])) {
720
-            $oRes =& $this->resources[$id];
720
+            $oRes = & $this->resources[$id];
721 721
             $path = @$oRes->get_path();
722 722
         }
723 723
         return $path;
@@ -733,7 +733,7 @@  discard block
 block discarded – undo
733 733
         if ($this->debug > 0) { error_log('In aicc::get_res_type('.$id.') method', 0); }
734 734
         $type = '';
735 735
         if (isset($this->resources[$id])) {
736
-            $oRes =& $this->resources[$id];
736
+            $oRes = & $this->resources[$id];
737 737
             $temptype = $oRes->get_scorm_type();
738 738
             if (!empty($temptype)) {
739 739
                 $type = $temptype;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
      * Gets the default organisation's title
747 747
      * @return	string	The organization's title
748 748
      */
749
-    function get_title(){
749
+    function get_title() {
750 750
         if ($this->debug > 0) { error_log('In aicc::get_title() method', 0); }
751 751
         $title = '';
752 752
         if (isset($this->config['organizations']['default'])) {
@@ -907,7 +907,7 @@  discard block
 block discarded – undo
907 907
             $chr = $data{$i};
908 908
             switch ($chr) {
909 909
                 case $enclosure:
910
-                    if ($enclosed && $data{$i+1} == $enclosure) {
910
+                    if ($enclosed && $data{$i + 1} == $enclosure) {
911 911
                         $fldval .= $chr;
912 912
                         ++$i; // Skip the next character.
913 913
                     } else
@@ -921,7 +921,7 @@  discard block
 block discarded – undo
921 921
                         $fldval .= $chr;
922 922
                     break;
923 923
                 case "\r":
924
-                    if (!$enclosed&&$data{$i+1} == "\n")
924
+                    if (!$enclosed && $data{$i + 1} == "\n")
925 925
                         continue;
926 926
                 case "\n":
927 927
                     if (!$enclosed) {
@@ -932,7 +932,7 @@  discard block
 block discarded – undo
932 932
                         $fldval .= $chr;
933 933
                     break;
934 934
                 case "\\r":
935
-                    if (!$enclosed&&$data{$i+1} == "\\n")
935
+                    if (!$enclosed && $data{$i + 1} == "\\n")
936 936
                         continue;
937 937
                 case "\\n":
938 938
                     if (!$enclosed) {
Please login to merge, or discard this patch.
Braces   +24 added lines, -15 removed lines patch added patch discarded remove patch
@@ -459,11 +459,12 @@  discard block
 block discarded – undo
459 459
             }
460 460
         }
461 461
 
462
-        if ($package_type == '' || !$mandatory)
463
-        // && defined('CHECK_FOR_AICC') && CHECK_FOR_AICC)
462
+        if ($package_type == '' || !$mandatory) {
463
+                // && defined('CHECK_FOR_AICC') && CHECK_FOR_AICC)
464 464
         {
465 465
             return api_failure::set_failure('not_aicc_content');
466 466
         }
467
+        }
467 468
 
468 469
         if (!enough_size($realFileSize, $course_sys_dir, $maxFilledSpace)) {
469 470
             return api_failure::set_failure('not_enough_space');
@@ -511,7 +512,9 @@  discard block
 block discarded – undo
511 512
                     if ($file != '.' && $file != '..') {
512 513
                         $filetype = 'file';
513 514
 
514
-                        if (is_dir($course_sys_dir.$new_dir.$file)) $filetype = 'folder';
515
+                        if (is_dir($course_sys_dir.$new_dir.$file)) {
516
+                            $filetype = 'folder';
517
+                        }
515 518
 
516 519
                         // TODO: RENAMING FILES CAN BE VERY DANGEROUS AICC-WISE, avoid that as much as possible!
517 520
                         //$safe_file = api_replace_dangerous_char($file, 'strict');
@@ -910,37 +913,43 @@  discard block
 block discarded – undo
910 913
                     if ($enclosed && $data{$i+1} == $enclosure) {
911 914
                         $fldval .= $chr;
912 915
                         ++$i; // Skip the next character.
913
-                    } else
914
-                        $enclosed = !$enclosed;
916
+                    } else {
917
+                                            $enclosed = !$enclosed;
918
+                    }
915 919
                     break;
916 920
                 case $delim:
917 921
                     if (!$enclosed) {
918 922
                         $ret_array[$linecount][$fldcount++] = $fldval;
919 923
                         $fldval = '';
920
-                    } else
921
-                        $fldval .= $chr;
924
+                    } else {
925
+                                            $fldval .= $chr;
926
+                    }
922 927
                     break;
923 928
                 case "\r":
924
-                    if (!$enclosed&&$data{$i+1} == "\n")
925
-                        continue;
929
+                    if (!$enclosed&&$data{$i+1} == "\n") {
930
+                                            continue;
931
+                    }
926 932
                 case "\n":
927 933
                     if (!$enclosed) {
928 934
                         $ret_array[$linecount++][$fldcount] = $fldval;
929 935
                         $fldcount = 0;
930 936
                         $fldval = '';
931
-                    } else
932
-                        $fldval .= $chr;
937
+                    } else {
938
+                                            $fldval .= $chr;
939
+                    }
933 940
                     break;
934 941
                 case "\\r":
935
-                    if (!$enclosed&&$data{$i+1} == "\\n")
936
-                        continue;
942
+                    if (!$enclosed&&$data{$i+1} == "\\n") {
943
+                                            continue;
944
+                    }
937 945
                 case "\\n":
938 946
                     if (!$enclosed) {
939 947
                         $ret_array[$linecount++][$fldcount] = $fldval;
940 948
                         $fldcount = 0;
941 949
                         $fldval = '';
942
-                    } else
943
-                        $fldval .= $chr;
950
+                    } else {
951
+                                            $fldval .= $chr;
952
+                    }
944 953
                     break;
945 954
                 default:
946 955
                     $fldval .= $chr;
Please login to merge, or discard this patch.
main/newscorm/learnpath_functions.inc.php 1 patch
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -60,6 +60,7 @@
 block discarded – undo
60 60
 /**
61 61
  * This function deletes an entire directory
62 62
  * @param	string	The directory path
63
+ * @param string $dir
63 64
  * @return boolean	True on success, false on failure
64 65
  */
65 66
 function deldir($dir) {
Please login to merge, or discard this patch.
main/newscorm/learnpathItem.class.php 2 patches
Doc Comments   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -1869,7 +1869,7 @@  discard block
 block discarded – undo
1869 1869
 
1870 1870
     /**
1871 1871
      * Get the extra terms (tags) that identify this item
1872
-     * @return mixed
1872
+     * @return string
1873 1873
      */
1874 1874
     public function get_terms()
1875 1875
     {
@@ -2069,7 +2069,7 @@  discard block
 block discarded – undo
2069 2069
 
2070 2070
     /**
2071 2071
      * Opens/launches the item. Initialises runtime values.
2072
-     * @return    boolean    True on success, false on failure.
2072
+     * @return    boolean|null    True on success, false on failure.
2073 2073
      */
2074 2074
     public function open($allow_new_attempt = false)
2075 2075
     {
@@ -3494,7 +3494,7 @@  discard block
 block discarded – undo
3494 3494
 
3495 3495
     /**
3496 3496
      * Checks if the current status is part of the list of status given
3497
-     * @param  array  $list  An array of status to check for.
3497
+     * @param  string[]  $list  An array of status to check for.
3498 3498
      * If the current status is one of the strings, return true
3499 3499
      *
3500 3500
      * @return boolean True if the status was one of the given strings,
@@ -3671,7 +3671,7 @@  discard block
 block discarded – undo
3671 3671
     /**
3672 3672
      * Write objectives to DB. This method is separate from write_to_db() because otherwise
3673 3673
      * objectives are lost as a side effect to AJAX and session concurrent access
3674
-     * @return    boolean        True or false on error
3674
+     * @return    boolean|null        True or false on error
3675 3675
      */
3676 3676
     public function write_objectives_to_db()
3677 3677
     {
@@ -4312,7 +4312,7 @@  discard block
 block discarded – undo
4312 4312
      * Removes the relation between the current item and an audio file. The file
4313 4313
      * is only removed from the lp_item table, but remains in the document table
4314 4314
      * and directory
4315
-     * @return bool
4315
+     * @return false|null
4316 4316
      */
4317 4317
     public function remove_audio()
4318 4318
     {
@@ -4333,7 +4333,7 @@  discard block
 block discarded – undo
4333 4333
      * @param $status
4334 4334
      * @param bool $decorate
4335 4335
      * @param string $type classic|simple
4336
-     * @return array|string
4336
+     * @return string
4337 4337
      */
4338 4338
     static function humanize_status($status, $decorate = true, $type = 'classic')
4339 4339
     {
Please login to merge, or discard this patch.
Spacing   +247 added lines, -247 removed lines patch added patch discarded remove patch
@@ -199,13 +199,13 @@  discard block
 block discarded – undo
199 199
             $res = Database::query($sql);
200 200
             if (Database::num_rows($res) > 0) {
201 201
                 $se_ref = Database::fetch_array($res);
202
-                $this->search_did = (int)$se_ref['search_did'];
202
+                $this->search_did = (int) $se_ref['search_did'];
203 203
             }
204 204
         }
205 205
         $this->audio = $row['audio'];
206 206
         if (self::debug > 0) {
207 207
             error_log(
208
-                'New LP - End of learnpathItem constructor for item ' . $id,
208
+                'New LP - End of learnpathItem constructor for item '.$id,
209 209
                 0
210 210
             );
211 211
         }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
     public function delete()
315 315
     {
316 316
         if (self::debug > 0) {
317
-            error_log('learnpath_item::delete() for item ' . $this->db_id, 0);
317
+            error_log('learnpath_item::delete() for item '.$this->db_id, 0);
318 318
         }
319 319
         $lp_item_view = Database::get_course_table(TABLE_LP_ITEM_VIEW);
320 320
         $lp_item = Database::get_course_table(TABLE_LP_ITEM);
@@ -322,29 +322,29 @@  discard block
 block discarded – undo
322 322
         $course_id = api_get_course_int_id();
323 323
 
324 324
         $sql = "DELETE FROM $lp_item_view
325
-                WHERE c_id = $course_id AND lp_item_id = " . $this->db_id;
325
+                WHERE c_id = $course_id AND lp_item_id = ".$this->db_id;
326 326
         if (self::debug > 0) {
327
-            error_log('Deleting from lp_item_view: ' . $sql, 0);
327
+            error_log('Deleting from lp_item_view: '.$sql, 0);
328 328
         }
329 329
         Database::query($sql);
330 330
 
331 331
         $sql = "SELECT * FROM $lp_item
332
-                WHERE c_id = $course_id AND id = " . $this->db_id;
332
+                WHERE c_id = $course_id AND id = ".$this->db_id;
333 333
         $res_sel = Database::query($sql);
334 334
         if (Database::num_rows($res_sel) < 1) {
335 335
             return false;
336 336
         }
337 337
 
338 338
         $sql = "DELETE FROM $lp_item
339
-                WHERE c_id = $course_id AND id = " . $this->db_id;
339
+                WHERE c_id = $course_id AND id = ".$this->db_id;
340 340
         Database::query($sql);
341 341
         if (self::debug > 0) {
342
-            error_log('Deleting from lp_item: ' . $sql);
342
+            error_log('Deleting from lp_item: '.$sql);
343 343
         }
344 344
 
345 345
         if (api_get_setting('search_enabled') == 'true') {
346 346
             if (!is_null($this->search_did)) {
347
-                require_once api_get_path(LIBRARY_PATH) . 'search/ChamiloIndexer.class.php';
347
+                require_once api_get_path(LIBRARY_PATH).'search/ChamiloIndexer.class.php';
348 348
                 $di = new ChamiloIndexer();
349 349
                 $di->remove_document($this->search_did);
350 350
             }
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
     {
381 381
         if (self::debug > 0) {
382 382
             error_log(
383
-                'learnpathItem::get_attempt_id() on item ' . $this->db_id,
383
+                'learnpathItem::get_attempt_id() on item '.$this->db_id,
384 384
                 0
385 385
             );
386 386
         }
@@ -390,8 +390,8 @@  discard block
 block discarded – undo
390 390
         }
391 391
         if (self::debug > 0) {
392 392
             error_log(
393
-                'New LP - End of learnpathItem::get_attempt_id() on item ' .
394
-                $this->db_id . ' - Returning ' . $res,
393
+                'New LP - End of learnpathItem::get_attempt_id() on item '.
394
+                $this->db_id.' - Returning '.$res,
395 395
                 0
396 396
             );
397 397
         }
@@ -453,12 +453,12 @@  discard block
 block discarded – undo
453 453
             if (self::debug > 2) {
454 454
                 error_log(
455 455
                     'learnpathItem::get_credit() - get_prevent_reinit!=0 and '.
456
-                    'status is ' . $status,
456
+                    'status is '.$status,
457 457
                     0
458 458
                 );
459 459
             }
460 460
             //0=not attempted - 1 = incomplete
461
-            if ($status != $this->possible_status[0]&&
461
+            if ($status != $this->possible_status[0] &&
462 462
                 $status != $this->possible_status[1]
463 463
             ) {
464 464
                 $credit = 'no-credit';
@@ -532,13 +532,13 @@  discard block
 block discarded – undo
532 532
                 case TOOL_DOCUMENT:
533 533
                     $table_doc = Database::get_course_table(TABLE_DOCUMENT);
534 534
                     $sql = 'SELECT path
535
-                            FROM ' . $table_doc . '
535
+                            FROM ' . $table_doc.'
536 536
                             WHERE
537
-                                c_id = ' . $course_id . ' AND
537
+                                c_id = ' . $course_id.' AND
538 538
                                 id = ' . $path;
539 539
                     $res = Database::query($sql);
540 540
                     $row = Database::fetch_array($res);
541
-                    $real_path = 'document' . $row['path'];
541
+                    $real_path = 'document'.$row['path'];
542 542
                     return $real_path;
543 543
                 case TOOL_STUDENTPUBLICATION:
544 544
                 case TOOL_QUIZ:
@@ -550,7 +550,7 @@  discard block
 block discarded – undo
550 550
             }
551 551
         } else {
552 552
             if (!empty($path_to_scorm_dir)) {
553
-                $path = $path_to_scorm_dir . $path;
553
+                $path = $path_to_scorm_dir.$path;
554 554
             }
555 555
             return $path;
556 556
         }
@@ -586,8 +586,8 @@  discard block
 block discarded – undo
586 586
         $sql = "SELECT id FROM $tbl
587 587
                 WHERE
588 588
                     c_id = $course_id AND
589
-                    lp_item_id = " . $this->db_id . " AND
590
-                    lp_view_id = " . $this->view_id . " AND
589
+                    lp_item_id = ".$this->db_id." AND
590
+                    lp_view_id = " . $this->view_id." AND
591 591
                     view_count = " . $this->attempt_id;
592 592
         $res = Database::query($sql);
593 593
         if (Database::num_rows($res) > 0) {
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
             $sql = "SELECT id FROM $tbl
631 631
                     WHERE
632 632
                         c_id = $course_id AND
633
-                        lp_item_id = " . $this->db_id . " AND
634
-                        lp_view_id = " . $this->view_id ." AND
633
+                        lp_item_id = ".$this->db_id." AND
634
+                        lp_view_id = " . $this->view_id." AND
635 635
                         view_count = " . $this->get_attempt_id();
636 636
             $res = Database::query($sql);
637 637
             if (Database::num_rows($res) > 0) {
@@ -671,13 +671,13 @@  discard block
 block discarded – undo
671 671
         foreach ($this->interactions as $id => $in) {
672 672
             $return .= "[
673 673
                 '$id',
674
-                '" . $in[1] . "',
675
-                '" . $in[2] . "',
676
-                '" . $in[3] . "',
677
-                '" . $in[4] . "',
678
-                '" . $in[5] . "',
679
-                '" . $in[6] . "',
680
-                '" . $in[7] . "'],";
674
+                '".$in[1]."',
675
+                '" . $in[2]."',
676
+                '" . $in[3]."',
677
+                '" . $in[4]."',
678
+                '" . $in[5]."',
679
+                '" . $in[6]."',
680
+                '" . $in[7]."'],";
681 681
         }
682 682
         if (!empty($return)) {
683 683
             $return = substr($return, 0, -1);
@@ -919,7 +919,7 @@  discard block
 block discarded – undo
919 919
                 $table = Database::get_course_table(TABLE_LP_MAIN);
920 920
                 $sql = "SELECT prevent_reinit
921 921
                     FROM $table
922
-                    WHERE c_id = $course_id AND id = " . $this->lp_id;
922
+                    WHERE c_id = $course_id AND id = ".$this->lp_id;
923 923
                 $res = Database::query($sql);
924 924
                 if (Database::num_rows($res) < 1) {
925 925
                     $this->error = "Could not find parent learnpath in lp table";
@@ -941,7 +941,7 @@  discard block
 block discarded – undo
941 941
         }
942 942
         if (self::debug > 2) {
943 943
             error_log(
944
-                'New LP - End of learnpathItem::get_prevent_reinit() - Returned ' . $this->prevent_reinit,
944
+                'New LP - End of learnpathItem::get_prevent_reinit() - Returned '.$this->prevent_reinit,
945 945
                 0
946 946
             );
947 947
         }
@@ -966,7 +966,7 @@  discard block
 block discarded – undo
966 966
                 $table = Database::get_course_table(TABLE_LP_MAIN);
967 967
                 $sql = "SELECT seriousgame_mode
968 968
                         FROM $table
969
-                        WHERE c_id = $course_id AND id = " . $this->lp_id;
969
+                        WHERE c_id = $course_id AND id = ".$this->lp_id;
970 970
                 $res = Database::query($sql);
971 971
                 if (Database::num_rows($res) < 1) {
972 972
                     $this->error = "Could not find parent learnpath in learnpath table";
@@ -987,7 +987,7 @@  discard block
 block discarded – undo
987 987
         }
988 988
         if (self::debug > 2) {
989 989
             error_log(
990
-                'New LP - End of learnpathItem::get_seriousgame_mode() - Returned ' . $this->seriousgame_mode,
990
+                'New LP - End of learnpathItem::get_seriousgame_mode() - Returned '.$this->seriousgame_mode,
991 991
                 0
992 992
             );
993 993
         }
@@ -1032,7 +1032,7 @@  discard block
 block discarded – undo
1032 1032
         }
1033 1033
         if (!isset($abs_path)) {
1034 1034
             $path = $this->get_file_path();
1035
-            $abs_path = api_get_path(SYS_COURSE_PATH) . api_get_course_path() . '/' . $path;
1035
+            $abs_path = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/'.$path;
1036 1036
         }
1037 1037
 
1038 1038
         $files_list = array();
@@ -1307,7 +1307,7 @@  discard block
 block discarded – undo
1307 1307
                                                             $abs_path
1308 1308
                                                         );
1309 1309
                                                         $new_abs_path = realpath(
1310
-                                                            $dir . '/' . $second_part
1310
+                                                            $dir.'/'.$second_part
1311 1311
                                                         );
1312 1312
                                                         $in_files_list[] = learnpathItem::get_resources_from_source(
1313 1313
                                                             TOOL_DOCUMENT,
@@ -1345,7 +1345,7 @@  discard block
 block discarded – undo
1345 1345
                                                             $abs_path
1346 1346
                                                         );
1347 1347
                                                         $new_abs_path = realpath(
1348
-                                                            $dir . '/' . $second_part
1348
+                                                            $dir.'/'.$second_part
1349 1349
                                                         );
1350 1350
                                                         $in_files_list[] = learnpathItem::get_resources_from_source(
1351 1351
                                                             TOOL_DOCUMENT,
@@ -1452,7 +1452,7 @@  discard block
 block discarded – undo
1452 1452
                                                             $abs_path
1453 1453
                                                         );
1454 1454
                                                         $new_abs_path = realpath(
1455
-                                                            $dir . '/' . $source
1455
+                                                            $dir.'/'.$source
1456 1456
                                                         );
1457 1457
                                                         $in_files_list[] = learnpathItem::get_resources_from_source(
1458 1458
                                                             TOOL_DOCUMENT,
@@ -1490,7 +1490,7 @@  discard block
 block discarded – undo
1490 1490
                                                             $abs_path
1491 1491
                                                         );
1492 1492
                                                         $new_abs_path = realpath(
1493
-                                                            $dir . '/' . $source
1493
+                                                            $dir.'/'.$source
1494 1494
                                                         );
1495 1495
                                                         $in_files_list[] = learnpathItem::get_resources_from_source(
1496 1496
                                                             TOOL_DOCUMENT,
@@ -1574,7 +1574,7 @@  discard block
 block discarded – undo
1574 1574
                                                 );
1575 1575
                                                 $dir = dirname($abs_path);
1576 1576
                                                 $new_abs_path = realpath(
1577
-                                                    $dir . '/' . $source
1577
+                                                    $dir.'/'.$source
1578 1578
                                                 );
1579 1579
                                                 $in_files_list[] = learnpathItem::get_resources_from_source(
1580 1580
                                                     TOOL_DOCUMENT,
@@ -1619,7 +1619,7 @@  discard block
 block discarded – undo
1619 1619
                                                 );
1620 1620
                                                 $dir = dirname($abs_path);
1621 1621
                                                 $new_abs_path = realpath(
1622
-                                                    $dir . '/' . $source
1622
+                                                    $dir.'/'.$source
1623 1623
                                                 );
1624 1624
                                                 $in_files_list[] = learnpathItem::get_resources_from_source(
1625 1625
                                                     TOOL_DOCUMENT,
@@ -1679,7 +1679,7 @@  discard block
 block discarded – undo
1679 1679
         }
1680 1680
         if (self::debug > 1) {
1681 1681
             error_log(
1682
-                'New LP - Out of learnpathItem::get_score() - returning ' . $res,
1682
+                'New LP - Out of learnpathItem::get_score() - returning '.$res,
1683 1683
                 0
1684 1684
             );
1685 1685
         }
@@ -1699,7 +1699,7 @@  discard block
 block discarded – undo
1699 1699
         $course_id = api_get_course_int_id();
1700 1700
         $debug = self::debug;
1701 1701
         if ($debug > 0) {
1702
-            error_log('learnpathItem::get_status() on item ' . $this->db_id, 0);
1702
+            error_log('learnpathItem::get_status() on item '.$this->db_id, 0);
1703 1703
         }
1704 1704
         if ($check_db) {
1705 1705
             if ($debug > 2) {
@@ -1710,12 +1710,12 @@  discard block
 block discarded – undo
1710 1710
                 $sql = "SELECT status FROM $table
1711 1711
                         WHERE
1712 1712
                             c_id = $course_id AND
1713
-                            id = '" . $this->db_item_view_id . "' AND
1714
-                            view_count = '" . $this->get_attempt_id() . "'";
1713
+                            id = '".$this->db_item_view_id."' AND
1714
+                            view_count = '" . $this->get_attempt_id()."'";
1715 1715
 
1716 1716
                 if ($debug > 2) {
1717 1717
                     error_log(
1718
-                        'learnpathItem::get_status() - Checking DB: ' . $sql,
1718
+                        'learnpathItem::get_status() - Checking DB: '.$sql,
1719 1719
                         0
1720 1720
                     );
1721 1721
                 }
@@ -1726,7 +1726,7 @@  discard block
 block discarded – undo
1726 1726
                     if ($update_local) {
1727 1727
                         if ($debug > 2) {
1728 1728
                             error_log(
1729
-                                'learnpathItem::set_status() :' . $row['status'],
1729
+                                'learnpathItem::set_status() :'.$row['status'],
1730 1730
                                 0
1731 1731
                             );
1732 1732
                         }
@@ -1734,7 +1734,7 @@  discard block
 block discarded – undo
1734 1734
                     }
1735 1735
                     if ($debug > 2) {
1736 1736
                         error_log(
1737
-                            'learnpathItem::get_status() - Returning db value ' . $row['status'],
1737
+                            'learnpathItem::get_status() - Returning db value '.$row['status'],
1738 1738
                             0
1739 1739
                         );
1740 1740
                     }
@@ -1751,7 +1751,7 @@  discard block
 block discarded – undo
1751 1751
             if (!empty($this->status)) {
1752 1752
                 if ($debug > 2) {
1753 1753
                     error_log(
1754
-                        'learnpathItem::get_status() - Returning attrib: ' . $this->status,
1754
+                        'learnpathItem::get_status() - Returning attrib: '.$this->status,
1755 1755
                         0
1756 1756
                     );
1757 1757
                 }
@@ -1761,7 +1761,7 @@  discard block
 block discarded – undo
1761 1761
 
1762 1762
         if ($debug > 2) {
1763 1763
             error_log(
1764
-                'learnpathItem::get_status() - Returning default ' . $this->possible_status[0],
1764
+                'learnpathItem::get_status() - Returning default '.$this->possible_status[0],
1765 1765
                 0
1766 1766
             );
1767 1767
         }
@@ -1801,7 +1801,7 @@  discard block
 block discarded – undo
1801 1801
             if ($origin == 'js') {
1802 1802
                 return '00 : 00: 00';
1803 1803
             } else {
1804
-                return '00 ' . $h . ' 00 \' 00"';
1804
+                return '00 '.$h.' 00 \' 00"';
1805 1805
             }
1806 1806
         } else {
1807 1807
             return api_format_time($time, $origin);
@@ -1826,7 +1826,7 @@  discard block
 block discarded – undo
1826 1826
         if (!isset($given_time)) {
1827 1827
             if (self::debug > 2) {
1828 1828
                 error_log(
1829
-                    'learnpathItem::get_scorm_time(): given time empty, current_start_time = ' . $this->current_start_time,
1829
+                    'learnpathItem::get_scorm_time(): given time empty, current_start_time = '.$this->current_start_time,
1830 1830
                     0
1831 1831
                 );
1832 1832
             }
@@ -1836,8 +1836,8 @@  discard block
 block discarded – undo
1836 1836
                         FROM $table
1837 1837
                         WHERE
1838 1838
                             c_id = $course_id AND
1839
-                            id = '" . $this->db_item_view_id . "' AND
1840
-                            view_count = '" . $this->get_attempt_id() . "'";
1839
+                            id = '".$this->db_item_view_id."' AND
1840
+                            view_count = '" . $this->get_attempt_id()."'";
1841 1841
                 $res = Database::query($sql);
1842 1842
                 $row = Database::fetch_array($res);
1843 1843
                 $start = $row['start_time'];
@@ -1858,7 +1858,7 @@  discard block
 block discarded – undo
1858 1858
         }
1859 1859
         if (self::debug > 2) {
1860 1860
             error_log(
1861
-                'learnpathItem::get_scorm_time(): intermediate = ' . $time,
1861
+                'learnpathItem::get_scorm_time(): intermediate = '.$time,
1862 1862
                 0
1863 1863
             );
1864 1864
         }
@@ -1878,7 +1878,7 @@  discard block
 block discarded – undo
1878 1878
         $sql = "SELECT * FROM $lp_item
1879 1879
                 WHERE
1880 1880
                     c_id = $course_id AND
1881
-                    id='" . intval($this->db_id) . "'";
1881
+                    id='".intval($this->db_id)."'";
1882 1882
         $res = Database::query($sql);
1883 1883
         $row = Database::fetch_array($res);
1884 1884
         return $row['terms'];
@@ -1907,9 +1907,9 @@  discard block
 block discarded – undo
1907 1907
     {
1908 1908
         if (self::debug > 0) {
1909 1909
             error_log(
1910
-                'learnpathItem::get_total_time() for item ' . $this->db_id .
1911
-                ' - Initially, current_start_time = ' . $this->current_start_time .
1912
-                ' and current_stop_time = ' . $this->current_stop_time,
1910
+                'learnpathItem::get_total_time() for item '.$this->db_id.
1911
+                ' - Initially, current_start_time = '.$this->current_start_time.
1912
+                ' and current_stop_time = '.$this->current_stop_time,
1913 1913
                 0
1914 1914
             );
1915 1915
         }
@@ -1950,9 +1950,9 @@  discard block
 block discarded – undo
1950 1950
         } else {
1951 1951
             if (self::debug > 2) {
1952 1952
                 error_log(
1953
-                    'learnpathItem::get_total_time() - Current start time = ' .
1954
-                    $this->current_start_time . ', current stop time = ' .
1955
-                    $this->current_stop_time . ' Returning ' . $time . "-----------\n",
1953
+                    'learnpathItem::get_total_time() - Current start time = '.
1954
+                    $this->current_start_time.', current stop time = '.
1955
+                    $this->current_stop_time.' Returning '.$time."-----------\n",
1956 1956
                     0
1957 1957
                 );
1958 1958
             }
@@ -1972,7 +1972,7 @@  discard block
 block discarded – undo
1972 1972
         }
1973 1973
         if (self::debug > 2) {
1974 1974
             error_log(
1975
-                'learnpathItem::get_type() - Returning ' . $res . ' for item ' . $this->db_id,
1975
+                'learnpathItem::get_type() - Returning '.$res.' for item '.$this->db_id,
1976 1976
                 0
1977 1977
             );
1978 1978
         }
@@ -2012,8 +2012,8 @@  discard block
 block discarded – undo
2012 2012
         if ($this->status_is($completedStatusList)) {
2013 2013
             if (self::debug > 2) {
2014 2014
                 error_log(
2015
-                    'learnpath::is_done() - Item ' . $this->get_id(
2016
-                    ) . ' is complete',
2015
+                    'learnpath::is_done() - Item '.$this->get_id(
2016
+                    ).' is complete',
2017 2017
                     0
2018 2018
                 );
2019 2019
             }
@@ -2022,8 +2022,8 @@  discard block
 block discarded – undo
2022 2022
         } else {
2023 2023
             if (self::debug > 2) {
2024 2024
                 error_log(
2025
-                    'learnpath::is_done() - Item ' . $this->get_id(
2026
-                    ) . ' is not complete',
2025
+                    'learnpath::is_done() - Item '.$this->get_id(
2026
+                    ).' is not complete',
2027 2027
                     0
2028 2028
                 );
2029 2029
             }
@@ -2060,7 +2060,7 @@  discard block
 block discarded – undo
2060 2060
         }
2061 2061
         if (self::debug > 2) {
2062 2062
             error_log(
2063
-                'New LP - End of learnpathItem::is_restart_allowed() - Returning ' . $restart,
2063
+                'New LP - End of learnpathItem::is_restart_allowed() - Returning '.$restart,
2064 2064
                 0
2065 2065
             );
2066 2066
         }
@@ -2139,7 +2139,7 @@  discard block
 block discarded – undo
2139 2139
     {
2140 2140
         if (self::debug > 0) {
2141 2141
             error_log(
2142
-                'learnpathItem::parse_prereq() for learnpath ' . $this->lp_id . ' with string ' . $prereqs_string,
2142
+                'learnpathItem::parse_prereq() for learnpath '.$this->lp_id.' with string '.$prereqs_string,
2143 2143
                 0
2144 2144
             );
2145 2145
         }
@@ -2332,7 +2332,7 @@  discard block
 block discarded – undo
2332 2332
                                 // Strange...
2333 2333
                                 if (self::debug > 1) {
2334 2334
                                     error_log(
2335
-                                        'New LP - Found ~ but strange string: ' . $prereqs_string,
2335
+                                        'New LP - Found ~ but strange string: '.$prereqs_string,
2336 2336
                                         0
2337 2337
                                     );
2338 2338
                                 }
@@ -2360,7 +2360,7 @@  discard block
 block discarded – undo
2360 2360
                                     //  the big brackets-enclosed condition.
2361 2361
                                     if (self::debug > 1) {
2362 2362
                                         error_log(
2363
-                                            'New LP - Dealing with group ' . $gr,
2363
+                                            'New LP - Dealing with group '.$gr,
2364 2364
                                             0
2365 2365
                                         );
2366 2366
                                     }
@@ -2374,7 +2374,7 @@  discard block
 block discarded – undo
2374 2374
                                     ) {
2375 2375
                                         if (self::debug > 1) {
2376 2376
                                             error_log(
2377
-                                                'New LP - Found multiplier ' . $multi[0],
2377
+                                                'New LP - Found multiplier '.$multi[0],
2378 2378
                                                 0
2379 2379
                                             );
2380 2380
                                         }
@@ -2390,7 +2390,7 @@  discard block
 block discarded – undo
2390 2390
                                                     $mytrue++;
2391 2391
                                                     if (self::debug > 1) {
2392 2392
                                                         error_log(
2393
-                                                            'New LP - Found true item, counting.. (' . ($mytrue) . ')',
2393
+                                                            'New LP - Found true item, counting.. ('.($mytrue).')',
2394 2394
                                                             0
2395 2395
                                                         );
2396 2396
                                                     }
@@ -2398,7 +2398,7 @@  discard block
 block discarded – undo
2398 2398
                                             } else {
2399 2399
                                                 if (self::debug > 1) {
2400 2400
                                                     error_log(
2401
-                                                        'New LP - item ' . $cond . ' does not exist in items list',
2401
+                                                        'New LP - item '.$cond.' does not exist in items list',
2402 2402
                                                         0
2403 2403
                                                     );
2404 2404
                                                 }
@@ -2445,7 +2445,7 @@  discard block
 block discarded – undo
2445 2445
                                                 } else {
2446 2446
                                                     if (self::debug > 1) {
2447 2447
                                                         error_log(
2448
-                                                            'New LP - ' .
2448
+                                                            'New LP - '.
2449 2449
                                                             ' Found false item, the set is not true, return false',
2450 2450
                                                             0
2451 2451
                                                         );
@@ -2456,7 +2456,7 @@  discard block
 block discarded – undo
2456 2456
                                             } else {
2457 2457
                                                 if (self::debug > 1) {
2458 2458
                                                     error_log(
2459
-                                                        'New LP - item ' . $cond . ' does not exist in items list',
2459
+                                                        'New LP - item '.$cond.' does not exist in items list',
2460 2460
                                                         0
2461 2461
                                                     );
2462 2462
                                                 }
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
                                 //  value of the corresponding resource completion status.
2483 2483
                                 if (self::debug > 1) {
2484 2484
                                     error_log(
2485
-                                        'New LP - Didnt find any group, returning value for ' . $prereqs_string,
2485
+                                        'New LP - Didnt find any group, returning value for '.$prereqs_string,
2486 2486
                                         0
2487 2487
                                     );
2488 2488
                                 }
@@ -2499,14 +2499,14 @@  discard block
 block discarded – undo
2499 2499
                                         if (!$returnstatus) {
2500 2500
                                             if (self::debug > 1) {
2501 2501
                                                 error_log(
2502
-                                                    'New LP - Prerequisite ' . $prereqs_string . ' not complete',
2502
+                                                    'New LP - Prerequisite '.$prereqs_string.' not complete',
2503 2503
                                                     0
2504 2504
                                                 );
2505 2505
                                             }
2506 2506
                                         } else {
2507 2507
                                             if (self::debug > 1) {
2508 2508
                                                 error_log(
2509
-                                                    'New LP - Prerequisite ' . $prereqs_string . ' complete',
2509
+                                                    'New LP - Prerequisite '.$prereqs_string.' complete',
2510 2510
                                                     0
2511 2511
                                                 );
2512 2512
                                             }
@@ -2518,12 +2518,12 @@  discard block
 block discarded – undo
2518 2518
                                             if ($returnstatus) {
2519 2519
                                                 //AND origin_lp_item_id = '.$user_id.'
2520 2520
                                                 $sql = 'SELECT exe_result, exe_weighting
2521
-                                                        FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES) . '
2521
+                                                        FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES).'
2522 2522
                                                         WHERE
2523
-                                                            exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . ' AND
2524
-                                                            exe_user_id = ' . $user_id . ' AND
2525
-                                                            orig_lp_id = ' . $this->lp_id . ' AND
2526
-                                                            orig_lp_item_id = ' . $prereqs_string . ' AND
2523
+                                                            exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path.' AND
2524
+                                                            exe_user_id = ' . $user_id.' AND
2525
+                                                            orig_lp_id = ' . $this->lp_id.' AND
2526
+                                                            orig_lp_item_id = ' . $prereqs_string.' AND
2527 2527
                                                             status <> "incomplete"
2528 2528
                                                         ORDER BY exe_date DESC
2529 2529
                                                         LIMIT 0, 1';
@@ -2561,12 +2561,12 @@  discard block
 block discarded – undo
2561 2561
 
2562 2562
                                             // Checking in the database.
2563 2563
                                             $sql = 'SELECT exe_result, exe_weighting
2564
-                                                    FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES) . '
2564
+                                                    FROM ' . Database :: get_main_table(TABLE_STATISTIC_TRACK_E_EXERCISES).'
2565 2565
                                                     WHERE
2566
-                                                        exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path . ' AND
2567
-                                                        exe_user_id = ' . $user_id . ' AND
2568
-                                                        orig_lp_id = ' . $this->lp_id . ' AND
2569
-                                                        orig_lp_item_id = ' . $prereqs_string . ' ';
2566
+                                                        exe_exo_id = ' . $items[$refs_list[$prereqs_string]]->path.' AND
2567
+                                                        exe_user_id = ' . $user_id.' AND
2568
+                                                        orig_lp_id = ' . $this->lp_id.' AND
2569
+                                                        orig_lp_item_id = ' . $prereqs_string.' ';
2570 2570
 
2571 2571
                                             $rs_quiz = Database::query($sql);
2572 2572
                                             if (Database::num_rows($rs_quiz) > 0) {
@@ -2612,14 +2612,14 @@  discard block
 block discarded – undo
2612 2612
                                         if (!$returnstatus) {
2613 2613
                                             if (self::debug > 1) {
2614 2614
                                                 error_log(
2615
-                                                    'New LP - Prerequisite ' . $prereqs_string . ' not complete',
2615
+                                                    'New LP - Prerequisite '.$prereqs_string.' not complete',
2616 2616
                                                     0
2617 2617
                                                 );
2618 2618
                                             }
2619 2619
                                         } else {
2620 2620
                                             if (self::debug > 1) {
2621 2621
                                                 error_log(
2622
-                                                    'New LP - Prerequisite ' . $prereqs_string . ' complete',
2622
+                                                    'New LP - Prerequisite '.$prereqs_string.' complete',
2623 2623
                                                     0
2624 2624
                                                 );
2625 2625
                                             }
@@ -2634,11 +2634,11 @@  discard block
 block discarded – undo
2634 2634
                                                 TABLE_LP_VIEW
2635 2635
                                             );
2636 2636
 
2637
-                                            $sql = 'SELECT id FROM ' . $lp_view . '
2637
+                                            $sql = 'SELECT id FROM '.$lp_view.'
2638 2638
                                                     WHERE
2639
-                                                        c_id = ' . $course_id . ' AND
2640
-                                                        user_id = ' . $user_id . '  AND
2641
-                                                        lp_id = ' . $this->lp_id . ' AND
2639
+                                                        c_id = ' . $course_id.' AND
2640
+                                                        user_id = ' . $user_id.'  AND
2641
+                                                        lp_id = ' . $this->lp_id.' AND
2642 2642
                                                         session_id = '.$sessionId.'
2643 2643
                                                     LIMIT 0, 1';
2644 2644
                                             $rs_lp = Database::query($sql);
@@ -2647,11 +2647,11 @@  discard block
 block discarded – undo
2647 2647
                                             );
2648 2648
                                             $my_lp_id = $lp_id[0];
2649 2649
 
2650
-                                            $sql = 'SELECT status FROM ' . $lp_item_view . '
2650
+                                            $sql = 'SELECT status FROM '.$lp_item_view.'
2651 2651
                                                    WHERE
2652
-                                                        c_id = ' . $course_id . ' AND
2653
-                                                        lp_view_id = ' . $my_lp_id . ' AND
2654
-                                                        lp_item_id = ' . $refs_list[$prereqs_string] . '
2652
+                                                        c_id = ' . $course_id.' AND
2653
+                                                        lp_view_id = ' . $my_lp_id.' AND
2654
+                                                        lp_item_id = ' . $refs_list[$prereqs_string].'
2655 2655
                                                     LIMIT 0, 1';
2656 2656
                                             $rs_lp = Database::query($sql);
2657 2657
                                             $status_array = Database :: fetch_row(
@@ -2668,14 +2668,14 @@  discard block
 block discarded – undo
2668 2668
                                             if (!$returnstatus) {
2669 2669
                                                 if (self::debug > 1) {
2670 2670
                                                     error_log(
2671
-                                                        'New LP - Prerequisite ' . $prereqs_string . ' not complete',
2671
+                                                        'New LP - Prerequisite '.$prereqs_string.' not complete',
2672 2672
                                                         0
2673 2673
                                                     );
2674 2674
                                                 }
2675 2675
                                             } else {
2676 2676
                                                 if (self::debug > 1) {
2677 2677
                                                     error_log(
2678
-                                                        'New LP - Prerequisite ' . $prereqs_string . ' complete',
2678
+                                                        'New LP - Prerequisite '.$prereqs_string.' complete',
2679 2679
                                                         0
2680 2680
                                                     );
2681 2681
                                                 }
@@ -2686,7 +2686,7 @@  discard block
 block discarded – undo
2686 2686
                                 } else {
2687 2687
                                     if (self::debug > 1) {
2688 2688
                                         error_log(
2689
-                                            'New LP - Could not find ' . $prereqs_string . ' in ' . print_r(
2689
+                                            'New LP - Could not find '.$prereqs_string.' in '.print_r(
2690 2690
                                                 $refs_list,
2691 2691
                                                 true
2692 2692
                                             ),
@@ -2709,7 +2709,7 @@  discard block
 block discarded – undo
2709 2709
                 foreach ($list as $condition) {
2710 2710
                     if (self::debug > 1) {
2711 2711
                         error_log(
2712
-                            'New LP - Found OR, adding it (' . $condition . ')',
2712
+                            'New LP - Found OR, adding it ('.$condition.')',
2713 2713
                             0
2714 2714
                         );
2715 2715
                     }
@@ -2762,7 +2762,7 @@  discard block
 block discarded – undo
2762 2762
 
2763 2763
         if (self::debug > 1) {
2764 2764
             error_log(
2765
-                'New LP - End of parse_prereq. Error code is now ' . $this->prereq_alert,
2765
+                'New LP - End of parse_prereq. Error code is now '.$this->prereq_alert,
2766 2766
                 0
2767 2767
             );
2768 2768
         }
@@ -2880,7 +2880,7 @@  discard block
 block discarded – undo
2880 2880
                                 $this->set_score($value);
2881 2881
                                 if (self::debug > 2) {
2882 2882
                                     error_log(
2883
-                                        'learnpathItem::save() - setting score to ' . $value,
2883
+                                        'learnpathItem::save() - setting score to '.$value,
2884 2884
                                         0
2885 2885
                                     );
2886 2886
                                 }
@@ -2889,7 +2889,7 @@  discard block
 block discarded – undo
2889 2889
                                 $this->set_max_score($value);
2890 2890
                                 if (self::debug > 2) {
2891 2891
                                     error_log(
2892
-                                        'learnpathItem::save() - setting view_max_score to ' . $value,
2892
+                                        'learnpathItem::save() - setting view_max_score to '.$value,
2893 2893
                                         0
2894 2894
                                     );
2895 2895
                                 }
@@ -2898,7 +2898,7 @@  discard block
 block discarded – undo
2898 2898
                                 $this->min_score = $value;
2899 2899
                                 if (self::debug > 2) {
2900 2900
                                     error_log(
2901
-                                        'learnpathItem::save() - setting min_score to ' . $value,
2901
+                                        'learnpathItem::save() - setting min_score to '.$value,
2902 2902
                                         0
2903 2903
                                     );
2904 2904
                                 }
@@ -2908,7 +2908,7 @@  discard block
 block discarded – undo
2908 2908
                                     $this->set_status($value);
2909 2909
                                     if (self::debug > 2) {
2910 2910
                                         error_log(
2911
-                                            'learnpathItem::save() - setting status to ' . $value,
2911
+                                            'learnpathItem::save() - setting status to '.$value,
2912 2912
                                             0
2913 2913
                                         );
2914 2914
                                     }
@@ -2918,7 +2918,7 @@  discard block
 block discarded – undo
2918 2918
                                 $this->set_time($value);
2919 2919
                                 if (self::debug > 2) {
2920 2920
                                     error_log(
2921
-                                        'learnpathItem::save() - setting time to ' . $value,
2921
+                                        'learnpathItem::save() - setting time to '.$value,
2922 2922
                                         0
2923 2923
                                     );
2924 2924
                                 }
@@ -2927,7 +2927,7 @@  discard block
 block discarded – undo
2927 2927
                                 $this->current_data = $value;
2928 2928
                                 if (self::debug > 2) {
2929 2929
                                     error_log(
2930
-                                        'learnpathItem::save() - setting suspend_data to ' . $value,
2930
+                                        'learnpathItem::save() - setting suspend_data to '.$value,
2931 2931
                                         0
2932 2932
                                     );
2933 2933
                                 }
@@ -2936,7 +2936,7 @@  discard block
 block discarded – undo
2936 2936
                                 $this->set_lesson_location($value);
2937 2937
                                 if (self::debug > 2) {
2938 2938
                                     error_log(
2939
-                                        'learnpathItem::save() - setting lesson_location to ' . $value,
2939
+                                        'learnpathItem::save() - setting lesson_location to '.$value,
2940 2940
                                         0
2941 2941
                                     );
2942 2942
                                 }
@@ -2945,7 +2945,7 @@  discard block
 block discarded – undo
2945 2945
                                 $this->set_core_exit($value);
2946 2946
                                 if (self::debug > 2) {
2947 2947
                                     error_log(
2948
-                                        'learnpathItem::save() - setting core_exit to ' . $value,
2948
+                                        'learnpathItem::save() - setting core_exit to '.$value,
2949 2949
                                         0
2950 2950
                                     );
2951 2951
                                 }
@@ -3092,7 +3092,7 @@  discard block
 block discarded – undo
3092 3092
     public function set_level($int = 0)
3093 3093
     {
3094 3094
         if (self::debug > 0) {
3095
-            error_log('learnpathItem::set_level(' . $int . ')', 0);
3095
+            error_log('learnpathItem::set_level('.$int.')', 0);
3096 3096
         }
3097 3097
         if (!empty($int) AND $int == strval(intval($int))) {
3098 3098
             $this->level = $int;
@@ -3121,7 +3121,7 @@  discard block
 block discarded – undo
3121 3121
         if (empty($lpItemId)) {
3122 3122
             if (self::debug > 0) {
3123 3123
                 error_log(
3124
-                    'learnpathItem::set_lp_view(' . $lp_view_id . ') $lpItemId is empty',
3124
+                    'learnpathItem::set_lp_view('.$lp_view_id.') $lpItemId is empty',
3125 3125
                     0
3126 3126
                 );
3127 3127
             }
@@ -3132,7 +3132,7 @@  discard block
 block discarded – undo
3132 3132
         if (empty($lp_view_id)) {
3133 3133
             if (self::debug > 0) {
3134 3134
                 error_log(
3135
-                    'learnpathItem::set_lp_view(' . $lp_view_id . ') $lp_view_id is empty',
3135
+                    'learnpathItem::set_lp_view('.$lp_view_id.') $lp_view_id is empty',
3136 3136
                     0
3137 3137
                 );
3138 3138
             }
@@ -3141,7 +3141,7 @@  discard block
 block discarded – undo
3141 3141
         }
3142 3142
 
3143 3143
         if (self::debug > 0) {
3144
-            error_log('learnpathItem::set_lp_view(' . $lp_view_id . ')', 0);
3144
+            error_log('learnpathItem::set_lp_view('.$lp_view_id.')', 0);
3145 3145
         }
3146 3146
 
3147 3147
         $this->view_id = $lp_view_id;
@@ -3151,13 +3151,13 @@  discard block
 block discarded – undo
3151 3151
         $sql = "SELECT * FROM $item_view_table
3152 3152
                 WHERE
3153 3153
                     c_id = $course_id AND
3154
-                    lp_item_id = " . $lpItemId . " AND
3155
-                    lp_view_id = " . $lp_view_id . "
3154
+                    lp_item_id = ".$lpItemId." AND
3155
+                    lp_view_id = " . $lp_view_id."
3156 3156
                 ORDER BY view_count DESC";
3157 3157
 
3158 3158
         if (self::debug > 2) {
3159 3159
             error_log(
3160
-                'learnpathItem::set_lp_view() - Querying lp_item_view: ' . $sql,
3160
+                'learnpathItem::set_lp_view() - Querying lp_item_view: '.$sql,
3161 3161
                 0
3162 3162
             );
3163 3163
         }
@@ -3189,7 +3189,7 @@  discard block
 block discarded – undo
3189 3189
             $sql = "SELECT * FROM $item_view_interaction_table
3190 3190
                     WHERE
3191 3191
                         c_id = $course_id AND
3192
-                        lp_iv_id = '" . $this->db_item_view_id . "'";
3192
+                        lp_iv_id = '".$this->db_item_view_id."'";
3193 3193
 
3194 3194
             $res = Database::query($sql);
3195 3195
             if ($res !== false) {
@@ -3204,7 +3204,7 @@  discard block
 block discarded – undo
3204 3204
             $sql = "SELECT * FROM $item_view_objective_table
3205 3205
                     WHERE
3206 3206
                         c_id = $course_id AND
3207
-                        lp_iv_id = '" . $this->db_item_view_id . "'";
3207
+                        lp_iv_id = '".$this->db_item_view_id."'";
3208 3208
 
3209 3209
             $res = Database::query($sql);
3210 3210
             if ($res !== false) {
@@ -3265,7 +3265,7 @@  discard block
 block discarded – undo
3265 3265
     {
3266 3266
         $debug = self::debug;
3267 3267
         if ($debug > 0) {
3268
-            error_log('learnpathItem::set_score(' . $score . ')', 0);
3268
+            error_log('learnpathItem::set_score('.$score.')', 0);
3269 3269
         }
3270 3270
         if (($this->max_score <= 0 || $score <= $this->max_score) && ($score >= $this->min_score)) {
3271 3271
             $this->current_score = $score;
@@ -3278,9 +3278,9 @@  discard block
 block discarded – undo
3278 3278
             }
3279 3279
 
3280 3280
             if ($debug > 0) {
3281
-                error_log('get_mastery_score: ' . $masteryScore);
3282
-                error_log('current_status: ' . $current_status);
3283
-                error_log('current score : ' . $this->current_score);
3281
+                error_log('get_mastery_score: '.$masteryScore);
3282
+                error_log('current_status: '.$current_status);
3283
+                error_log('current score : '.$this->current_score);
3284 3284
             }
3285 3285
 
3286 3286
             // If mastery_score is set AND the current score reaches the mastery
@@ -3308,15 +3308,15 @@  discard block
 block discarded – undo
3308 3308
     public function set_max_score($score)
3309 3309
     {
3310 3310
         if (self::debug > 0) {
3311
-            error_log('learnpathItem::set_max_score(' . $score . ')', 0);
3311
+            error_log('learnpathItem::set_max_score('.$score.')', 0);
3312 3312
         }
3313 3313
         if (is_int($score) || $score == '') {
3314 3314
             $this->view_max_score = $score;
3315 3315
             if (self::debug > 1) {
3316 3316
                 error_log(
3317
-                    'learnpathItem::set_max_score() - ' .
3318
-                    'Updated object score of item ' . $this->db_id .
3319
-                    ' to ' . $this->view_max_score,
3317
+                    'learnpathItem::set_max_score() - '.
3318
+                    'Updated object score of item '.$this->db_id.
3319
+                    ' to '.$this->view_max_score,
3320 3320
                     0
3321 3321
                 );
3322 3322
             }
@@ -3334,12 +3334,12 @@  discard block
 block discarded – undo
3334 3334
     public function set_status($status)
3335 3335
     {
3336 3336
         if (self::debug > 0) {
3337
-            error_log('learnpathItem::set_status(' . $status . ')', 0);
3337
+            error_log('learnpathItem::set_status('.$status.')', 0);
3338 3338
         }
3339 3339
 
3340 3340
         $found = false;
3341 3341
         foreach ($this->possible_status as $possible) {
3342
-            if (preg_match('/^' . $possible . '$/i', $status)) {
3342
+            if (preg_match('/^'.$possible.'$/i', $status)) {
3343 3343
                 $found = true;
3344 3344
             }
3345 3345
         }
@@ -3349,8 +3349,8 @@  discard block
 block discarded – undo
3349 3349
             if (self::debug > 1) {
3350 3350
                 error_log(
3351 3351
                     'learnpathItem::set_status() - '.
3352
-                        'Updated object status of item ' . $this->db_id .
3353
-                        ' to ' . $this->status,
3352
+                        'Updated object status of item '.$this->db_id.
3353
+                        ' to '.$this->status,
3354 3354
                     0
3355 3355
                 );
3356 3356
             }
@@ -3374,7 +3374,7 @@  discard block
 block discarded – undo
3374 3374
         $lp_item = Database::get_course_table(TABLE_LP_ITEM);
3375 3375
         require_once api_get_path(
3376 3376
                 LIBRARY_PATH
3377
-            ) . 'search/ChamiloIndexer.class.php';
3377
+            ).'search/ChamiloIndexer.class.php';
3378 3378
         $a_terms = preg_split('/,/', $terms);
3379 3379
         $i_terms = preg_split('/,/', $this->get_terms());
3380 3380
         foreach ($i_terms as $term) {
@@ -3391,7 +3391,7 @@  discard block
 block discarded – undo
3391 3391
                 SET terms = '$terms'
3392 3392
                 WHERE
3393 3393
                     c_id = $course_id AND
3394
-                    id=" . $this->get_id();
3394
+                    id=".$this->get_id();
3395 3395
         Database::query($sql);
3396 3396
         // Save it to search engine.
3397 3397
         if (api_get_setting('search_enabled') == 'true') {
@@ -3419,7 +3419,7 @@  discard block
 block discarded – undo
3419 3419
     public function set_time($scorm_time, $format = 'scorm')
3420 3420
     {
3421 3421
         if (self::debug > 0) {
3422
-            error_log('learnpathItem::set_time(' . $scorm_time . ')', 0);
3422
+            error_log('learnpathItem::set_time('.$scorm_time.')', 0);
3423 3423
         }
3424 3424
         if ($scorm_time == '0'
3425 3425
                 and ($this->type != 'sco')
@@ -3430,8 +3430,8 @@  discard block
 block discarded – undo
3430 3430
                 $this->update_time($my_time);
3431 3431
                 if (self::debug > 0) {
3432 3432
                     error_log(
3433
-                        'learnpathItem::set_time(' . $scorm_time . ') - ' .
3434
-                            'found asset - set time to ' . $my_time,
3433
+                        'learnpathItem::set_time('.$scorm_time.') - '.
3434
+                            'found asset - set time to '.$my_time,
3435 3435
                         0
3436 3436
                     );
3437 3437
                 }
@@ -3504,10 +3504,10 @@  discard block
 block discarded – undo
3504 3504
     {
3505 3505
         if (self::debug > 1) {
3506 3506
             error_log(
3507
-                'learnpathItem::status_is(' . print_r(
3507
+                'learnpathItem::status_is('.print_r(
3508 3508
                     $list,
3509 3509
                     true
3510
-                ) . ') on item ' . $this->db_id,
3510
+                ).') on item '.$this->db_id,
3511 3511
                 0
3512 3512
             );
3513 3513
         }
@@ -3517,11 +3517,11 @@  discard block
 block discarded – undo
3517 3517
         }
3518 3518
         $found = false;
3519 3519
         foreach ($list as $status) {
3520
-            if (preg_match('/^' . $status . '$/i', $currentStatus)) {
3520
+            if (preg_match('/^'.$status.'$/i', $currentStatus)) {
3521 3521
                 if (self::debug > 2) {
3522 3522
                     error_log(
3523
-                        'New LP - learnpathItem::status_is() - Found status ' .
3524
-                            $status . ' corresponding to current status',
3523
+                        'New LP - learnpathItem::status_is() - Found status '.
3524
+                            $status.' corresponding to current status',
3525 3525
                         0
3526 3526
                     );
3527 3527
                 }
@@ -3532,8 +3532,8 @@  discard block
 block discarded – undo
3532 3532
         }
3533 3533
         if (self::debug > 2) {
3534 3534
             error_log(
3535
-                'New LP - learnpathItem::status_is() - Status ' .
3536
-                    $currentStatus . ' did not match request',
3535
+                'New LP - learnpathItem::status_is() - Status '.
3536
+                    $currentStatus.' did not match request',
3537 3537
                 0
3538 3538
             );
3539 3539
         }
@@ -3550,7 +3550,7 @@  discard block
 block discarded – undo
3550 3550
     public function update_time($total_sec = 0)
3551 3551
     {
3552 3552
         if (self::debug > 0) {
3553
-            error_log('learnpathItem::update_time(' . $total_sec . ')', 0);
3553
+            error_log('learnpathItem::update_time('.$total_sec.')', 0);
3554 3554
         }
3555 3555
         if ($total_sec >= 0) {
3556 3556
             // Getting start time from finish time. The only problem in the calculation is it might be
@@ -3602,11 +3602,11 @@  discard block
 block discarded – undo
3602 3602
         $item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
3603 3603
         $course_id = api_get_course_int_id();
3604 3604
 
3605
-        $get_view_sql = 'SELECT total_time, status FROM ' . $item_view_table . '
3606
-                         WHERE c_id = ' . $course_id . '
3607
-                            AND lp_item_id="' . $this->db_id . '"
3608
-                            AND lp_view_id="' . $this->view_id . '"
3609
-                            AND view_count="' . $this->attempt_id . '" ;';
3605
+        $get_view_sql = 'SELECT total_time, status FROM '.$item_view_table.'
3606
+                         WHERE c_id = ' . $course_id.'
3607
+                            AND lp_item_id="' . $this->db_id.'"
3608
+                            AND lp_view_id="' . $this->view_id.'"
3609
+                            AND view_count="' . $this->attempt_id.'" ;';
3610 3610
         $result = Database::query($get_view_sql);
3611 3611
         $row = Database::fetch_array($result);
3612 3612
 
@@ -3659,12 +3659,12 @@  discard block
 block discarded – undo
3659 3659
     {
3660 3660
         $item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
3661 3661
         $course_id = api_get_course_int_id();
3662
-        $sql = 'UPDATE ' . $item_view_table . '
3663
-                SET total_time = 0, start_time=' . time() . '
3664
-                WHERE c_id = ' . $course_id . '
3665
-                    AND lp_item_id="' . $this->db_id . '"
3666
-                    AND lp_view_id="' . $this->view_id . '"
3667
-                    AND view_count="' . $this->attempt_id . '" ;';
3662
+        $sql = 'UPDATE '.$item_view_table.'
3663
+                SET total_time = 0, start_time=' . time().'
3664
+                WHERE c_id = ' . $course_id.'
3665
+                    AND lp_item_id="' . $this->db_id.'"
3666
+                    AND lp_view_id="' . $this->view_id.'"
3667
+                    AND view_count="' . $this->attempt_id.'" ;';
3668 3668
         Database::query($sql);
3669 3669
     }
3670 3670
 
@@ -3686,8 +3686,8 @@  discard block
 block discarded – undo
3686 3686
                     FROM $tbl
3687 3687
                     WHERE
3688 3688
                         c_id = $course_id AND
3689
-                        lp_item_id = " . $this->db_id . " AND
3690
-                        lp_view_id = " . $this->view_id . " AND
3689
+                        lp_item_id = ".$this->db_id." AND
3690
+                        lp_view_id = " . $this->view_id." AND
3691 3691
                         view_count = " . $this->attempt_id;
3692 3692
             $res = Database::query($sql);
3693 3693
             if (Database::num_rows($res) > 0) {
@@ -3695,8 +3695,8 @@  discard block
 block discarded – undo
3695 3695
                 $lp_iv_id = $row[0];
3696 3696
                 if (self::debug > 2) {
3697 3697
                     error_log(
3698
-                        'learnpathItem::write_to_db() - Got item_view_id ' .
3699
-                            $lp_iv_id . ', now checking objectives ',
3698
+                        'learnpathItem::write_to_db() - Got item_view_id '.
3699
+                            $lp_iv_id.', now checking objectives ',
3700 3700
                         0
3701 3701
                     );
3702 3702
                 }
@@ -3708,7 +3708,7 @@  discard block
 block discarded – undo
3708 3708
                                 WHERE
3709 3709
                                     c_id = $course_id AND
3710 3710
                                     lp_iv_id = $lp_iv_id AND
3711
-                                    objective_id = '" . Database::escape_string($objective[0]) . "'";
3711
+                                    objective_id = '".Database::escape_string($objective[0])."'";
3712 3712
                     $iva_res = Database::query($iva_sql);
3713 3713
                     // id(0), type(1), time(2), weighting(3),
3714 3714
                     // correct_responses(4), student_response(5),
@@ -3717,22 +3717,22 @@  discard block
 block discarded – undo
3717 3717
                         // Update (or don't).
3718 3718
                         $iva_row = Database::fetch_array($iva_res);
3719 3719
                         $iva_id = $iva_row[0];
3720
-                        $ivau_sql = "UPDATE $iva_table " .
3721
-                            "SET objective_id = '" . Database::escape_string(
3720
+                        $ivau_sql = "UPDATE $iva_table ".
3721
+                            "SET objective_id = '".Database::escape_string(
3722 3722
                                 $objective[0]
3723
-                            ) . "'," .
3724
-                            "status = '" . Database::escape_string(
3723
+                            )."',".
3724
+                            "status = '".Database::escape_string(
3725 3725
                                 $objective[1]
3726
-                            ) . "'," .
3727
-                            "score_raw = '" . Database::escape_string(
3726
+                            )."',".
3727
+                            "score_raw = '".Database::escape_string(
3728 3728
                                 $objective[2]
3729
-                            ) . "'," .
3730
-                            "score_min = '" . Database::escape_string(
3729
+                            )."',".
3730
+                            "score_min = '".Database::escape_string(
3731 3731
                                 $objective[4]
3732
-                            ) . "'," .
3733
-                            "score_max = '" . Database::escape_string(
3732
+                            )."',".
3733
+                            "score_max = '".Database::escape_string(
3734 3734
                                 $objective[3]
3735
-                            ) . "' " .
3735
+                            )."' ".
3736 3736
                             "WHERE c_id = $course_id AND id = $iva_id";
3737 3737
                         Database::query($ivau_sql);
3738 3738
                     } else {
@@ -3782,12 +3782,12 @@  discard block
 block discarded – undo
3782 3782
         $credit = $this->get_credit();
3783 3783
 
3784 3784
         $item_view_table = Database::get_course_table(TABLE_LP_ITEM_VIEW);
3785
-        $sql = 'SELECT status FROM ' . $item_view_table . '
3785
+        $sql = 'SELECT status FROM '.$item_view_table.'
3786 3786
                 WHERE
3787
-                    c_id = ' . $course_id . ' AND
3788
-                    lp_item_id="' . $this->db_id . '" AND
3789
-                    lp_view_id="' . $this->view_id . '" AND
3790
-                    view_count="' . $this->get_attempt_id() . '" ';
3787
+                    c_id = ' . $course_id.' AND
3788
+                    lp_item_id="' . $this->db_id.'" AND
3789
+                    lp_view_id="' . $this->view_id.'" AND
3790
+                    view_count="' . $this->get_attempt_id().'" ';
3791 3791
         $rs_verified = Database::query($sql);
3792 3792
         $row_verified = Database::fetch_array($rs_verified);
3793 3793
 
@@ -3815,8 +3815,8 @@  discard block
 block discarded – undo
3815 3815
                     "This info shouldn't be saved as the credit or lesson mode info prevent it"
3816 3816
                 );
3817 3817
                 error_log(
3818
-                    'learnpathItem::write_to_db() - credit(' . $credit . ') or'.
3819
-                        ' lesson_mode(' . $mode . ') prevent recording!',
3818
+                    'learnpathItem::write_to_db() - credit('.$credit.') or'.
3819
+                        ' lesson_mode('.$mode.') prevent recording!',
3820 3820
                     0
3821 3821
                 );
3822 3822
             }
@@ -3840,14 +3840,14 @@  discard block
 block discarded – undo
3840 3840
                     "max_score" => $this->get_max(),
3841 3841
                     "lp_item_id" => $this->db_id,
3842 3842
                     "lp_view_id" => $this->view_id,
3843
-                    "view_count" => $this->get_attempt_id() ,
3843
+                    "view_count" => $this->get_attempt_id(),
3844 3844
                     "suspend_data" => $this->current_data,
3845 3845
                     //"max_time_allowed" => ,
3846 3846
                     "lesson_location" => $this->lesson_location
3847 3847
                 );
3848 3848
                 if (self::debug > 2) {
3849 3849
                     error_log(
3850
-                        'learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1),
3850
+                        'learnpathItem::write_to_db() - Inserting into item_view forced: '.print_r($params, 1),
3851 3851
                         0
3852 3852
                     );
3853 3853
                 }
@@ -3855,7 +3855,7 @@  discard block
 block discarded – undo
3855 3855
 
3856 3856
                 if ($this->db_item_view_id) {
3857 3857
                     $sql = "UPDATE $item_view_table SET id = iid
3858
-                            WHERE iid = " . $this->db_item_view_id;
3858
+                            WHERE iid = ".$this->db_item_view_id;
3859 3859
                     Database::query($sql);
3860 3860
                     $inserted = true;
3861 3861
                 }
@@ -3865,12 +3865,12 @@  discard block
 block discarded – undo
3865 3865
             $sql = "SELECT * FROM $item_view_table
3866 3866
                     WHERE
3867 3867
                         c_id = $course_id AND
3868
-                        lp_item_id = " . $this->db_id . " AND
3869
-                        lp_view_id = " . $this->view_id . " AND
3868
+                        lp_item_id = ".$this->db_id." AND
3869
+                        lp_view_id = " . $this->view_id." AND
3870 3870
                         view_count = " . intval($this->get_attempt_id());
3871 3871
             if (self::debug > 2) {
3872 3872
                 error_log(
3873
-                    'learnpathItem::write_to_db() - Querying item_view: ' . $sql,
3873
+                    'learnpathItem::write_to_db() - Querying item_view: '.$sql,
3874 3874
                     0
3875 3875
                 );
3876 3876
             }
@@ -3887,7 +3887,7 @@  discard block
 block discarded – undo
3887 3887
                     "max_score" => $this->get_max(),
3888 3888
                     "lp_item_id" => $this->db_id,
3889 3889
                     "lp_view_id" => $this->view_id,
3890
-                    "view_count" => $this->get_attempt_id() ,
3890
+                    "view_count" => $this->get_attempt_id(),
3891 3891
                     "suspend_data" => $this->current_data,
3892 3892
                     //"max_time_allowed" => ,$this->get_max_time_allowed()
3893 3893
                     "lesson_location" => $this->lesson_location
@@ -3895,7 +3895,7 @@  discard block
 block discarded – undo
3895 3895
 
3896 3896
                 if (self::debug > 2) {
3897 3897
                     error_log(
3898
-                        'learnpathItem::write_to_db() - Inserting into item_view forced: ' . print_r($params, 1),
3898
+                        'learnpathItem::write_to_db() - Inserting into item_view forced: '.print_r($params, 1),
3899 3899
                         0
3900 3900
                     );
3901 3901
                 }
@@ -3904,7 +3904,7 @@  discard block
 block discarded – undo
3904 3904
 
3905 3905
                 if ($this->db_item_view_id) {
3906 3906
                     $sql = "UPDATE $item_view_table SET id = iid
3907
-                            WHERE iid = " . $this->db_item_view_id;
3907
+                            WHERE iid = ".$this->db_item_view_id;
3908 3908
                     Database::query($sql);
3909 3909
                 }
3910 3910
             } else {
@@ -3944,8 +3944,8 @@  discard block
 block discarded – undo
3944 3944
                             $time_exe_date = convert_sql_date(
3945 3945
                                 $row_dates['exe_date']
3946 3946
                             );
3947
-                            $mytime = ((int)$time_exe_date - (int)$time_start_date);
3948
-                            $total_time = " total_time = " . $mytime . ", ";
3947
+                            $mytime = ((int) $time_exe_date - (int) $time_start_date);
3948
+                            $total_time = " total_time = ".$mytime.", ";
3949 3949
                         }
3950 3950
                     } else {
3951 3951
                         $my_type_lp = learnpath::get_type_static($this->lp_id);
@@ -3959,16 +3959,16 @@  discard block
 block discarded – undo
3959 3959
 
3960 3960
                         // Is not multiple attempts
3961 3961
                         if ($this->seriousgame_mode == 1 && $this->type == 'sco') {
3962
-                            $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
3963
-                            $my_status = " status = '" . $this->get_status(false) . "' ,";
3962
+                            $total_time = " total_time = total_time +".$this->get_total_time().", ";
3963
+                            $my_status = " status = '".$this->get_status(false)."' ,";
3964 3964
                         } elseif ($this->get_prevent_reinit() == 1) {
3965 3965
                             // Process of status verified into data base.
3966
-                            $sql = 'SELECT status FROM ' . $item_view_table . '
3966
+                            $sql = 'SELECT status FROM '.$item_view_table.'
3967 3967
                                     WHERE
3968
-                                        c_id = ' . $course_id . ' AND
3969
-                                        lp_item_id="' . $this->db_id . '" AND
3970
-                                        lp_view_id="' . $this->view_id . '" AND
3971
-                                        view_count="' . $this->get_attempt_id() . '"
3968
+                                        c_id = ' . $course_id.' AND
3969
+                                        lp_item_id="' . $this->db_id.'" AND
3970
+                                        lp_view_id="' . $this->view_id.'" AND
3971
+                                        view_count="' . $this->get_attempt_id().'"
3972 3972
                                     ';
3973 3973
                             $rs_verified = Database::query($sql);
3974 3974
                             $row_verified = Database::fetch_array($rs_verified);
@@ -3978,26 +3978,26 @@  discard block
 block discarded – undo
3978 3978
                             if (!in_array($this->get_status(false), $case_completed) &&
3979 3979
                                 $my_type_lp == 2
3980 3980
                             ) {
3981
-                                $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
3982
-                                $my_status = " status = '" . $this->get_status(false) . "' ,";
3981
+                                $total_time = " total_time = total_time +".$this->get_total_time().", ";
3982
+                                $my_status = " status = '".$this->get_status(false)."' ,";
3983 3983
                             } else {
3984 3984
                                 // Verified into database.
3985 3985
                                 if (!in_array($row_verified['status'], $case_completed) &&
3986 3986
                                     $my_type_lp == 2
3987 3987
                                 ) {
3988
-                                    $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
3989
-                                    $my_status = " status = '" . $this->get_status(false) . "' ,";
3990
-                                } elseif (in_array($row_verified['status'], $case_completed ) &&
3988
+                                    $total_time = " total_time = total_time +".$this->get_total_time().", ";
3989
+                                    $my_status = " status = '".$this->get_status(false)."' ,";
3990
+                                } elseif (in_array($row_verified['status'], $case_completed) &&
3991 3991
                                     $my_type_lp == 2 && $this->type != 'sco'
3992 3992
                                 ) {
3993
-                                    $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
3994
-                                    $my_status = " status = '" . $this->get_status(false) . "' ,";
3993
+                                    $total_time = " total_time = total_time +".$this->get_total_time().", ";
3994
+                                    $my_status = " status = '".$this->get_status(false)."' ,";
3995 3995
                                 } else {
3996 3996
                                     if (($my_type_lp == 3 && $this->type == 'au') ||
3997 3997
                                         ($my_type_lp == 1 && $this->type != 'chapter')) {
3998 3998
                                         // Is AICC or Chamilo LP
3999
-                                        $total_time = " total_time = total_time + " . $this->get_total_time() . ", ";
4000
-                                        $my_status = " status = '" . $this->get_status(false) . "' ,";
3999
+                                        $total_time = " total_time = total_time + ".$this->get_total_time().", ";
4000
+                                        $my_status = " status = '".$this->get_status(false)."' ,";
4001 4001
                                     }
4002 4002
                                 }
4003 4003
                             }
@@ -4009,27 +4009,27 @@  discard block
 block discarded – undo
4009 4009
                                 ) && $my_type_lp == 2
4010 4010
                             ) {
4011 4011
                                 // Reset zero new attempt ?
4012
-                                $my_status = " status = '" . $this->get_status(false) . "' ,";
4012
+                                $my_status = " status = '".$this->get_status(false)."' ,";
4013 4013
                             } elseif (!in_array($this->get_status(false), $case_completed) &&
4014 4014
                                 $my_type_lp == 2
4015 4015
                             ) {
4016
-                                $total_time = " total_time = " . $this->get_total_time() . ", ";
4017
-                                $my_status = " status = '" . $this->get_status(false) . "' ,";
4016
+                                $total_time = " total_time = ".$this->get_total_time().", ";
4017
+                                $my_status = " status = '".$this->get_status(false)."' ,";
4018 4018
                             } else {
4019 4019
                                 // It is chamilo LP.
4020
-                                $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
4021
-                                $my_status = " status = '" . $this->get_status(false) . "' ,";
4020
+                                $total_time = " total_time = total_time +".$this->get_total_time().", ";
4021
+                                $my_status = " status = '".$this->get_status(false)."' ,";
4022 4022
                             }
4023 4023
 
4024 4024
                             // This code line fixes the problem of wrong status.
4025 4025
                             if ($my_type_lp == 2) {
4026 4026
                                 // Verify current status in multiples attempts.
4027
-                                $sql = 'SELECT status FROM ' . $item_view_table . '
4027
+                                $sql = 'SELECT status FROM '.$item_view_table.'
4028 4028
                                         WHERE
4029
-                                            c_id = ' . $course_id . ' AND
4030
-                                            lp_item_id="' . $this->db_id . '" AND
4031
-                                            lp_view_id="' . $this->view_id . '" AND
4032
-                                            view_count="' . $this->get_attempt_id() . '" ';
4029
+                                            c_id = ' . $course_id.' AND
4030
+                                            lp_item_id="' . $this->db_id.'" AND
4031
+                                            lp_view_id="' . $this->view_id.'" AND
4032
+                                            view_count="' . $this->get_attempt_id().'" ';
4033 4033
                                 $rs_status = Database::query($sql);
4034 4034
                                 $current_status = Database::result(
4035 4035
                                     $rs_status,
@@ -4040,7 +4040,7 @@  discard block
 block discarded – undo
4040 4040
                                     $my_status = '';
4041 4041
                                     $total_time = '';
4042 4042
                                 } else {
4043
-                                    $total_time = " total_time = total_time +" . $this->get_total_time() . ", ";
4043
+                                    $total_time = " total_time = total_time +".$this->get_total_time().", ";
4044 4044
                                 }
4045 4045
                             }
4046 4046
                         }
@@ -4051,38 +4051,38 @@  discard block
 block discarded – undo
4051 4051
                         //" . //start_time = ".$this->get_current_start_time().", " . //scorm_init_time does it
4052 4052
                         ////" max_time_allowed = '".$this->get_max_time_allowed()."'," .
4053 4053
                         $sql = "UPDATE $item_view_table SET
4054
-                                    score = " . $this->get_score() . ",
4054
+                                    score = ".$this->get_score().",
4055 4055
                                     $my_status
4056
-                                    max_score = '" . $this->get_max() . "',
4057
-                                    suspend_data = '" . Database::escape_string($this->current_data) . "',
4058
-                                    lesson_location = '" . $this->lesson_location . "'
4056
+                                    max_score = '".$this->get_max()."',
4057
+                                    suspend_data = '" . Database::escape_string($this->current_data)."',
4058
+                                    lesson_location = '" . $this->lesson_location."'
4059 4059
                                 WHERE
4060 4060
                                     c_id = $course_id AND
4061
-                                    lp_item_id = " . $this->db_id . " AND
4062
-                                    lp_view_id = " . $this->view_id . "  AND
4061
+                                    lp_item_id = ".$this->db_id." AND
4062
+                                    lp_view_id = " . $this->view_id."  AND
4063 4063
                                     view_count = " . $this->get_attempt_id();
4064 4064
 
4065 4065
                     } else {
4066 4066
                         //" max_time_allowed = '".$this->get_max_time_allowed()."'," .
4067 4067
                         $sql = "UPDATE $item_view_table SET
4068 4068
                                     $total_time
4069
-                                    start_time = " . $this->get_current_start_time() . ",
4070
-                                    score = " . $this->get_score() . ",
4069
+                                    start_time = ".$this->get_current_start_time().",
4070
+                                    score = " . $this->get_score().",
4071 4071
                                     $my_status
4072
-                                    max_score = '" . $this->get_max() . "',
4073
-                                    suspend_data = '" . Database::escape_string($this->current_data) . "',
4074
-                                    lesson_location = '" . $this->lesson_location . "'
4072
+                                    max_score = '".$this->get_max()."',
4073
+                                    suspend_data = '" . Database::escape_string($this->current_data)."',
4074
+                                    lesson_location = '" . $this->lesson_location."'
4075 4075
                                 WHERE
4076 4076
                                     c_id = $course_id AND
4077
-                                    lp_item_id = " . $this->db_id . " AND
4078
-                                    lp_view_id = " . $this->view_id . " AND
4077
+                                    lp_item_id = ".$this->db_id." AND
4078
+                                    lp_view_id = " . $this->view_id." AND
4079 4079
                                     view_count = " . $this->get_attempt_id();
4080 4080
                     }
4081 4081
                     $this->current_start_time = time();
4082 4082
                 }
4083 4083
                 if (self::debug > 2) {
4084 4084
                     error_log(
4085
-                        'learnpathItem::write_to_db() - Updating item_view: ' . $sql,
4085
+                        'learnpathItem::write_to_db() - Updating item_view: '.$sql,
4086 4086
                         0
4087 4087
                     );
4088 4088
                 }
@@ -4095,8 +4095,8 @@  discard block
 block discarded – undo
4095 4095
                 $sql = "SELECT id FROM $tbl
4096 4096
                         WHERE
4097 4097
                             c_id = $course_id AND
4098
-                            lp_item_id = " . $this->db_id . " AND
4099
-                            lp_view_id = " . $this->view_id . " AND
4098
+                            lp_item_id = ".$this->db_id." AND
4099
+                            lp_view_id = " . $this->view_id." AND
4100 4100
                             view_count = " . $this->get_attempt_id();
4101 4101
                 $res = Database::query($sql);
4102 4102
                 if (Database::num_rows($res) > 0) {
@@ -4104,8 +4104,8 @@  discard block
 block discarded – undo
4104 4104
                     $lp_iv_id = $row[0];
4105 4105
                     if (self::debug > 2) {
4106 4106
                         error_log(
4107
-                            'learnpathItem::write_to_db() - Got item_view_id ' .
4108
-                                $lp_iv_id . ', now checking interactions ',
4107
+                            'learnpathItem::write_to_db() - Got item_view_id '.
4108
+                                $lp_iv_id.', now checking interactions ',
4109 4109
                             0
4110 4110
                         );
4111 4111
                     }
@@ -4116,7 +4116,7 @@  discard block
 block discarded – undo
4116 4116
                             ) && !empty($interaction[4][0])
4117 4117
                         ) {
4118 4118
                             foreach ($interaction[4] as $resp) {
4119
-                                $correct_resp .= $resp . ',';
4119
+                                $correct_resp .= $resp.',';
4120 4120
                             }
4121 4121
                             $correct_resp = substr(
4122 4122
                                 $correct_resp,
@@ -4135,7 +4135,7 @@  discard block
 block discarded – undo
4135 4135
                                         lp_iv_id = $lp_iv_id AND
4136 4136
                                         (
4137 4137
                                             order_id = $index OR
4138
-                                            interaction_id = '" . Database::escape_string($interaction[0]) . "'
4138
+                                            interaction_id = '".Database::escape_string($interaction[0])."'
4139 4139
                                         )
4140 4140
                                     ";
4141 4141
                         $iva_res = Database::query($iva_sql);
@@ -4208,11 +4208,11 @@  discard block
 block discarded – undo
4208 4208
     public function add_audio()
4209 4209
     {
4210 4210
         $course_info = api_get_course_info();
4211
-        $filepath = api_get_path(SYS_COURSE_PATH) . $course_info['path'] . '/document/';
4211
+        $filepath = api_get_path(SYS_COURSE_PATH).$course_info['path'].'/document/';
4212 4212
 
4213
-        if (!is_dir($filepath . 'audio')) {
4213
+        if (!is_dir($filepath.'audio')) {
4214 4214
             mkdir(
4215
-                $filepath . 'audio',
4215
+                $filepath.'audio',
4216 4216
                 api_get_permissions_for_new_directories()
4217 4217
             );
4218 4218
             $audio_id = add_document(
@@ -4271,10 +4271,10 @@  discard block
 block discarded – undo
4271 4271
             // Store the mp3 file in the lp_item table.
4272 4272
             $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
4273 4273
             $sql = "UPDATE $tbl_lp_item SET
4274
-                        audio = '" . Database::escape_string($file_path) . "'
4274
+                        audio = '".Database::escape_string($file_path)."'
4275 4275
                     WHERE
4276 4276
                         c_id = {$course_info['real_id']} AND
4277
-                        id = '" . intval($this->db_id) . "'";
4277
+                        id = '".intval($this->db_id)."'";
4278 4278
             Database::query($sql);
4279 4279
         }
4280 4280
 
@@ -4299,10 +4299,10 @@  discard block
 block discarded – undo
4299 4299
             // Store the mp3 file in the lp_item table.
4300 4300
             $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
4301 4301
             $sql = "UPDATE $tbl_lp_item SET
4302
-                        audio = '" . Database::escape_string($file_path) . "'
4302
+                        audio = '".Database::escape_string($file_path)."'
4303 4303
                     WHERE
4304 4304
                         c_id = {$course_info['real_id']} AND
4305
-                        id = " . intval($this->db_id);
4305
+                        id = ".intval($this->db_id);
4306 4306
             Database::query($sql);
4307 4307
         }
4308 4308
         return $file_path;
@@ -4323,7 +4323,7 @@  discard block
 block discarded – undo
4323 4323
         }
4324 4324
         $sql = "UPDATE $tbl_lp_item SET
4325 4325
                 audio = ''
4326
-                WHERE c_id = $course_id AND id IN (" . $this->db_id . ")";
4326
+                WHERE c_id = $course_id AND id IN (".$this->db_id.")";
4327 4327
         Database::query($sql);
4328 4328
     }
4329 4329
 
@@ -4369,7 +4369,7 @@  discard block
 block discarded – undo
4369 4369
 
4370 4370
         if ($type == 'simple') {
4371 4371
             if (in_array($status, array('failed', 'passed', 'browsed'))) {
4372
-                $myLessonStatus = get_lang('ScormIncomplete');;
4372
+                $myLessonStatus = get_lang('ScormIncomplete'); ;
4373 4373
                 $classStatus = 'warning';
4374 4374
             }
4375 4375
         }
@@ -4518,7 +4518,7 @@  discard block
 block discarded – undo
4518 4518
      */
4519 4519
     public function createForumThread($currentForumId)
4520 4520
     {
4521
-        require_once api_get_path(SYS_CODE_PATH) . '/forum/forumfunction.inc.php';
4521
+        require_once api_get_path(SYS_CODE_PATH).'/forum/forumfunction.inc.php';
4522 4522
 
4523 4523
         $em = Database::getManager();
4524 4524
         $threadRepo = $em->getRepository('ChamiloCourseBundle:CForumThread');
Please login to merge, or discard this patch.
main/newscorm/learnpathList.class.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
      * @param   int     $categoryId
35 35
      * @param bool $ignoreCategoryFilter
36 36
      *
37
-     * @return	void
37
+     * @return	false|null
38 38
      */
39 39
     public function __construct(
40 40
         $user_id,
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
                     ";
106 106
         $res = Database::query($sql);
107 107
         $names = array();
108
-        while ($row = Database::fetch_array($res,'ASSOC')) {
108
+        while ($row = Database::fetch_array($res, 'ASSOC')) {
109 109
             // Use domesticate here instead of Database::escape_string because
110 110
             // it prevents ' to be slashed and the input (done by learnpath.class.php::toggle_visibility())
111 111
             // is done using domesticate()
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 
236 236
         $lessons = array();
237 237
         while ($row = Database::fetch_array($result)) {
238
-            if (api_get_item_visibility($course, 'learnpath', $row['id'],  $session_id)) {
238
+            if (api_get_item_visibility($course, 'learnpath', $row['id'], $session_id)) {
239 239
                 $lessons[$row['id']] = $row;
240 240
             }
241 241
         }
Please login to merge, or discard this patch.