Skip to content

Commit

Permalink
Merge pull request #478 from Neriderc/preferred-name
Browse files Browse the repository at this point in the history
Add Preferred name abbreviation
  • Loading branch information
Neriderc authored Apr 5, 2024
2 parents ec571a0 + c2d42f9 commit 2e10127
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,16 @@ private function getAbbreviatedName(array $nameArray): string
return explode(" ", $nameArray["givn"])[0];
case 40: /* Surname(s) */
return $nameArray["surn"];
case 80: /* Preferred given name and surname */
$pattern = '/<span class="starredname">(.*?)<\/span>/';
preg_match_all($pattern, $nameArray['full'], $matches);
$preferredName = $matches[1];
if (empty($preferredName)) {
$preferredName = explode(" ", $nameArray["givn"])[0];
} else {
$preferredName = implode(' ', $preferredName);
}
return $preferredName . ' ' . $nameArray['surname'];
case 50: /* Initials only */
// Split by space or hyphen to get different names
$givenParts = preg_split('/[\s-]/', $nameArray["givn"]);
Expand Down
2 changes: 1 addition & 1 deletion app/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function __construct(){
$this->defaultSettings['url_xref_treatment_options']['nothing'] = "Don't add to list";
$this->defaultSettings['url_xref_treatment_options']['overwrite'] = "Overwrite";
$this->defaultSettings['use_abbr_places'] = [0 => "Full place name", 10 => "City and country" , 20 => "City and 2 letter ISO country code", 30 => "City and 3 letter ISO country code"];
$this->defaultSettings['use_abbr_names'] = [0 => "Full name", 10 => "Given and surnames", 20 => "Given names" , 30 => "First given name only", 40 => "Surnames", 50 => "Initials only", 60 => "Given name initials and surname", 70 => "Don't show names"];
$this->defaultSettings['use_abbr_names'] = [0 => "Full name", 10 => "Given and surnames", 20 => "Given names" , 30 => "First given name only", 80 => "Preferred given name and surname", 40 => "Surnames", 50 => "Initials only", 60 => "Given name initials and surname", 70 => "Don't show names"];
$this->defaultSettings['photo_shape_options'] = [Person::SHAPE_NONE => "No change", Person::SHAPE_OVAL => "Oval", Person::SHAPE_CIRCLE => "Circle" , Person::SHAPE_SQUARE => "Square", Person::SHAPE_ROUNDED_RECT => "Rounded rectangle", Person::SHAPE_ROUNDED_SQUARE => "Rounded square"];
$this->defaultSettings['photo_quality_options'] = [0 => "Lowest", 20 => "Low", 50 => "Medium" , 75 => "High", 100 => "Highest"];
$this->defaultSettings['indi_tile_shape_custom_options'] = [0 => "Rectangle", 10 => "Rounded rectangle"];
Expand Down

0 comments on commit 2e10127

Please sign in to comment.