<commit_before><?php if(!defined('PHORMS_ROOT')) { die('Phorms not loaded properly'); }
/**
 * @package Phorms
 * @subpackage Fields
 */
/**
 * Phorm_Field_FileUpload
 *
 * A field representing a file upload input.
 *
 * @author <NAME> <<EMAIL>>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 * @package Phorms
 * @subpackage Fields
 * @uses Phorm_Type_File
 */
class Phorm_Field_FileUpload extends Phorm_Field
{

	/**
	 * Stores the valid types for this field.
	 */
	private $types;
	/**
	 * Stores the maximum size boundary in bytes.
	 * @var int
	 */
	private $max_size;

	/**
	 * @param string $label the field's string label
	 * @param array $mime_types a list of valid mime types
	 * @param int $max_size the maximum upload size in bytes
	 * @param array $validators a list of callbacks to validate the field data
	 * @param array $attributes a list of key/value pairs representing HTML attributes
	 */
	public function __construct($label, array $mime_types, $max_size, array $validators=array(), array $attributes=array())
	{
		$this->types = $mime_types;
		$this->max_size = $max_size;
		parent::__construct($label, $validators, $attributes);
	}

	/**
	 * Returns true if the file was uploaded without an error.
	 *
	 * @return boolean
	 */
	protected function file_was_uploaded()
	{
		$file = $this->get_file_data();
		return !$file['error'];
	}

	/**
	 * Returns an error message for a file upload error code.
	 *
	 * @param int $errno the error code (from $_FILES['name']['error'])
	 * @return string the error message
	 */
	protected function file_upload_error($errno)
	{
		global $phorms_tr;
		switch( $errno )
		{
			case UPLOAD_ERR_INI_SIZE:<commit_msg>add further checks in file_was_uploaded<commit_after><?php if(!defined('PHORMS_ROOT')) { die('Phorms not loaded properly'); }
/**
 * @package Phorms
 * @subpackage Fields
 */
/**
 * Phorm_Field_FileUpload
 *
 * A field representing a file upload input.
 *
 * @author <NAME> <<EMAIL>>
 * @license http://www.opensource.org/licenses/mit-license.php MIT
 * @package Phorms
 * @subpackage Fields
 * @uses Phorm_Type_File
 */
class Phorm_Field_FileUpload extends Phorm_Field
{

	/**
	 * Stores the valid types for this field.
	 */
	private $types;
	/**
	 * Stores the maximum size boundary in bytes.
	 * @var int
	 */
	private $max_size;

	/**
	 * @param string $label the field's string label
	 * @param array $mime_types a list of valid mime types
	 * @param int $max_size the maximum upload size in bytes
	 * @param array $validators a list of callbacks to validate the field data
	 * @param array $attributes a list of key/value pairs representing HTML attributes
	 */
	public function __construct($label, array $mime_types, $max_size, array $validators=array(), array $attributes=array())
	{
		$this->types = $mime_types;
		$this->max_size = $max_size;
		parent::__construct($label, $validators, $attributes);
	}

	/**
	 * Returns true if the file was uploaded without an error.
	 *
	 * @return boolean
	 */
	protected function file_was_uploaded()
	{
		$file = $this->get_file_data();
		return !empty($file['tmp_name']) && !$file['error'];
	}

	/**
	 * Returns an error message for a file upload error code.
	 *
	 * @param int $errno the error code (from $_FILES['name']['error'])
	 * @return string the error message
	 */
	protected function file_upload_error($errno)
	{
		global $phorms_tr;
		switch( $errno )
		{
			case UPLOAD_ERR_INI_SIZE:
{'fraction_non_alphanumeric': 0.12583745994756773, 'fraction_numerical': 0.0, 'mean_word_length': 3.9410071942446043, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '7036064', 'n_tokens_mistral': 1144, 'n_tokens_neox': 1053, 'n_words': 344}