<commit_before><?php
/**
 * @file class.charField.php
 * @brief Contiene la classe charField
 *
 * @copyright 2005 Otto srl (http://www.opensource.org/licenses/mit-license.php) The MIT License
 * @author <NAME> <EMAIL>
 * @author abidibo <EMAIL>
 */

/**
 * @brief Campo di tipo CHAR (CHAR, VARCHAR)
 * 
 * Tipologie di input associabili: testo, campo nascosto, textarea
 *
 * @copyright 2005 Otto srl (http://www.opensource.org/licenses/mit-license.php) The MIT License
 * @author <NAME> <EMAIL>
 * @author abidibo <EMAIL>
 */
class charField extends field {

	/**
	 * Proprietà dei campi specifiche del tipo di campo
	 */
	protected $_trnsl;
	
	/**
	 * Costruttore
	 * 
	 * @param array $options array associativo di opzioni del campo del database
	 *   - opzioni generali definite come proprietà nella classe field()
	 *   - @b trnsl (boolean): campo con traduzioni
	 * @return void
	 */
	function __construct($options) {

		parent::__construct($options);
		
		$this->_default_widget = 'text';
		$this->_value_type = 'string';
		
		$this->_trnsl = isset($options['trnsl']) ? $options['trnsl'] : true;
	}
	
	public function getTrnsl() {
		
		return $this->_trnsl;
	}
	
	public function setTrnsl($value) {
		
		if(is_bool($value)) $this->_trnsl = $value;
	}
	
	/**
	 * Stampa l'elemento del form
	 * 
	 * @param object $form
	 * @param array $options opzioni dell'elemento del form
	 * @return string
	 */
	public function formElement($form, $options) {
		
		if(!isset($options['trnsl'])) $options['trnsl'] = $this->_trnsl;
		if(!isset($options['field'])) $options['field'] = $this->_name;
		
		return parent::formElement($form, $options);
	}
}
?>
<commit_msg>La ricerca sui campi di tipo char/varchar è stata estesa utilizzando la condizione "LIKE"<commit_after><?php
/**
 * @file class.charField.php
 * @brief Contiene la classe charField
 *
 * @copyright 2005 Otto srl (http://www.opensource.org/licenses/mit-license.php) The MIT License
 * @author <NAME> <EMAIL>
 * @author abidibo <EMAIL>
 */

/**
 * @brief Campo di tipo CHAR (CHAR, VARCHAR)
 * 
 * Tipologie di input associabili: testo, campo nascosto, textarea
 *
 * @copyright 2005 Otto srl (http://www.opensource.org/licenses/mit-license.php) The MIT License
 * @author <NAME> <EMAIL>
 * @author abidibo <EMAIL>
 */
class charField extends field {

	/**
	 * Proprietà dei campi specifiche del tipo di campo
	 */
	protected $_trnsl;
	
	/**
	 * Costruttore
	 * 
	 * @param array $options array associativo di opzioni del campo del database
	 *   - opzioni generali definite come proprietà nella classe field()
	 *   - @b trnsl (boolean): campo con traduzioni
	 * @return void
	 */
	function __construct($options) {

		parent::__construct($options);
		
		$this->_default_widget = 'text';
		$this->_value_type = 'string';
		
		$this->_trnsl = isset($options['trnsl']) ? $options['trnsl'] : true;
	}
	
	public function getTrnsl() {
		
		return $this->_trnsl;
	}
	
	public function setTrnsl($value) {
		
		if(is_bool($value)) $this->_trnsl = $value;
	}
	
	/**
	 * @see field::filterWhereClause()
	 */
	public function filterWhereClause($value) {

		$value = str_replace("'", "''", $value);
		
		if(preg_match("#^\"([^\"]*)\"$#", $value, $matches))
			$condition = "='".$matches[1]."'";
		elseif(preg_match("#^\"([^\"]*)$#", $value, $matches))
			$condition = " LIKE '".$matches[1]."%'";
		else
			$condition = " LIKE '%".$value."%'";
		
		return $this->_table.".".$this->_name.$condition;
	}
	
	/**
	 * Stampa l'elemento del form
	 * 
	 * @see field::formElement()
	 */
	public function formElement($form, $options) {
		
		if(!isset($options['trnsl'])) $options['trnsl'] = $this->_trnsl;
		if(!isset($options['field'])) $options['field'] = $this->_name;
		
		return parent::formElement($form, $options);
	}
}
?>

{'fraction_non_alphanumeric': 0.17122378550570747, 'fraction_numerical': 0.004778338200159278, 'mean_word_length': 3.7938931297709924, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7305348', 'n_tokens_mistral': 1413, 'n_tokens_neox': 1278, 'n_words': 316}