Jump to content

Object of class XMLTag could not be converted to string... Code included.


buildakicker

Recommended Posts

Hello all, I have an application that I am moving from php4 to php5 that I get some errors in. Namely:

 

Catchable fatal error: Object of class XMLTag could not be converted to string in WEBRView.php on line 497

 

Line 497 has the:  return (isset($s) && strlen($s)); // var is set and not an empty string '' of this function:

function check_not_empty($s, $include_whitespace = false)
{
    if ($include_whitespace) {
        // make it so strings containing white space are treated as empty too
		$s = trim($s);	
    }
    return (isset($s) && strlen($s)); // var is set and not an empty string ''
} 

 

I cannot figure out why it is doing this... It works fine on the php4 server. Here is the code for the file that is throwing this error:

 

<?php
//ERROR REPORTING
ini_set('display_errors',1); 
error_reporting(E_ALL);
///////////

include 'parser_php5.php';
include 'db.php';
include 'dbconnect.php';

// It's probably best to put this file in a non web-accessible folder for security
$configFile = '../documents/WEBRIndex.xml';
$fileContents = file_get_contents($configFile);
$indexXML = new XMLParser($fileContents);
//Work the magic...
$indexXML->Parse();

// ------------------------------------------------------------------
// Associate the users requested view with a document view mapping

$docType = $_GET["doc"];
//$action = $_GET["act"];

if(check_not_empty($docType) == FALSE) {
	echo "No document type specified";
	exit;
	}

// Find the XML mapping that corresponds with this type.. the ->document->document reference is because
// there is an embedded ->document attached automatically by the XML Parser... the second ->document
// reference is part of our document

$viewXMLFile = null;
$viewMapping = null;
foreach($indexXML->document->document as $doc) {
    		if(strcmp($doc->documentkey[0]->tagData, $docType) == 0) {
		$viewMapping = $doc;
		$viewXMLFile = $doc->viewxml[0]->tagData;
		break;
		}
	}

// Make sure we found our XML view mapping
if($viewMapping == null) {
	echo "No mapping found";
	exit;
	}

// Now load the actual view XML file into memory
$viewFile = '../documents/'.$viewXMLFile;
$fileContents = file_get_contents($viewFile);
$viewXML = new XMLParser($fileContents);

//Work the magic...
$viewXML->Parse();

// Find the XML mapping that corresponds with this type (because there can be multiple definitions per view XML file)
// so we need to do this a second time, (the first was for the index file)

$viewMapping = null;
foreach($viewXML->document->documentview as $view) {
    		if(strcmp($view->documentkey[0]->tagData, $docType) == 0) {
		$viewMapping = $view;
		break;
		}
	}

// Make sure we found our XML view mapping
if($viewMapping == null) {
	echo "No mapping found";
	exit;
	}


// ---------------------------------------------------------------
// Extract the header and group data from the view template	

$includeScripts = $viewMapping->includescript;
$customScript = $viewMapping->customscript;
$headerBlock = $viewMapping->header[0];
$bodyBlock = $viewMapping->body[0];
$documentType = $viewMapping->documenttype[0]->tagData;
if(check_not_empty($headerBlock) == FALSE || check_not_empty($bodyBlock) == FALSE || check_not_empty($documentType) == FALSE) {
	echo " Malformed document view - ".check_not_empty($headerBlock)." - ".check_not_empty($bodyBlock)." - ".check_not_empty($documentType);
	exit;
	}

// ------------------------------------------------------------------------------------------------
// Grab any final screen variables... The home button returns the user back to the WEBR index page
// the add button reloads the page for another document entry. The final screen message

$completionMessage = "";
$homeButtonMsg = null;
$addButtonMsg = null;
if(count($viewMapping->submitmessage) > 0) { $finalScreenMsg = $viewMapping->submitmessage[0]->tagData; }
if(count($viewMapping->homebutton) > 0) { $homeButtonMsg = $viewMapping->homebutton[0]->tagData; }
if(count($viewMapping->completionmessage) > 0) { $completionMessage = $viewMapping->completionmessage[0]->tagData; }

	$DB = new DB($dbUser, $dbPassword, $dbServer);
      	if ( $DB->error ) {
      		echo $DB->errorToString();
      		exit("No database");
      		}

// ------------------------------------------------------------------------------------
// The various case types are provided to add abstraction between the control column
// and the provided drop-down data

