<commit_before><?php

// $Id$

require_once $config->get('sysRoot').'alpha/util/handle_error.inc';

require_once $config->get('sysRoot').'alpha/model/types/String.inc';

/**
* String HTML input box custom widget
* 
* @package Alpha Widgets
* @author <NAME> <<EMAIL>>
* @copyright 2006 <NAME>
*  
*/
class string_box
{
	/**
	 * the string object that will be edited by this text box
	 * @var string
	 */
	var $string_object;
	/**
	 * the data label for the string object
	 * @var string
	 */
	var $label;
	/**
	 * the name of the HTML input box
	 * @var string
	 */
	var $name;
	/**
	 * the display size of the input box
	 * @var int
	 */
	var $size;
	
	/**
	 * the constructor
	 * @param String $string the string object that will be edited by this text box
	 * @param string $label the data label for the string object
	 * @param string $name the name of the HTML input box
	 * @param string $form_id the id of the form that contains this string box
	 * @param int $size the display size (characters)
	 * @param bool $table_tags determines if table tags are also rendered for the string_box
	 */
	function string_box($string, $label, $name, $form_id, $size=0, $table_tags=true) {
		$this->set_string_object($string);
		$this->set_label($label);
		$this->set_name($name);
		if (!empty($form_id))
			$this->set_form_id($form_id);
		else
			$this->render_javascript();
		$this->set_size($size);
		
		$this->render($table_tags);
	}
	
	/**
	 * renders the HTML and javascript for the string box
	 * @param bool $table_tags determines if table tags are also rendered for the string_box
	 */
	function render($table_tags=true) {
		$string_obj = $this->get_string_object(); 
		if ($table_tags) {
			echo '<tr><td style="width:25%;">';
			echo $this->get_label();
			echo '</td>';
	
			echo '<td>';
			echo '<input '.($string_obj->check_is_password()? 'type="password"':'type="text"').($this->size == 0 ? ' style="width:100%;"' : ' size="'.$this->size.'"').' maxlength="'.$string_obj->get_MAX_SIZE().'" name="'.$this->get_name().'" id="'.$this->get_name().'" value="'.((isset($_POST[$this->get_name()]) && $string_obj->get_value() == "")? $_POST[$this->get_name()] : $string_obj->get_value()).'"/>';
			echo '</td></tr>';
		}else{
			echo '<input '.($string_obj->check_is_password()? 'type="password"':'type="text"').($this->size == 0 ? ' style="width:100%;"' : ' size="'.$this->size.'"').' maxlength="'.$string_obj->get_MAX_SIZE().'" name="'.$this->get_name().'" id="'.$this->get_name().'" value="'.((isset($_POST[$this->get_name()]) && $string_obj->get_value() == "")? $_POST[$this->get_name()] : $string_obj->get_value()).'"/>';
		}
	}
	
	/**<commit_msg>Added support for read_only paramater<commit_after><?php

// $Id$

require_once $config->get('sysRoot').'alpha/util/handle_error.inc';

require_once $config->get('sysRoot').'alpha/model/types/String.inc';

/**
* String HTML input box custom widget
* 
* @package Alpha Widgets
* @author <NAME> <<EMAIL>>
* @copyright 2008 <NAME>
*  
*/
class string_box
{
	/**
	 * the string object that will be edited by this text box
	 * @var string
	 */
	var $string_object;
	/**
	 * the data label for the string object
	 * @var string
	 */
	var $label;
	/**
	 * the name of the HTML input box
	 * @var string
	 */
	var $name;
	/**
	 * the display size of the input box
	 * @var int
	 */
	var $size;
	
	/**
	 * the constructor
	 * @param String $string the string object that will be edited by this text box
	 * @param string $label the data label for the string object
	 * @param string $name the name of the HTML input box
	 * @param string $form_id the id of the form that contains this string box
	 * @param int $size the display size (characters)
	 * @param bool $table_tags determines if table tags are also rendered for the string_box
	 * @param bool $read_only set to true to make the text box readonly (defaults to false)
	 */
	function string_box($string, $label, $name, $form_id, $size=0, $table_tags=true, $read_only=false) {
		$this->set_string_object($string);
		$this->set_label($label);
		$this->set_name($name);
		if (!empty($form_id))
			$this->set_form_id($form_id);
		else
			$this->render_javascript();
		$this->set_size($size);
		
		$this->render($table_tags, $read_only);
	}
	
	/**
	 * renders the HTML and javascript for the string box
	 * @param bool $table_tags determines if table tags are also rendered for the string_box
	 * @param bool $read_only set to true to make the text box readonly (defaults to false)
	 */
	function render($table_tags=true, $read_only=false) {
		$string_obj = $this->get_string_object(); 
		if ($table_tags) {
			echo '<tr><td style="width:25%;">';
			echo $this->get_label();
			echo '</td>';
	
			echo '<td>';
			echo '<input '.($string_obj->check_is_password()? 'type="password"':'type="text"').($this->size == 0 ? ' style="width:100%;"' : ' size="'.$this->size.'"').' maxlength="'.$string_obj->get_MAX_SIZE().'" name="'.$this->get_name().'" id="'.$this->get_name().'" value="'.((isset($_POST[$this->get_name()]) && $string_obj->get_value() == "")? $_POST[$this->get_name()] : $string_obj->get_value()).'"'.($read_only ? 'readonly class="readonly"' : '').'/>';
			echo '</td></tr>';
		}else{
			echo '<input '.($string_obj->check_is_password()? 'type="password"':'type="text"').($this->size == 0 ? ' style="width:100%;"' : ' size="'.$this->size.'"').' maxlength="'.$string_obj->get_MAX_SIZE().'" name="'.$this->get_name().'" id="'.$this->get_name().'" value="'.((isset($_POST[$this->get_name()]) && $string_obj->get_value() == "")? $_POST[$this->get_name()] : $string_obj->get_value()).'"'.($read_only ? 'readonly class="readonly"' : '').'/>';
		}
	}
	
	/**
{'fraction_non_alphanumeric': 0.20495575221238937, 'fraction_numerical': 0.005309734513274336, 'mean_word_length': 4.281308411214953, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 89, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3286056', 'n_tokens_mistral': 2023, 'n_tokens_neox': 1876, 'n_words': 491}