<?php
require_once "SiemensXMLElement.php";

class IppTextField extends SiemensXMLElement {

    private $text = "";
    
    const ConstraintANY = "ANY" ;
    const ConstraintNUMERIC = "NUMERIC" ; 
    const ConstraintPASSWORD = "PASSWORD" ; 
    const ConstraintPHONENUMBER = "PHONENUMBER "; 
    const ConstraintURL = "URL" ; 
    const ConstraintEMAILADDR = "EMAILADDR"; 

    const PasswordYES = "YES" ; 
    const PasswordNO = "NO" ; 

    const DefaultNULL = "NULL"; 
    const DefaultTEXT = "TEXT" ; 
    const DefaultPHONENUMBER = "PHONENUMBER"; 

    const UneditableYES = "YES"; 
    const UneditableNO = "NO"; 
    
    public function __construct(
    		$key,
    		$maxSize = 30,
    		$constraint = IppTextField::ConstraintNUMERIC,
    		$password = IppTextField::PasswordNO,
    		$default = IppTextField::DefaultTEXT,
    		$uneditable = IppTextField::UneditableNO
    		) {
        
    	$attributes = array();
        
        $attributes['MaxSize'] = $maxSize;
        $attributes['Constraint'] = $constraint;
        $attributes['PASSWORD'] = $password;
        $attributes['Default'] = $default;
        $attributes['Key'] = $key;
        $attributes['Uneditable'] = $uneditable;
        
        parent::__construct($attributes);
    }
    
    public function renderXMLBeforeChildsHook(xmlWriter &$xw) {
        $xw->text($this->text);
    }   
    
    protected function name() {
        return "IppTextField";
    }
    
} 
