<commit_before><?php
class PhoneField extends RegexField{

	function __construct($options = array()){
		$options += array(
			"error_messages" => array(),
			"help_text" => _("Enter phone number in format %sample_phone_number%"),
			"null_empty_output" => true,
			"default_country_code" => "+420", // "420" or "+420"
			"sample_phone_number" => "+420 605 123 456",
		);

		$options += array(
			"initial" => $options["default_country_code"] ? $options["default_country_code"]." " : "",
		);

		$options["error_messages"] += array(
			"invalid" => _("Enter valid phone number (%sample_phone_number%)"),
			"required" => _("Enter phone number"),
		);

		$this->default_country_code = $options["default_country_code"];
		unset($options["default_country_code"]);

		$sample_phone_number = $options["sample_phone_number"];
		unset($options["sample_phone_number"]);

		// TODO: jsou cisla, ktera zacinaji nulou: +044.1425838079
		parent::__construct('/^\+[1-9][0-9]{0,3}\.[0-9]{6,12}$/',$options);

		foreach($this->messages as $k => &$v){
			$v = str_replace("%sample_phone_number%",$sample_phone_number,$v);
		}
		$this->help_text = str_replace("%sample_phone_number%",$sample_phone_number,$this->help_text);
	}

	function format_initial_data($phone){
		if(preg_match('/^(\+\d+)\.(\d+)$/',$phone,$matches)){
			$cc = $matches[1];
			$number = $matches[2];
			$number_ar = array();<commit_msg>Defined constant PHONE_FIELD_DEFAULT_COUNTRY_CODE and PHONE_FIELD_SAMPLE_PHONE_NUMBER<commit_after><?php
defined("PHONE_FIELD_DEFAULT_COUNTRY_CODE") || define("PHONE_FIELD_DEFAULT_COUNTRY_CODE","+420");
defined("PHONE_FIELD_SAMPLE_PHONE_NUMBER") || define("PHONE_FIELD_SAMPLE_PHONE_NUMBER","+420 605 123 456");

class PhoneField extends RegexField{

	function __construct($options = array()){
		$options += array(
			"error_messages" => array(),
			"help_text" => _("Enter phone number in format %sample_phone_number%"),
			"null_empty_output" => true,
			"default_country_code" => PHONE_FIELD_DEFAULT_COUNTRY_CODE, // "421" or "+420"
			"sample_phone_number" => PHONE_FIELD_SAMPLE_PHONE_NUMBER,
		);

		$options += array(
			"initial" => $options["default_country_code"] ? $options["default_country_code"]." " : "",
		);

		$options["error_messages"] += array(
			"invalid" => _("Enter valid phone number (%sample_phone_number%)"),
			"required" => _("Enter phone number"),
		);

		$this->default_country_code = $options["default_country_code"];
		unset($options["default_country_code"]);

		$sample_phone_number = $options["sample_phone_number"];
		unset($options["sample_phone_number"]);

		// TODO: jsou cisla, ktera zacinaji nulou: +044.1425838079
		parent::__construct('/^\+[1-9][0-9]{0,3}\.[0-9]{6,12}$/',$options);

		foreach($this->messages as $k => &$v){
			$v = str_replace("%sample_phone_number%",$sample_phone_number,$v);
		}
		$this->help_text = str_replace("%sample_phone_number%",$sample_phone_number,$this->help_text);
	}

	function format_initial_data($phone){
		if(preg_match('/^(\+\d+)\.(\d+)$/',$phone,$matches)){
			$cc = $matches[1];
			$number = $matches[2];
			$number_ar = array();
{'fraction_non_alphanumeric': 0.19444444444444445, 'fraction_numerical': 0.030361757105943153, 'mean_word_length': 6.070776255707763, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, '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': '4697277', 'n_tokens_mistral': 1233, 'n_tokens_neox': 1082, 'n_words': 165}