Location: PHPKode > scripts > Rapid Form Builder > rapid-form-builder/presentationLayer.php
<?php
session_start();

// accessKey works like this:
// if the field is:  usr1_username, and the Access Key should be the U in Username,
// then the access key is:  substr ($labelName, 4, 0) for the U 
// that will make the U have an underscore and be keystroke accessible for keyboard shortcutting
include 'checkClasses.php';

/*
$ajaxField = This is the field name that is used to break out all the relevant information
$accessPosition = Enables a keystroke shortcut for accessing each field. Linux users: hit Shift, Alt, <key> to select field
$fieldLength = self explanatory
$defaultValue = looks into the database, if there is no previously entered value, will display this one
$tabIndex = self explanatory
$sid = session ID, or whatever distinct number you need to pass.  could be a cookie i guess
$unique = does the field value submitted need to be unique?  such as Usernames and email addresses for registration
$minimumLength = tests to see if the field value meets a minumum length (e.g. 4 characters for usernames
*/


class presentationLayer {
	
	public function displayField ($ajaxField = '' , $accessPosition = '', $fieldLength = '20', $defaultValue = '', $tabIndex = '', $sid = '') {  
		$sid = $_SESSION['sid'] ;
		$this->ajaxField = $ajaxField; 
		$this->accessPosition = $accessPosition;
		$this->fieldLength = $fieldLength;
		$this->defaultValue = $defaultValue;
		$defaultValue = urldecode($defaultValue) ;
		$this->tabIndex = $tabIndex ; 
		$messageName = $ajaxField . "out" ;
		$mandatory = substr($ajaxField, 3, 1) ;
			if ($mandatory == "1" ) {
				$mandatory = "*" ; 				
			} 
			else 
			{ 
				$mandatory = "" ; 
			}		
		$fieldName = substr($ajaxField, 5) ; 
		$fieldLabel = manageData::getFieldLabel($fieldName) ;  
		$accessKey = substr($fieldLabel, $accessPosition, 1);
		$preAccessKey = substr($fieldLabel, 0, $accessPosition);
		$postAccessKey = substr($fieldLabel, ($accessPosition + 1));
		
		$mapTables = new manageData();
		$storedValue = $mapTables->getStoredValues($fieldName, $sid);
			if ( isset($storedValue) ) {
				$defaultValue = $storedValue ; 
				$defaultValue = urldecode($defaultValue) ;
			}		
		$displayField =  "
		<tr>
		<td class=\"mandatoryField\"> $mandatory </td>
				<td class=\"formLabel\">
					<LABEL FOR=\"$ajaxField\" accesskey=\"$accessKey\">$preAccessKey<u>$accessKey</u>$postAccessKey</LABEL>
				</td>
				<td class=\"formField\">
					<input id=\"$ajaxField\" type=\"text\" name=\"$ajaxField\"
					OnChange=\"CheckField(this)\" tabindex=\"$tabIndex\" value=\"$defaultValue\" size=\"$fieldLength\">
					<span id=\"$messageName\" class=\"message\"></span>
				</td>
				</tr>
		" ; 
		return $displayField ; 
	}
	
	
	public function displayTextArea ($ajaxField = '', $accessPosition = '', $fieldLength = '40', $fieldRows = '8', $defaultValue = '', $tabIndex = '' ) {  
		$sid = $_SESSION['sid'] ;
		$this->ajaxField = $ajaxField; 
		$this->accessPosition = $accessPosition;
		$this->fieldLength = $fieldLength;
		$this->fieldRows = $fieldRows ; 
		$this->defaultValue = $defaultValue;
		$defaultValue = urldecode($defaultValue) ;
		$this->tabIndex = $tabIndex ; 
		$messageName = $ajaxField . "out" ;
		$mandatory = substr($ajaxField, 3, 1) ;
			if ($mandatory == "1" ) {
				$mandatory = "*" ; 				
			} 
			else 
			{ 
				$mandatory = "" ; 
			}		
		$fieldName = substr($ajaxField, 5) ; 
		$fieldLabel = manageData::getFieldLabel($fieldName) ;  
		$accessKey = substr($fieldLabel, $accessPosition, 1);
		$preAccessKey = substr($fieldLabel, 0, $accessPosition);
		$postAccessKey = substr($fieldLabel, ($accessPosition + 1));
		
		$mapTables = new manageData();
		$storedValue = $mapTables->getStoredValues($fieldName, $sid);
			if ( isset($storedValue) ) {
				$defaultValue = $storedValue ; 
				$defaultValue = urldecode($defaultValue) ;
			}	
		$displayField =  "
		<td class=\"mandatoryField\"> $mandatory </td>
				<td class=\"formLabel\">
					<LABEL FOR=\"$ajaxField\" accesskey=\"$accessKey\">$preAccessKey<u>$accessKey</u>$postAccessKey</LABEL>
				</td>
				<td>
<textarea id=\"$ajaxField\" name=\"$ajaxField\" OnChange=\"CheckField(this)\" tabindex=\"$tabIndex\" cols=\"$fieldLength\" rows=\"$fieldRows\">$defaultValue</textarea>
					<span id=\"$messageName\" class=\"message\"></span>
				</td>
		" ; 
		return $displayField ; 
	}

	
	
}

?>
Return current item: Rapid Form Builder