<commit_before><?php

class ffInput extends ffObject implements ffiControl{
    protected $allowedProperties = array('id'       => array('type' => 'string'),
                                         'label'    => array('type' => 'string'),
                                         'lines'    => array('type' => 'u+int', 'default' => 1),
                                         'cols'     => array('type' => 'u+int', 'default' => 15),
                                         'maxlength'=> array('type' => 'uint', 'default' => 0),
                                         'password' => array('type' => 'bool', 'default' => false),
                                         'value'    => array('type' => 'string', 'default' => ''),
                                         'flags'    => array('type' => 'array', 'default' => array()),
                                         'regex'    => array('type' => 'string', 'default' => ''),
                                         'required' => array('type' => 'bool',  'default' => false),
                                         'error'    => array('type' => 'string',  'default' => ''),
                                         'ffPhp'    => array('type' => 'object'));
    
    public function __construct($id = null, $label = null) {
        if(isset($id))
            $this->id = $id;
        
        if(isset($label))
            $this->label = $label;
    }
    
    public function GetHtml() {
        $this->CheckProperties();
        $r = '';
        
        $r .= '<label for="'.$this->id.'">'.$this->HSC($this->label);
        
        if(isset($this->required))
            $r .= ' <em title="Required field!">*</em>';
        
        $r .= '</label>'.LF;
        
        if($this->lines > 1) { //textarea
            $r .= '<textarea id="'.$this->id.'" name="'.$this->id.'"'.
                  ' cols="'.$this->cols.'" rows="'.$this->lines.'"';
            
            if(isset($this->flags))
                $r .= SP.$this->FlagsToHtml($this->flags);
            
            if(isset($this->error))
                $r .= ' class="ffphp-error"';
            
            $r .= '>';
            
            if(isset($this->value))
                $r .= $this->HSC($this->value);
            
            $r .= '</textarea>'.LF;
        } else { //input
            $r .= '<input id="'.$this->id.'" name="'.$this->id.'"';
            
            if($this->password)
                $r .= ' type="password"';
            else
                $r .= ' type="text"';
            
            if(isset($this->value))
                $r .= ' value="'.$this->HSC($this->value).'"';
            
            if(isset($this->maxlength))
                $r .= ' maxlength="'.$this->maxlength.'"';
            
            if(isset($this->flags))
                $r .= SP.$this->FlagsToHtml($this->flags);
            
            if(isset($this->error))
                $r .= ' class="ffphp-error"';
            
            $r .= ' />'.LF;
        }
        
        if(isset($this->error))
            $r .= '<em class="ffphp-error">'.$this->HSC($this->error).'</em>'.LF;
        
        return $r;
    }
    
    public function IsComplete() {
        if($this->required && empty($this->ffPhp->req[$this->id])) {
            $this->error = '';
            return false;
        }
        
        if(!empty($this->ffPhp->req[$this->id]) && $this->regex &&
           !preg_match($this->regex, $this->ffPhp->req[$this->id])) {
            $this->error = '';<commit_msg>Do not display empty error message<commit_after><?php

class ffInput extends ffObject implements ffiControl{
    protected $allowedProperties = array('id'       => array('type' => 'string'),
                                         'label'    => array('type' => 'string'),
                                         'lines'    => array('type' => 'u+int', 'default' => 1),
                                         'cols'     => array('type' => 'u+int', 'default' => 15),
                                         'maxlength'=> array('type' => 'uint', 'default' => 0),
                                         'password' => array('type' => 'bool', 'default' => false),
                                         'value'    => array('type' => 'string', 'default' => ''),
                                         'flags'    => array('type' => 'array', 'default' => array()),
                                         'regex'    => array('type' => 'string', 'default' => ''),
                                         'required' => array('type' => 'bool',  'default' => false),
                                         'error'    => array('type' => 'string',  'default' => ''),
                                         'ffPhp'    => array('type' => 'object'));
    
    public function __construct($id = null, $label = null) {
        if(isset($id))
            $this->id = $id;
        
        if(isset($label))
            $this->label = $label;
    }
    
    public function GetHtml() {
        $this->CheckProperties();
        $r = '';
        
        $r .= '<label for="'.$this->id.'">'.$this->HSC($this->label);
        
        if(isset($this->required))
            $r .= ' <em title="Required field!">*</em>';
        
        $r .= '</label>'.LF;
        
        if($this->lines > 1) { //textarea
            $r .= '<textarea id="'.$this->id.'" name="'.$this->id.'"'.
                  ' cols="'.$this->cols.'" rows="'.$this->lines.'"';
            
            if(isset($this->flags))
                $r .= SP.$this->FlagsToHtml($this->flags);
            
            if(isset($this->error))
                $r .= ' class="ffphp-error"';
            
            $r .= '>';
            
            if(isset($this->value))
                $r .= $this->HSC($this->value);
            
            $r .= '</textarea>'.LF;
        } else { //input
            $r .= '<input id="'.$this->id.'" name="'.$this->id.'"';
            
            if($this->password)
                $r .= ' type="password"';
            else
                $r .= ' type="text"';
            
            if(isset($this->value))
                $r .= ' value="'.$this->HSC($this->value).'"';
            
            if(isset($this->maxlength))
                $r .= ' maxlength="'.$this->maxlength.'"';
            
            if(isset($this->flags))
                $r .= SP.$this->FlagsToHtml($this->flags);
            
            if(isset($this->error))
                $r .= ' class="ffphp-error"';
            
            $r .= ' />'.LF;
        }
        
        if($this->error)
            $r .= '<em class="ffphp-error">'.$this->HSC($this->error).'</em>'.LF;
        
        return $r;
    }
    
    public function IsComplete() {
        if($this->required && empty($this->ffPhp->req[$this->id])) {
            $this->error = '';
            return false;
        }
        
        if(!empty($this->ffPhp->req[$this->id]) && $this->regex &&
           !preg_match($this->regex, $this->ffPhp->req[$this->id])) {
            $this->error = '';
{'fraction_non_alphanumeric': 0.2054910840645344, 'fraction_numerical': 0.001415227851684121, 'mean_word_length': 1.1611620795107034, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 185, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 44, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '337649', 'n_tokens_mistral': 1908, 'n_tokens_neox': 1887, 'n_words': 311}