function provideDynamicData($viewMapping, $element, $type, $selected = null) {

	global $DB;

	$outText = "";
	switch($type) {
		case "CURRENTDATE":
			return Date("m/d/Y");
			break;

		case "CURRENTTIME":
			return Date("Hi");
			break;

		case "EUNAMES":
			$outText .= getHTMLOptionsFromDB($viewMapping, $element, $selected);
			break;
	  }
	return $outText;
	}

// ------------------------------------------------------------------------------------

function getHTMLOptionsFromDB($viewMapping, $element, $selected) {

	global $DB;

	$outText = "";
	$table = $viewMapping->defaulttable[0]->tagData;
	$column = $element->control[0]->column[0]->tagData;

	$sql = "SELECT distinct ".$column." from ".$table;


	$DB->query($sql); 
	if ( $DB->error ) {
		echo $DB->errorToString();
		exit("No database");
		}

	$result = $DB->getSensibleStatement();
	      for($i=0; $i<count($result); $i++) {
	      	$value = $result[$i][$column];

		if($selected == null) {
		      	$outText .= "<option value='".$value."'>".$value."</option>";
			}
		else
			{
			if(strcmp($value, $selected) == 0)
				$outText .= "<option value='".$value."' selected>".$value."</option>";
			else
				$outText .= "<option value='".$value."'>".$value."</option>";
			}
	      	}

	return $outText;
	}

// ------------------------------------------------------------------------------------

function returnConnection() {
	global $dbUser, $dbPassword, $dbServer;

	$con = OCILogon($dbUser, $dbPassword, $dbServer);
  		if ( ! $con ) {
    			echo "Unable to connect: " . var_dump( OCIError() );
		exit;
  			}

	return $con;
	}

function executeSQL($sql) {

	global $statusXML, $errorMsg, $errorXML, $dbUser, $dbPassword, $dbServer;

	$con = OCILogon($dbUser, $dbPassword, $dbServer);
  		if ( ! $con ) {
    			$errorMsg = "Unable to connect: " . var_dump( OCIError() );
    			return FALSE;
  			}

	$stmt = OCIParse($con, $sql);
	OCIExecute($stmt, OCI_DEFAULT);

	$error = OCIError ($stmt);
	if ($error["offset"]) {
        		$errorMsg = substr ($error["sqltext"], 0, $error["offset"]).'*'.substr ($error["sqltext"], $error["offset"]);
        		return FALSE;
		}

	// Commit to save changes...
  		OCICommit($con);

  		// Logoff from Oracle...
  	OCILogoff($con);
	}

// ------------------------------------------------------------------------------------

