<commit_before><?php

/**
 * Details on a particular contact
 * 
 * @author ilateral
 * @package Contacts
 */
class Contact extends DataObject implements PermissionProvider {
    
    private static $db = array(
        "Salutation" => "Varchar(20)",
        "FirstName" => "Varchar(255)",
		"MiddleName" => "Varchar(255)",
        "Surname" => "Varchar(255)",
        "Company" => "Varchar(255)",
        "Phone" => "Varchar(15)",
        "Mobile" => "Varchar(15)",
        "Email" => "Varchar(255)",
        "Address1" => "Varchar(255)",
        "Address2" => "Varchar(255)",
        "City" => "Varchar(255)",
        "County" => "Varchar(255)",
        "Country" => "Varchar(255)",
        "PostCode" => "Varchar(10)",
        "Source" => "Text",
        "Notes" => "Text",
    );
    
	private static $many_many = array(
		'Tags' => 'ContactTag'
	);

	private static $belongs_many_many = array(
		'Lists' => 'ContactList'
	);
    
    private static $casting = array(
		'TagsList' => 'Varchar'
	);
    
    private static $summary_fields = array(
        "FirstName",
        "Surname",
        "Email",
        "Address1",
        "Address2",
        "City",
        "PostCode",
        "TagsList"
    );

	private static $default_sort = '"FirstName" ASC, "Surname" ASC';
    
	private static $searchable_fields = array(
		"Salutation",
		"FirstName",
		"MiddleName",
		"Surname",
		"Email",
        "Address1",
        "Address2",
        "City",
        "Country",
        "PostCode",
        "Tags.Title",
		"Lists.Title"
	);
    
    public function getTitle() {
		$t = '';
		if (!empty($this->Salutation)) $t = "$this->Salutation ";
        $f = '';
		if (!empty($this->FirstName)) $f = "$this->FirstName ";
		$m = '';
		if (!empty($this->MiddleName)) $m = "$this->MiddleName ";
		$s = '';
		if (!empty($this->Surname)) $s = "$this->Surname ";
		$e = '';
		if (!empty($this->Email)) $e = "($this->Email)";
        
		return $s.$f.$m.$s.$e;
	}
    
    public function getTagsList() {
        $return = "";
        $tags = $this->Tags();
        $i = 1;
        
        foreach($tags as $tag) {
            $return .= $tag->Title;
            
            if($i < $tags->count())
                $return .= ", ";
            
            $i++;
        }
        
        return $return;
    }
    
    public function getCMSFields() {
        $fields = parent::getCMSFields();
        
        $fields->removeByName("Tags");
        
        $tag_field = TagField::create(
            'Tags',
            null,
            ContactTag::get(),
            $this->Tags()
        )->setRightTitle(_t(<commit_msg>added functions to get full name<commit_after><?php

/**
 * Details on a particular contact
 * 
 * @author ilateral
 * @package Contacts
 */
class Contact extends DataObject implements PermissionProvider {
    
    private static $db = array(
        "Salutation" => "Varchar(20)",
        "FirstName" => "Varchar(255)",
		"MiddleName" => "Varchar(255)",
        "Surname" => "Varchar(255)",
        "Company" => "Varchar(255)",
        "Phone" => "Varchar(15)",
        "Mobile" => "Varchar(15)",
        "Email" => "Varchar(255)",
        "Address1" => "Varchar(255)",
        "Address2" => "Varchar(255)",
        "City" => "Varchar(255)",
        "County" => "Varchar(255)",
        "Country" => "Varchar(255)",
        "PostCode" => "Varchar(10)",
        "Source" => "Text",
        "Notes" => "Text",
    );
    
	private static $many_many = array(
		'Tags' => 'ContactTag'
	);

	private static $belongs_many_many = array(
		'Lists' => 'ContactList'
	);
    
    private static $casting = array(
		'TagsList' => 'Varchar'
	);
    
    private static $summary_fields = array(
        "FirstName",
        "Surname",
        "Email",
        "Address1",
        "Address2",
        "City",
        "PostCode",
        "TagsList"
    );

	private static $default_sort = '"FirstName" ASC, "Surname" ASC';
    
	private static $searchable_fields = array(
		"Salutation",
		"FirstName",
		"MiddleName",
		"Surname",
		"Email",
        "Address1",
        "Address2",
        "City",
        "Country",
        "PostCode",
        "Tags.Title",
		"Lists.Title"
	);
    
    public function getTitle() {
		$t = '';
		if (!empty($this->Salutation)) $t = "$this->Salutation ";
        $f = '';
		if (!empty($this->FirstName)) $f = "$this->FirstName ";
		$m = '';
		if (!empty($this->MiddleName)) $m = "$this->MiddleName ";
		$s = '';
		if (!empty($this->Surname)) $s = "$this->Surname ";
		$e = '';
		if (!empty($this->Email)) $e = "($this->Email)";
        
		return $t.$f.$m.$s.$e;
	}

    public function getFullName() {
		$t = '';
		if (!empty($this->Salutation)) $t = "$this->Salutation ";
        	$f = '';
		if (!empty($this->FirstName)) $f = "$this->FirstName ";
		$m = '';
		if (!empty($this->MiddleName)) $m = "$this->MiddleName ";
		$s = '';
		if (!empty($this->Surname)) $s = "$this->Surname ";
        
		return $t.$f.$m.$s;
	}
	

	/**
	 * Get the complete name of the member
	 *
	 * @return string Returns the first- and surname of the member.
	 */
	public function getName() {
		return ($this->Surname) ? trim($this->FirstName . ' ' . $this->Surname) : $this->FirstName;
	}
    
    public function getTagsList() {
        $return = "";
        $tags = $this->Tags();
        $i = 1;
        
        foreach($tags as $tag) {
            $return .= $tag->Title;
            
            if($i < $tags->count())
                $return .= ", ";
            
            $i++;
        }
        
        return $return;
    }
    
    public function getCMSFields() {
        $fields = parent::getCMSFields();
        
        $fields->removeByName("Tags");
        
        $tag_field = TagField::create(
            'Tags',
            null,
            ContactTag::get(),
            $this->Tags()
        )->setRightTitle(_t(
{'fraction_non_alphanumeric': 0.1912241761994195, 'fraction_numerical': 0.01536622844459621, 'mean_word_length': 2.0041025641025643, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 85, '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': '4295281', 'n_tokens_mistral': 2088, 'n_tokens_neox': 1919, 'n_words': 388}