示例#1
0
 public static function standardizeValues($label, $values)
 {
     $stdValues = array();
     if (is_array(@$values)) {
         foreach ($values as $value) {
             $stdValue = '';
             if (strpos($label, 'Surname') !== false || strpos($label, 'Given') !== false) {
                 $pieces = explode(' ', $value);
                 $sdxValue = '';
                 foreach ($pieces as $piece) {
                     $lowerPiece = mb_strtolower($piece);
                     if ($piece && $lowerPiece != 'unknown' && $lowerPiece != '?' && $lowerPiece != 'fnu' && $lowerPiece != 'lnu' && $lowerPiece != 'nn' && $lowerPiece != 'n.n.') {
                         if ($stdValue) {
                             $stdValue .= ' ';
                             $sdxValue .= ' ';
                         }
                         $stdValue .= $lowerPiece;
                         $sdxValue .= soundex($piece);
                     }
                 }
                 $stdValue .= '|' . $sdxValue;
             } else {
                 if (strpos($label, 'date') !== false) {
                     $stdValue = StructuredData::getDateKey($value);
                 } else {
                     if (strpos($label, 'place') !== false) {
                         $stdValue = StructuredData::getPlaceKey($value);
                         $pos = mb_strpos($stdValue, ', united states');
                         if ($pos !== false) {
                             $stdValue = mb_substr($stdValue, 0, $pos);
                             // remove united states for ,-check in scoreMatch below
                         }
                     } else {
                         if (strpos($label, 'ParentFamilyTitle') !== false || strpos($label, 'SpouseFamilyTitle') !== false) {
                             $pos = mb_strpos($value, '(');
                             if ($pos !== false) {
                                 $stdValue = mb_substr($value, 0, $pos);
                             } else {
                                 $stdValue = $value;
                             }
                             $stdValue = trim(mb_convert_case($stdValue, MB_CASE_LOWER));
                         } else {
                             $stdValue = $value;
                         }
                     }
                 }
             }
             if ($stdValue) {
                 $stdValues[] = $stdValue;
             }
         }
     } else {
         if ($label == 'childGedcomMatchTitle' && @$values) {
             // keep this for matching
             $stdValues[] = $values;
         }
     }
     return $stdValues;
 }
示例#2
0
 private static function readEvents($xml)
 {
     $events = array();
     foreach ($xml->event_fact as $o) {
         $type = (string) $o['type'];
         $stdType = MergeForm::getStdType($type);
         $date = (string) $o['date'];
         $stdDate = (string) StructuredData::getDateKey($date);
         $place = (string) $o['place'];
         $stdPlace = StructuredData::getPlaceKey($place);
         $desc = (string) $o['desc'];
         // sometimes people put the references in the wrong fields, so gather them all together
         list($sources, $images, $notes) = MergeForm::readSourcesImagesNotes((string) $o['sources'], (string) $o['images'], (string) $o['notes']);
         $key = 'EVENT|' . $type . '|' . $date . '|' . $place . '|' . $desc . '|' . $sources . '|' . $notes . '|' . $images;
         $events[] = array('type' => $type, 'stdtype' => $stdType, 'date' => $date, 'stddate' => $stdDate, 'place' => $place, 'stdplace' => $stdPlace, 'description' => $desc, 'sources' => $sources, 'notes' => $notes, 'images' => $images, 'key' => $key);
     }
     return $events;
 }