function generateControlHTML($viewMapping, $element, $isHeader) {

	$ctlHTML = "";

	// Write out the question description
	$title = $element->description[0]->tagData;
	$helpPageURL = $element->helppageurl[0]->tagData;
	$nolinebreak = $element->nolinebreak;
	$validationScript = $element->validationscript;
	$noSubmit = $element->nosubmit;

	if(count($element->noheaderdatacarryover) > 0)
		$noDataCarryOver = TRUE;
	else
		$noDataCarryOver = FALSE;


	if(check_not_empty($title) == TRUE) { 
		$ctlHTML .= "<p style='font-weight:bold;font-size:100%;'";
		if(count($nolinebreak) == 1) { $ctlHTML .= " style='padding-right:10px;display:inline;' "; }
		$ctlHTML .= "><label onfocus='blur();' ";

		if(count($element->control) > 0) 
			$ctlHTML .= " for='".$element->control[0]->column[0]->tagData."' ";


		$ctlHTML .= ">".$title;

		if(check_not_empty($helpPageURL) == TRUE) { $ctlHTML .= "   <span style='cursor:hand' onclick=\"window.open('".$helpPageURL."', 'help', 'width=350,height=420,status=0,toolbar=0,location=0,menubar=0,resizable=1,scrollbars=1');\"> [ ? ] </span> "; }

		$ctlHTML .= "</label></p>\n"; 
		}


	// See if this element contains an inline document
	if(count($element->inlinedocument) > 0 && 
	   count($element->inlinedocument[0]->documentkey) > 0 &&
	   count($element->inlinedocument[0]->source) > 0) {

		$ctlHTML .= "<div id='".$element->inlinedocument[0]->documentkey[0]->tagData."' style='margin:0px;padding:0px;width:100%;background:#ffffff;' >";

		// Add a javascript variable identifying this inline documents content
		$ctlHTML .= "<script type='text/javascript'>\n<!--\n var inlineDocumentContext = '".$element->inlinedocument[0]->documentkey[0]->tagData."'; \n --></script>\n\n";

		// Inject the inline document into the div
		$inlineDoc = $element->inlinedocument[0]->source[0]->tagData;
		$ctlHTML .= file_get_contents($inlineDoc);

		$ctlHTML .= "</div>\n";
		}

	// Scan through all each of the control blocks in this element
	for($i=0; $i<count($element->control); $i++) {

		$ctlType = $element->control[$i]->type[0]->tagData;
		$posttext = $element->control[$i]->posttext[0]->tagData;
		$pretext = $element->control[$i]->pretext[0]->tagData;
		$column = $element->control[$i]->column[0]->tagData;
		$data = $element->control[$i]->data[0]->tagData;
		$limit = $element->control[$i]->limit[0]->tagData;
		$rows = $element->control[$i]->rows[0]->tagData;
		$cols = $element->control[$i]->cols[0]->tagData;			
		$nolinebreak = $element->control[$i]->nolinebreak;			
		$controlSize = $element->control[$i]->controlsize[0]->tagData;			
		$defaultValue = $element->control[$i]->defaultvalue[0]->tagData;						
		$onSubmitScript = $element->control[$i]->onsubmitscript;

		// The column names are uppercased and trimmed
		$column = trim(strtoupper($column));

		// Write out any text coming before this element
		if(check_not_empty($pretext) == TRUE) { 
			$ctlHTML .= "<label class='small' style='margin-right:8px;'>".$pretext."</label>"; 
			}		

		switch($ctlType) {

			case "NEWDROPDOWN":
				$ctlHTML .= "<select id='".$column."' name='".$column."' style='font-family:monospace;font-size:9pt;'>";

				for($k=0; $k<count($element->control[$i]->option); $k++) {
					$ctlHTML .= "<option value='".$element->control[$i]->option[$k]->tagData."'>".$element->control[$i]->option[$k]->tagData." </option>\n";
					}

				// Get the dynamic data if its requested for this control
				if(check_not_empty($data) == TRUE) { 
					if($isHeader == TRUE && isset($_SESSION[$column]) == TRUE)
						$ctlHTML .= provideDynamicData($viewMapping, $element, $data, $_SESSION[$column]); 
					else
						$ctlHTML .= provideDynamicData($viewMapping, $element, $data); 
					}

				$ctlHTML .= "</select><input type='button' value='New' id='".$column."-NEWBTN' onclick='newDropDownValue(\"$column\");' />\n";

				$ctlHTML .= "<input type='text' class='specialforminput2' value='new value' id='".$column."-NEW' name='".$column."-NEW' style='display:none' ";
				if(check_not_empty($limit) == TRUE && check_not_empty($controlSize) == FALSE) { $ctlHTML .= "maxLength='".$limit."' size='".$limit."' "; }
				if(check_not_empty($controlSize) == TRUE) { $ctlHTML .= "size='".$controlSize."' maxlength='".$limit."' "; }
				$ctlHTML .= " /><br/>";

				$ctlHTML .= "<input type='button' value='Select Previous' id='".$column."-selbtn' onclick='previousDropDownValue(\"$column\");' style='display:none' />\n";

				// Generate a hidden status field ONLY if the browser supports javascript
				if($isHeader == FALSE) {
					$ctlHTML .= "  <script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$column."-status\" style=\"font-size:50%;display:none\" ></span>'); \n --></script>";
					}
				break;


			case "DROPDOWN":
				$ctlHTML .= "<select id='".$column."' name='".$column."' style='font-family:monospace;font-size:9pt;' ";

				if($isHeader == FALSE) { $ctlHTML .= " onfocus='selectCTL(\"".$column."\");' "; }
				if($isHeader == FALSE && count($noSubmit) == 0) { $ctlHTML .= " onchange='sendSingleValue(\"".$column."\", \"".$column."\", \"DROPDOWN\", this.options[this.selectedIndex].value);' "; } else { $ctlHTML .= " onChange='convertToUpperCase(this);' "; }
				$ctlHTML .= ">";

				for($k=0; $k<count($element->control[$i]->option); $k++) {
					if(count($element->control[$i]->option[$k]->value) > 0)
						$ctlHTML .= "<option value='".$element->control[$i]->option[$k]->value[0]->tagData."'>".$element->control[$i]->option[$k]->tagData." </option>\n";
					else
						$ctlHTML .= "<option value='".$element->control[$i]->option[$k]->tagData."'>".$element->control[$i]->option[$k]->tagData." </option>\n";
					}

				// Get the dynamic data if its requested for this control
				if(check_not_empty($data) == TRUE) { 
					if($isHeader == TRUE && isset($_SESSION[$column]) == TRUE)
						$ctlHTML .= provideDynamicData($viewMapping, $element, $data, $_SESSION[$column]); 
					else
						$ctlHTML .= provideDynamicData($viewMapping, $element, $data); 
					}

				$ctlHTML .= "</select>\n";

				// Generate a hidden status field ONLY if the browser supports javascript
				if($isHeader == FALSE) {
					$ctlHTML .= "  <script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$column."-status\" style=\"display:none\" ></span>'); \n --></script>";
					}
				break;


			case "TEXTFIELD":
				$ctlHTML .= "<input class='specialforminput2' type='text' id='".$column."' name='".$column."' ";
				if($isHeader == FALSE) { $ctlHTML .= " onfocus='selectCTL(\"".$column."\");' "; }

				if($isHeader == FALSE) { 
					$ctlHTML .= " onchange='";
					if(count($onSubmitScript) > 0) { $ctlHTML .= " ".$onSubmitScript[0]->tagData." "; }
					if(count($validationScript) > 0) { $ctlHTML .= " ".$validationScript[0]->tagData." "; }
					if(count($noSubmit) == 0) { $ctlHTML .= " sendSingleValue(\"".$column."\", \"".$column."\", \"TEXTFIELD\", this.value); "; }
					$ctlHTML .= "' ";  
					} else { $ctlHTML .= " onChange='convertToUpperCase(this);' "; }

				// If there was a previous header-value entered, then display it in this field
				if($isHeader == TRUE && $noDataCarryOver == FALSE && isset($_SESSION[$column]) == TRUE ) { 
					$ctlHTML .= "value='".$_SESSION[$column]."' ";
					} 
				else
					{
					if(check_not_empty($defaultValue) == TRUE) { $ctlHTML .= "value='".$defaultValue."' "; }
					}

				if(check_not_empty($limit) == TRUE && check_not_empty($controlSize) == FALSE) { $ctlHTML .= "maxLength='".$limit."' size='".$limit."' "; }
				if(check_not_empty($controlSize) == TRUE) { $ctlHTML .= "size='".$controlSize."' maxlength='".$limit."' "; }

				if(check_not_empty($data) == TRUE) { $ctlHTML .= " value='".provideDynamicData($viewMapping, $element, $data)."' "; }
				$ctlHTML .= " />\n ";

				if($element->control[$i]->displaylimit)
					$ctlHTML .= "<br/><label class='small'> ".$limit." characters max </label>\n";

				// Generate a hidden status field ONLY if the browser supports javascript
				if($isHeader == FALSE) {
					$ctlHTML .= "  <script type='text/javascript'>\n<!--\n document.writeln('<div id=\"".$column."-status\" style=\"display:none\" >*</div>'); \n --></script>";
					}
				break;

			case "TEXTAREA":
				if(check_not_empty($rows) == FALSE) { $rows = 6; }
				if(check_not_empty($cols) == FALSE) { $cols = 50; }

				$ctlHTML .= "<textarea name='".$column."' id='".$column."' cols='".$cols."' rows='".$rows."' ";
				if($isHeader == FALSE) { $ctlHTML .= " onfocus='selectCTL(\"".$column."\");' "; }
				if($isHeader == FALSE && count($noSubmit) == 0) { $ctlHTML .= " onchange='if(checkLength(".$limit.", \"".$column."\") == true) { sendSingleValue(\"".$column."\", \"".$column."\", \"TEXTAREA\", this.value); }' "; }
				$ctlHTML .= ">";

				if(check_not_empty($data) == TRUE) { $ctlHTML .= provideDynamicData($data); }
				$ctlHTML .= "</textarea>\n";

				if($element->control[$i]->displaylimit)
					$ctlHTML .= "<br/><label> ".$limit." characters max </label>\n";

				// Generate a hidden status field ONLY if the browser supports javascript
				if($isHeader == FALSE) {
					$ctlHTML .= "  <script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$column."-status\" style=\"display:none\" >*</span>'); \n --></script>";
					}
				break;

			case "RADIO":
				for($k=0; $k<count($element->control[$i]->option); $k++) {

					// See if the mapping specifies a custom value of this radio button... use this in the value="" attribute
					// If there is no value specified in the XML, then use the option text as the value

					$id = "".$column."-".$k;
					$radioValue = $element->control[$i]->option[$k]->tagData;
					if(count($element->control[$i]->option[$k]->value) > 0)
						$radioValue = $element->control[$i]->option[$k]->value[0]->tagData;

					// Build the HTML for this control
					$ctlHTML .= "<input type='radio' name='".$column."' id='$id' ";
					if($isHeader == FALSE) { $ctlHTML .= " onFocus='selectCTL(\"$id\");' "; }
					if($isHeader == FALSE && count($noSubmit) == 0) { $ctlHTML .= " onclick='sendSingleValue(\"".$column."\", \"$id\", \"RADIO\", this.value);' "; }
					$ctlHTML .= " value=\"".$radioValue."\" ";

					if($isHeader == TRUE && isset($_SESSION[$column]) == TRUE && strcmp($_SESSION[$column], $element->control[$i]->option[$k]->tagData) == 0 ) { $ctlHTML .= " checked='yes' "; }

					$ctlHTML .= " />";

					$ctlHTML .= "<label for='$id'>".$element->control[$i]->option[$k]->tagData."</label>\n";

					// Generate a hidden status field ONLY if the browser supports javascript
					if($isHeader == FALSE) {
						$ctlHTML .= "<script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$column."-".$k."-status\" style=\"display:none\" >*</span>'); \n --></script>";
						}

					if(count($nolinebreak) == 0) { $ctlHTML .= "<br/>"; } else { $ctlHTML .= " "; }
					}

				break;

			case "CHECKBOXES":
				$ctlHTML .= "<div style='text-align:left;'>"; 
				for($k=0; $k<count($element->control[$i]->checkbox); $k++) {
					$ctl = $element->control[$i]->checkbox[$k];

					// Generate a hidden status field ONLY if the browser supports javascript
					if($isHeader == FALSE) {
						$ctlHTML .= "<script type='text/javascript'>\n<!--\n document.writeln('<span id=\"".$ctl->column[0]->tagData."-status\" style=\"display:none\" >*</span>'); \n --></script>";
						}

					$ctlHTML .= "<input type='checkbox' name='".$ctl->column[0]->tagData."' id='".$ctl->column[0]->tagData."'";
					if($isHeader == FALSE && count($noSubmit) == 0) { $ctlHTML .= " onclick='selectCTL(\"".$ctl->column[0]->tagData."\"); sendSingleValue(\"".$ctl->column[0]->tagData."\", \"".$ctl->column[0]->tagData."\", \"CHECKBOX\", this.checked);' "; }
					$ctlHTML .= "\>\n";

					$ctlHTML .= "<label for='".$ctl->column[0]->tagData."'>".$ctl->title[0]->tagData." </label><br/>\n";
					}

				$ctlHTML .= "</div>";
				break;
			}

		// Write out any text coming before this element
		if(check_not_empty($posttext) == TRUE) { 
			$ctlHTML .= "  <label class='small' style='margin-right:8px;'>".$posttext."</label>"; 
			}

		if(count($nolinebreak) == 0) { $ctlHTML .= "<br/>\n"; }
		}

	return $ctlHTML;
	}

