NYCPHP Meetup

NYPHP.org

[nycphp-talk] addition to method/property/class problem

soazine at pop.erols.com soazine at pop.erols.com
Mon Oct 27 14:45:24 EST 2003


PHP version 4.1 in Linux Red Hat 9 with Apache ???

<?
  class ErrorMsgCollection {

	var $name;
	var $mandatory;
	var $emptyErr;
	var $maxLength;
	var $maxLengthErr;
	var $minLength;
	var $minLenghtErr;
	var $pattern;
	var $patternErr;
	var $arrayMandatoryAmountType;
	var $validArrayErr;
	var $isAssoc;
	var $erroredArrayAssocIndexArray;



	function ErrorMsgCollection() {
		$this->name = '';
		$this->arrayMandatoryAmountType = ''; // DEFAULT TO NULL
		$this->validArrayErr = $emptyErr; // DEFAULT TO SAME ERROR MSG AS EMPTY
ERR MSG
		$this->assocIndex = 0;	// DEFAULT TO 0 WILL BE USED AS INDEX KEY FOR
CONVERTING ERR ARRAY (IF INDICATED) TO ASSOCIATIVE
		$this->erroredArrayAssocIndexArray = array();
		return true;
	}

	function getErroredArrayAssocIndex($key) {
		return $this->erroredArrayAssocIndexArray[$key];
	}


	function getEmptyErr() {
		if ($this->getIsAssoc()) return $this->emptyErr . '~IsAssoc~' .
str_replace('~', '&#126;', $this->getErroredArrayAssocIndex($this->name));
		return $this->emptyErr;
	}

	function getIsAssoc() {
		return $this->isAssoc;
	}

	function getMandatory() {
		return $this->mandatory;
	}

	function getMaxLength() {
		return $this->maxLength;
	}

	function getMaxLengthErr() {
		if ($this->getIsAssoc()) return $this->emptyErr . '~IsAssoc~' .
str_replace('~', '&#126;', $this->getErroredArrayAssocIndex($this->name));
		return $this->maxLengthErr;
	}

	function getMinLength() {
		return $this->minLength;
	}

	function getMinLengthErr() {
		if ($this->getIsAssoc()) return $this->emptyErr . '~IsAssoc~' .
str_replace('~', '&#126;', $this->getErroredArrayAssocIndex($this->name));
		return $this->minLengthErr;
	}

	function getName() {
		return $this->name;
	}

	function getPattern() {
		return $this->pattern;
	}

	function getPatternErr() {
		if ($this->getIsAssoc()) return $this->emptyErr . '~IsAssoc~' .
str_replace('~', '&#126;', $this->getErroredArrayAssocIndex($this->name));
		return $this->patternErr;
	}

	function getValidArray() {
		return $this->arrayMandatoryAmountType;
	}

	function getValidArrayErr() {
		if ($this->getIsAssoc()) return $this->emptyErr . '~IsAssoc~' .
str_replace('~', '&#126;', $this->getErroredArrayAssocIndex($this->name));
		return $this->validArrayErr;
	}

	function setErroredArrayAssocIndex($arrayName, $assocIndex) {
	 	$this->erroredArrayAssocIndexArray = $this->erroredArrayAssocIndexArray
+ array($arrayName => $assocIndex);
	}

	function setIsAssoc($isAssoc) {
		$this->isAssoc = $isAssoc;
	}


	function setMandatory($mandatory,$emptyErr) {
		$this->mandatory = $mandatory;
		$this->emptyErr = $emptyErr;
	}

	function setMaxLength($maxLength,$maxLengthErr) {
		$this->maxLength = $maxLength;
		$this->maxLengthErr = $maxLengthErr;
	}

	function setMinLength($minLength,$minLengthErr) {
		$this->minLength = $minLength;
		$this->minLengthErr = $minLengthErr;
	}

	function setName($name) {
		$this->name = $name;
	}

	function setPattern($pattern,$patternErr) {
		$this->pattern = $pattern;
		$this->patternErr = $patternErr;
	}

	function setValidArray($arrayMandatoryAmountType,$validArrayErr) {
		$this->arrayMandatoryAmountType = $arrayMandatoryAmountType;
		$this->validArrayErr = $validArrayErr;
	}
  }

  class FormValidator {

	var $validator, $errors, $isValid;
	var $post, $errorMsgObjArray, $dateFormfieldsArray;

	function FormValidator($post, $errorMsgObjArray, $dateFormFieldsArray =
array()) {
		$this->validator = null;
		$this->errors = array();
		$this->isValid = true;
		$this->post = $post;
		$this->errorMsgObjArray = $errorMsgObjArray;
		$this->dateFormFieldsArray = $dateFormFieldsArray;
	}

	function getErrorArray() {
		return $this->errors;
	}

	function isValid() {
		foreach ($this->errorMsgObjArray as $key => $val) {
		 $name = $val->name;
		 print_r($name . "<P>");
		}
		return $this->isValid;
	}

  }
?>

--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .





More information about the talk mailing list