95 lines
2.4 KiB
PHP
95 lines
2.4 KiB
PHP
<?php
|
||
|
||
include_once ('datatypes.inc.php') ;
|
||
include_once ('errors.inc.php') ;
|
||
|
||
/**
|
||
* Classe faisant abstraction d'un champ utilisateur
|
||
*
|
||
* @package PlatosClient
|
||
* @name CPCUserField
|
||
*/
|
||
class CPCUserField
|
||
{
|
||
|
||
/**
|
||
* @var string Code interne du champ utilisateur
|
||
* @access public
|
||
*/
|
||
public $zCode ;
|
||
|
||
/**
|
||
* @var string Lib<69>ll<6C> du champ utilisateur
|
||
* @access public
|
||
*/
|
||
public $zLabel ;
|
||
|
||
/**
|
||
* @var int Type du champs
|
||
* @access public
|
||
*/
|
||
public $iType ;
|
||
|
||
/**
|
||
* @var string Motif de v<>rification du champ sous forme d'expression r<>guli<6C>re
|
||
* @access public
|
||
*/
|
||
public $zPattern ;
|
||
|
||
/**
|
||
* @var string Valeur du champ
|
||
* @access public
|
||
*/
|
||
public $zValue ;
|
||
|
||
/**
|
||
* Constructeur
|
||
*
|
||
* @param string $_zCode Code du champs tel que fourni dans PARAGAS
|
||
* @param int $_iType Type du champs
|
||
* @param string $_zPattern Motif du champs pour son validation dans la m<>thode check
|
||
* @param string $_zValue Valeur du champs
|
||
*/
|
||
public function __construct ($_zCode, $_iType = FIELDTYPE_TEXT, $_zPattern = "", $_zValue = "")
|
||
{
|
||
$this->zCode = $_zCode ;
|
||
$this->iType = $_iType ;
|
||
$this->zPattern = $_zPattern ;
|
||
$this->zValue = $_zValue ;
|
||
}
|
||
|
||
/**
|
||
* V<>rificaion de la conformit<69> interne du champs
|
||
*
|
||
* @return bool R<>sultat de la v<>rification de conformit<69>
|
||
*/
|
||
public function check ()
|
||
{
|
||
$bRet = true ;
|
||
if (preg_match ("/^[a-zA-Z0-9_]+$/", $this->zCode) === false)
|
||
{
|
||
$bRet = false ;
|
||
throw new Exception ("[FIELD : " . $this->zCode . "] >> Code de champ incorrect : [" . $this->zCode . "]") ;
|
||
}
|
||
if (trim ($this->zPattern) != "")
|
||
{
|
||
if (ereg ($this->zPattern, $this->zValue) === false)
|
||
{
|
||
$bRet = false ;
|
||
throw new Exception ("[FIELD : " . $this->zCode . "] >> Valeur de champ incorrect par rapport au motif") ;
|
||
}
|
||
}
|
||
if ($this->iType == FIELDTYPE_LIST)
|
||
{
|
||
if (ereg ("^[0-9]+$", $this->zValue) === false)
|
||
{
|
||
$bRet = false ;
|
||
throw new Exception ("[FIELD : " . $this->zCode . "] >> Valeur de champ incorrect pour un type LISTE") ;
|
||
}
|
||
}
|
||
return $bRet ;
|
||
}
|
||
|
||
}
|
||
|
||
?>
|