// ------------------------------------------------------------------------------------

function check_not_empty($s, $include_whitespace = false)
{
    if ($include_whitespace) {
        // make it so strings containing white space are treated as empty too
		$s = trim($s);	
    }
    return (isset($s) && strlen($s)); // var is set and not an empty string ''
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Expires" content="Tue, 01 Jan 2000 12:12:12 GMT" />
<meta http-equiv="Pragma" content="no-cache" />

<title>WebR On-line customer response form</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="WebR - on-line customer response form" />
<link href="../local-resources/styles/webr.css" rel="stylesheet" type="text/css" />

<!--[if IE]>
<style type="text/css"> 

/* place css fixes for all versions of IE in this conditional comment */
#sidebar1 { padding-top: 30px; }
#mainContent { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->            		

<script type='text/javascript' src='../libs/sarissa.js'></script>
<script type='text/javascript' src='../libs/mootools-1.2-core-yc.js'></script>
<script language="JavaScript" type="text/JavaScript">
<!--
	// ====================================================================================

	var activeCTL = null;
	var documentKey = null;

	// ====================================================================================

	function convertToUpperCase(fieldObject) {
		fieldObject.value = fieldObject.value.toUpperCase()
		}

	function checkLength(strlimit, column) {

		var field = document.getElementById(column);
		if(field.value.length > strlimit) { 
			alert("This field has exceeded it's maximum length by " + (field.value.length - strlimit) + " characters");
			field.style.background = '#ffaaaa';
			return false;
			}

		return true;
		}

	// ====================================================================================

	function sendSingleValue(column, id, type, value) {

		// Set the wait icon
		var saveText = "<label> Saving... <img src='../local-resources/images/ajaxwait.gif' />  </label>";
		document.getElementById(id + '-status').innerHTML = saveText;

		// The javascript urlencode method treats plus signs like spaces, so we need to convert them
		// into a unicode value before putting it through the js encoding
		if(type == "TEXTAREA" || type == "TEXTFIELD" || type == "RADIO") {

			var testVal = value;
			value = "";
			for(var i=0; i<testVal.length; i++) {
				if(testVal.charAt(i) == '+') { value += "%2B"; continue; }
				if(testVal.charAt(i) == "'") { value += "''"; continue; }
				value += testVal.charAt(i);
				}
			}

		// Build a url containing the value to be updated
		var URL = 'WEBRController.php?act=add1&doctype=<?php echo $docType;?>&key=' + documentKey + '&' + column + "=" + escape(value);
		var xmlhttp = new XMLHttpRequest(); 
		//alert("URL Query: " + URL);  
		xmlhttp.open("GET", URL, true);   
		xmlhttp.onreadystatechange = function() {   
		  	if(xmlhttp.readyState == 4) {

				var xmlDOC = Sarissa.getDomDocument();   
				xmlDOC = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml"); 

				// Change the colors of the control based on the server response
				var errorXML = xmlDOC.getElementsByTagName("Error");
				if(errorXML.length > 0) {
					document.getElementById(id).style.background = '#ffaaaa';

					alert(errorXML[0].text);
					document.getElementById(id + '-status').innerHTML = 'Error';
					}
				else
					{
					if(xmlDOC.getElementsByTagName("Success").length > 0) {							
						document.getElementById(id).style.background = '#aaffaa';
						document.getElementById(id + '-status').innerHTML = "<label><b>Saved</b>  </label>";

						// Fade out the save message
						setTimeout(function() { $(id + '-status').fade('out'); }, 1500); 
						setTimeout(function() { $(id + '-status').style.display='none'; }, 2200);
						}
					}
				}
			}; 

		xmlhttp.send('');   			
		}

	// ====================================================================================

	function sendHeader() {
		var headerForm = document.getElementById('headerform');
		var inputFields = headerForm.getElementsByTagName("input");
		for(var i=0; i<inputFields.length; i++) {
			if(inputFields[i].type == 'text')
				inputFields[i].style.background = '#ffffff';
			}


		var headerForm = document.getElementById('headerform');
		var query = Sarissa.formToQueryString(headerForm);
		var queryURL = 'WEBRController.php?' + query;
		//alert("Header Query: " + queryURL);
		var xmlhttp = new XMLHttpRequest();   
		xmlhttp.open("GET", queryURL, true);   

		xmlhttp.onreadystatechange = function() {   
		  	if(xmlhttp.readyState == 4) {

				var xmlDOC = Sarissa.getDomDocument();   
				xmlDOC = (new DOMParser()).parseFromString(xmlhttp.responseText, "text/xml"); 

				// Change the colors of the control based on the server response
				var errorXML = xmlDOC.getElementsByTagName("Error");
				if(errorXML.length > 0) {
					alert("Error: " + errorXML[0].text);

					// See if its a specific validation error
					if(xmlDOC.getElementsByTagName("ValidationError").length > 0) {
						var controlid = xmlDOC.getElementsByTagName("Column")[0].text;
						document.getElementById(controlid).style.background = '#ffaaaa';
						}

					alert("Error: " + errorXML[0].text);
					}
				else
					{
					// The header was sent and accepted, grab the document key to use
					var dockeyary = xmlDOC.getElementsByTagName("DocumentKey");
					if(dockeyary.length > 0) {
						documentKey = dockeyary[0].text;
						//alert("documentKey: " + documentKey);
						openBody();
						}
					else
						{
						alert("Response: " + xmlhttp.responseText);
						}
					}
				}
			}

		xmlhttp.send('');   			
		}

	// ====================================================================================

	function selectCTL(column) {

		if(column != null) {

			if(activeCTL != null && activeCTL != (column+"-status")) {
				var ctlName = activeCTL + "-status";

				if($(ctlName).innerHTML == '*') {
					document.getElementById(ctlName).style.display = 'none';
					}
				}

      				$(column + '-status').fade('show');
			document.getElementById(column).style.background = '#ffffff';
      				document.getElementById(column + '-status').innerHTML = '*';
      				document.getElementById(column + '-status').style.display = 'inline';
      				activeCTL = column;
      				}
		}

	// ====================================================================================

	function previousDropDownValue(column) {
		var dropdown = document.getElementById(column);
		var newTextField = document.getElementById(column + "-NEW");
		var newbutton = document.getElementById(column + "-NEWBTN");
		var selbutton = document.getElementById(column + "-SELBTN");

		// reset whatever the user previously input
		newTextField.value = "new value";

		dropdown.style.display = 'inline';
		newbutton.style.display = 'inline';
		newTextField.style.display = 'none';
		selbutton.style.display = 'none';
		}

	// ====================================================================================

	function newDropDownValue(column) {
		var dropdown = document.getElementById(column);
		var newTextField = document.getElementById(column + "-NEW");
		var newbutton = document.getElementById(column + "-NEWBTN");
		var selbutton = document.getElementById(column + "-SELBTN");

		dropdown.style.display = 'none';
		newbutton.style.display = 'none';
		newTextField.style.display = 'inline';
		selbutton.style.display = 'inline';

		newTextField.focus();
		newTextField.select();
		}


	// ====================================================================================

	function openBody() {
		var dropdowns = $('headerDIV').getElementsByTagName("select");
		for(var i=0; i<dropdowns.length; i++) {
			dropdowns[i].style.display = 'none';
			}

		$('headerDIV').fade('out');	
		$('SubmitHeaderBtn').fade('out');
		$('headerText').fade('out');

		setTimeout("$('SubmitHeaderBtn').style.display='none';", 800);
		setTimeout("$('headerDIV').tween('height', 0);", 500);
		setTimeout("$('headerDIV').style.display='none';", 1000);
		setTimeout("$('headerText').style.display='none';", 1000);

		$('bodyDIV').fade('hide');
		document.getElementById('bodyDIV').style.display = 'block';
		$('bodyDIV').fade('in');
		}


	// ====================================================================================

	function displayFinishedScreen() {			
		$('bodyDIV').style.display = 'none';
		$('FinalScreen').style.display = 'block'; 
		window.scroll(0,0);
		}

	// ====================================================================================

	function resize(iframedom) {

	try { var oBody = iframedom.document.documentElement;
                      var oframe = iframedom;			

		alert(iframedom.document.documentElement.clientHeight);
		alert(oBody.offsetHeight);
		alert(oBody.clientHeight);
		alert(oBody.scrollHeight);

		var calcheight = (oBody.offsetHeight - oBody.clientHeight);
		if(oBody.scrollHeight != null) { calcheight += oBody.scrollHeight; }

		oframe.style.height = calcheight;

		} catch(e) {
			window.status = 'Error: ' + e.number + '; ' + e.description;
			}
		}


	<?php
		// If this document specified any custom javascript in the VIEW XML then include it here
		if(count($customScript) > 0) { echo $customScript[0]->tagData; }
	?>
// -->
</script>


<?php
	// If the document includes and custom javascript libraries, then do it here
      		if(count($includeScripts) > 0) {
      		for($i=0; $i<count($includeScripts); $i++) {
      			echo "<script type='text/javascript' src='../libs/".$includeScripts[$i]->tagData."'></script>";
      			}
      		}
?>

</head>
<body>

<!-- start #container -->
<div id="container">
<!-- start #header -->
<div id="header">

</div>
<!-- end #header -->
<?php include_once("topbar.php"); ?>
<!-- start #mainContent -->
<div id="mainContent">

<h2><?php echo $documentType; ?></h2>

<!-- Write out the form header -->
<div style="text-align:center;">
<span id="headerText">Please complete this section before continuing...<br /></span>
<div id="headerDIV" class="list-box">
<form action="WEBRController.php" method="post" id='headerform' onsubmit="return false;">
<fieldset>
<input type='hidden' name='act' value='addheader' />
<input type='hidden' name='doctype' value='<?php echo $docType ?>' />

<div class="list-left" style="text-align:left;">
<?php   $breakPoint = FALSE;
	for($i=0; $i<count($headerBlock->element); $i++) {
		$headerElement = $headerBlock->element[$i];

		echo generateControlHTML($viewMapping, $headerElement, TRUE);
		if($i >= ((count($headerBlock->element)/2)-1) && $breakPoint == FALSE) { 
			$breakPoint = TRUE;
			echo "</div><div class='list-right'>"; 
			}
		} 
?>
</div>

</fieldset>

<input type='button' onClick='sendHeader();' id='SubmitHeaderBtn' value='Start Survey' class='Submit' />

</form>
</div>
</div>

<!-- Write out the body -->
<div id="bodyDIV" style="display:none">
<script type='text/javascript'>
<!--
	document.writeln("<div style='text-align:center;'><div style='text-align:left;'><small class='surveyheadertext'>After answering a question, tab or click off the answer box to automatically save that entry. The field will turn green to represent a successful save. An asterisk mark indicates the currently selected field. </small></div></div>");
-->
</script>
<noscript>
	Your information will not save until you click the "Submit Entire Form" button
</noscript>

	<?php 	for($i=0; $i<count($bodyBlock->group); $i++) {
      			$groupBlock = $bodyBlock->group[$i];
      			$groupTitle = $groupBlock->title[0]->tagData;
      
      			echo "<fieldset>";
      			echo "<legend>".$groupTitle."</legend>";
      
      			for($k=0; $k<count($groupBlock->element); $k++) {
      				$groupElement = $groupBlock->element[$k];
      				if(($k % 2) == 1) { echo "<div class='altform-g'>"; }
      
      				echo generateControlHTML($viewMapping, $groupElement, FALSE);
      
      				if(($k % 2) == 1) { echo "</div>"; }

      				}
      
      			echo "</fieldset>";

      			}
	?>

<div style="text-align:center;">
	<br />
	<input type="button" id='FinalSubmitBTN' class='Submit' onClick='displayFinishedScreen(); return false;' value="Finish Survey" />
</div>
</div>
</fieldset>
</div>

<!-- ************************************************************************************************ 
      FINAL SCREENS - The final screen contains the thank you message and optional "Enter Another ... "
      button, and optional "Go to WEBR Home" button. All of these values including button text are specified in the 
      document level of the View XML.
     ************************************************************************************************ -->


	<div style='display:none' id='FinalScreen'>
	<div style="text-align:center;"><strong><?php echo $completionMessage; ?></strong>
	<br /><br />

	<?php

	if($addButtonMsg != null) {
		echo "<input type='button' value='".$addButtonMsg."' onClick='window.open(\"WEBRView.php?doc=".$docType."\", \"_self\");'>";
		} 

	if($homeButtonMsg != null) {
		echo "<input type='button' value='".$homeButtonMsg."' onClick='window.open(\"WEBRView.php?doc=".$docType."\", \"_self\");'>";
		}
	?>
	<br /><br />
	</div>
	</div>


<?php
 include_once ("footer.php"); 
?> 
</div>
</body>
</html>

 

The php5 parser is located here: http://www.criticaldevelopment.net/xml/parser_php5.phps

 

WebIndex.xml looks like this:

 

<?xml version="1.0"?>
<WEBRIndex>
<Document>
	<DocumentKey>EP2010</DocumentKey>
	<Title>2010 Enterprise Program Customer Survey</Title>
	<ViewXML>ep2010-views.xml</ViewXML>
	<MappingXML>ep2010-mappings.xml</MappingXML>
</Document>
</WEBRIndex>

Link to comment
Share on other sites

I would guess you need some code before the line that fails which checks if $s is an XMLTag, and takes appropriate action if it is.  Did you write this code or are you porting someone else's code from php4 to php5?

Link to comment
Share on other sites

Hi thanks for the reply. This was written before I arrived at my current position. The person who wrote the PHP Parsing script, Adam Flynn, has been very helpful. He replied to me about passing Strings into the check_not_empty function. Which has worked to a certain extent. I am no longer getting errors, however, the XML isn't rendering in the page correctly yet.

 

So, this error is solved in all reality.

Link to comment
Share on other sites

I was just reading up on this post:

 

Passed by Reference

This is an important change. In PHP4, everything was passed by value, including objects. This has changed in PHP5 -- all objects are now passed by reference.

 

PHP Code:

$joe = new Person();

$joe->sex = 'male';

 

$betty = $joe;

$betty->sex = 'female';

 

echo $joe->sex; // Will be 'female' 

The above code fragment was common in PHP4. If you needed to duplicate an object, you simply copied it by assigning it to another variable. But in PHP5 you must use the new clone keyword.

 

Note that this also means you can stop using the reference operator (&). It was common practice to pass your objects around using the & operator to get around the annoying pass-by-value functionality in PHP4.

 

I guess this might have a lot to do with this script I am looking at...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.