Пример #1
0
 /**
  * Return xml elements from data in request
  * @param unknown $request
  */
 protected function fromEditFields($request)
 {
     $this->correctedPlaceTitles = PlaceSearcher::correctPlaceTitlesMultiLine($request->getVal('places', ''));
     $result = '';
     $result .= $this->addSingleLineFieldToXml($request->getVal('source'), 'source');
     $result .= $this->addMultiLineFieldToXml($request->getVal('surnames', ''), 'formatSurname');
     $result .= $this->addMultiLineFieldToXml($request->getVal('places', ''), 'formatPlace');
     $result .= $this->addSingleLineFieldToXml($request->getVal('fromYear', ''), 'from_year');
     $result .= $this->addSingleLineFieldToXml($request->getVal('toYear', ''), 'to_year');
     return $result;
 }
Пример #2
0
 private static function correctPlaceTitles($request, $stdEventFacts)
 {
     $titles = array();
     for ($i = 0; $i < count($stdEventFacts) || $request->getVal("event_fact{$i}"); $i++) {
         $place = $request->getVal("place{$i}");
         if ($place && mb_strpos($place, '|') === false) {
             $titles[] = $place;
         }
     }
     return PlaceSearcher::correctPlaceTitles($titles);
 }
Пример #3
0
 private function correctPlaceTitle($place)
 {
     if ($place && mb_strpos($place, '|') === false) {
         $titles = array();
         $titles[] = $place;
         $correctedPlaces = PlaceSearcher::correctPlaceTitles($titles);
         $correctedPlace = @$correctedPlaces[$place];
         if ($correctedPlace) {
             $place = strcasecmp($place, $correctedPlace) == 0 ? $correctedPlace : $correctedPlace . '|' . $place;
         }
     }
     return $place;
 }
Пример #4
0
 public function getPedigreeMapData()
 {
     $places = array();
     $this->iterateFamilies('getPlaces', $places);
     $this->stdPlaces = PlaceSearcher::getPlaceTitleLatLong($places);
     $eventXml = '';
     $this->iterateFamilies('getMapData', $eventXml);
     return $eventXml;
 }
Пример #5
0
 public static function getPageText($marriagedate, $marriageplace, $titleString, $pageids = NULL, $husbandTitle = '', $wifeTitle = '', $childTitle = '')
 {
     // standardize marriage place
     $placeTitles = array();
     if ($marriageplace && mb_strpos($marriageplace, '|') === false) {
         $placeTitles[] = $marriageplace;
     }
     if ($placeTitles) {
         $correctedTitles = PlaceSearcher::correctPlaceTitles($placeTitles);
         $correctedPlace = @$correctedTitles[$marriageplace];
         if ($correctedPlace) {
             $marriageplace = strcasecmp($marriageplace, $correctedPlace) == 0 ? $correctedPlace : $correctedPlace . '|' . $marriageplace;
         }
     }
     $result = "<family>\n";
     $db =& wfGetDB(DB_MASTER);
     // get latest version
     $imageId = 0;
     $husbands = '';
     $wives = '';
     $children = '';
     $images = '';
     if ($pageids) {
         foreach ($pageids as $pageid) {
             $revision = Revision::loadFromPageId($db, $pageid);
             if ($revision) {
                 if ($revision->getTitle()->getNamespace() == NS_PERSON) {
                     $text = $revision->getText();
                     $xml = StructuredData::getXml('person', $text);
                     if (isset($xml)) {
                         $personTitle = StructuredData::escapeXml($revision->getTitle()->getText());
                         $spouseTag = Person::getSpouseTagFromGender((string) $xml->gender);
                         foreach ($xml->spouse_of_family as $family) {
                             if ((string) $family['title'] == $titleString) {
                                 if ($spouseTag == 'husband') {
                                     $husbands .= "<husband title=\"" . $personTitle . "\"/>\n";
                                 } else {
                                     $wives .= "<wife title=\"" . $personTitle . "\"/>\n";
                                 }
                             }
                         }
                         foreach ($xml->child_of_family as $family) {
                             if ((string) $family['title'] == $titleString) {
                                 $children .= '<child title="' . $personTitle . "\"/>\n";
                             }
                         }
                     }
                 } else {
                     if ($revision->getTitle()->getNamespace() == NS_IMAGE) {
                         $text = $revision->getText();
                         $xml = StructuredData::getXml('image_data', $text);
                         if (isset($xml)) {
                             $imageTitle = StructuredData::escapeXml($revision->getTitle()->getText());
                             foreach ($xml->family as $family) {
                                 if ((string) $family['title'] == $titleString) {
                                     $imageId++;
                                     $images .= '<image id="I' . $imageId . '" filename="' . $imageTitle . "\"/>\n";
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($husbandTitle) {
         $husbands .= "<husband title=\"" . StructuredData::escapeXml($husbandTitle) . "\"/>\n";
     }
     if ($wifeTitle) {
         $wives .= "<husband title=\"" . StructuredData::escapeXml($wifeTitle) . "\"/>\n";
     }
     if ($childTitle) {
         $children .= "<husband title=\"" . StructuredData::escapeXml($childTitle) . "\"/>\n";
     }
     $result .= $husbands;
     $result .= $wives;
     $result .= $children;
     if ($marriagedate || $marriageplace) {
         $result .= '<event_fact type="Marriage" date="' . StructuredData::escapeXml($marriagedate) . '" place="' . StructuredData::escapeXml($marriageplace) . "\"/>\n";
     }
     $result .= $images;
     $result .= "</family>\n";
     return $result;
 }
Пример #6
0
    public function OutputJSONData()
    {
        $places = $this->getPlaces();
        $this->stdPlaces = PlaceSearcher::getPlaceTitleLatLong($places);
        //print_r($this->families);#for debug
        //print_r($this->stdPlaces);#for debug
        $persons = array();
        $extras = array();
        print "{\n\t\"items\":[";
        $first = true;
        // we go through all the families and create a JSON Family object from each
        // we add to the persons array going through it
        // which we use down below to make a bunch of JSON Person objects
        // we also add to an event array containing marriages, deaths, and births
        // each event has a place and a date
        foreach ($this->families as $family) {
            if ($first) {
                $first = false;
            } else {
                print ',';
            }
            // lot of work for a dumb comma
            print "\n\t\t{";
            print "\n\t\t\ttype: 'Family'";
            print ",\n\t\t\tlabel: '" . str_replace("'", "\\'", $family['title']) . "'";
            $title = Title::newFromText($family['title'], NS_FAMILY);
            $url = $title->getLocalURL();
            print ",\n\t\t\tURL: '{$url}'";
            $id = $this->counter++;
            $extras[] = @array('id' => $id, 'URL' => $url, 'Family' => $family['title'], 'type' => 'Marriage', 'Date' => $family['marriagedate'], 'Place' => $family['marriageplace']);
            print ",\n\t\t\tMarriage: '{$id}'";
            if (isset($family['husband']) && $family['husband'] != "UNKNOWN") {
                $family['husband']['family'] = $family['title'];
                $persons[$family['husband']['title']] = $family['husband'];
            }
            if (isset($family['wife']) && $family['wife'] != "UNKNOWN") {
                $family['wife']['family'] = $family['title'];
                $persons[$family['wife']['title']] = $family['wife'];
            }
            if (isset($family['children'])) {
                $count = count($family['children']);
                print ",\n\t\t\tChildCount: {$count}";
                foreach ($family['children'] as $child) {
                    $child['family'] = $family['title'];
                    $child['siblingCount'] = $count - 1;
                    $persons[$child['title']] = $child;
                }
            }
            print "\n\t\t}";
        }
        foreach ($persons as $person) {
            print ",\n\t\t{";
            print "\n\t\t\ttype: 'Person'";
            print ",\n\t\t\tlabel: '" . str_replace("'", "\\'", $person['title']) . "'";
            $title = Title::newFromText($person['title'], NS_PERSON);
            $url = $title->getLocalURL();
            print ",\n\t\t\tURL: '{$url}'";
            print ",\n\t\t\tFamily: '" . str_replace("'", "\\'", $person['family']) . "'";
            if (isset($person['siblingCount'])) {
                print ",\n\t\t\tSiblingCount: " . $person['siblingCount'];
            }
            $arr = array();
            preg_match('/(.*)\\s+(\\S+)\\s+(\\(\\S+\\))/', $person['title'], $arr);
            if (isset($person['given']) && strlen($person['given']) > 0) {
                print ",\n\t\t\tGiven: '" . str_replace("'", "\\'", $person['given']) . "'";
            } elseif (count($arr) == 4 && strlen($arr[1]) > 0) {
                print ",\n\t\t\tGiven: '" . str_replace("'", "\\'", trim($arr[1])) . "'";
            }
            if (isset($person['surname']) && strlen($person['surname']) > 0) {
                print ",\n\t\t\tSurname: '" . str_replace("'", "\\'", $person['surname']) . "'";
            } elseif (count($arr) == 4 && strlen($arr[2]) > 0) {
                print ",\n\t\t\tSurname: '" . str_replace("'", "\\'", trim($arr[2])) . "'";
            }
            $id = $this->counter++;
            $extras[] = @array('id' => $id, 'URL' => $url, 'Person' => $person['title'], 'Family' => $person['family'], 'type' => 'Birth', 'Date' => $person['birthdate'], 'Place' => $person['birthplace']);
            print ",\n\t\t\tBirth: '{$id}'";
            $id = $this->counter++;
            $extras[] = @array('id' => $id, 'URL' => $url, 'Person' => $person['title'], 'Family' => $person['family'], 'type' => 'Death', 'Date' => $person['deathdate'], 'Place' => $person['deathplace']);
            print ",\n\t\t\tDeath: '{$id}'";
            print "\n\t\t}";
        }
        foreach ($extras as $extra) {
            print ",\n\t\t{";
            print "\n\t\t\ttype: '" . $extra['type'] . "'";
            print ",\n\t\t\tid: '" . $extra['id'] . "'";
            print ",\n\t\t\tURL: '" . $extra['URL'] . "'";
            $label = '';
            if (isset($extra['Place']) && strlen($extra['Place']) > 0) {
                $place = $this->cleanPlace($extra['Place']);
                if (strlen($place) > 0) {
                    print ",\n\t\t\tLocation: '" . str_replace("'", "\\'", $this->formatPlace($place)) . "'";
                    if (isset($this->stdPlaces[$place])) {
                        // this should be unnecessary, but there appears to be a bug
                        print ",\n\t\t\tLatLon: '" . $this->stdPlaces[$place]['lat'] . ',' . $this->stdPlaces[$place]['lon'] . "'";
                    }
                    $pos = strpos($place, ',');
                    if ($pos >= 0) {
                        $label .= str_replace("'", "\\'", substr($place, 0, $pos));
                    } else {
                        $label .= str_replace("'", "\\'", $place);
                    }
                    $label .= ': ';
                }
            }
            if (isset($extra['Person'])) {
                if (isset($extra['Family'])) {
                    print ",\n\t\t\tFamily: '" . str_replace("'", "\\'", $extra['Family']) . "'";
                }
                print ",\n\t\t\tPerson: '" . str_replace("'", "\\'", $extra['Person']) . "'";
                $label .= $extra['type'] . ' of ' . str_replace("'", "\\'", $extra['Person']);
            } else {
                if (isset($extra['Family'])) {
                    print ",\n\t\t\tFamily: '" . str_replace("'", "\\'", $extra['Family']) . "'";
                    $label .= $extra['type'] . ' of ' . str_replace("'", "\\'", $extra['Family']);
                }
            }
            if (isset($extra['Date']) && strlen($extra['Date']) > 0) {
                $date = $this->cleanDate(str_replace("'", "\\'", $extra['Date']));
                if (strlen($date) > 0) {
                    print ",\n\t\t\tDate: '{$date}'";
                } else {
                    $label .= ': ' . str_replace("'", "\\'", $extra['Date']);
                }
            }
            print ",\n\t\t\tlabel: '{$label}'";
            print "\n\t\t}";
        }
        print "\n\t],";
        //		"Date" : { valueType: "date" },
        print '
	"properties": {
		"Marriage" : { valueType: "item" },
		"Family" : { valueType: "item" },
		"Person" : { valueType: "item" },
		"Death" : { valueType: "item" },
		"Birth" : { valueType: "item" },
		"Date" : { valueType: "date" },
		"URL" : { valueType: "url" }
	},
	"types": {
		"Person" : { pluralLabel: "People" },
		"Family" : { pluralLabel: "Families" },
		"Marriage" : { pluralLabel: "Marriages" },
		"Birth" : { pluralLabel: "Births" },
		"Death" : { pluralLabel: "Deaths" },
		"Date" : { pluralLabel: "Dates" },
		"Location" : { pluralLabel: "Locations" }
	}
}';
    }
Пример #7
0
 private static function cleanSourcePlace($place)
 {
     $title = array();
     $title[] = $place;
     $stdTitle = PlaceSearcher::correctPlaceTitles($title);
     if (@$stdTitle[$place]) {
         $place = $stdTitle[$place];
     }
     return rtrim($place, ' .');
 }
Пример #8
0
 /**
  * Return xml elements from data in request
  * @param unknown $request
  */
 protected function fromEditFields($request)
 {
     $this->correctedPlaceTitles = PlaceSearcher::correctPlaceTitlesMultiLine($request->getVal('places', ''));
     $result = '';
     // !!! +title, +date_issued, -publication_info, -call_number, type->format, -abbrev, +ethnicity, +religion, +occupation, +category
     // !!! author format=lastname, given name(s)
     if ($this->isGedcomPage) {
         list($mysourcePrefix, $mysourceTitle, $mysourceSuffix) = MySource::splitGedcomMySourceTitle($this->titleString);
         $mysourceTitle = $request->getVal('mysource_title', '') ? $request->getVal('mysource_title', '') : $mysourceTitle;
         $mysourceTitle = mb_strtoupper(mb_substr($mysourceTitle, 0, 1)) . mb_substr($mysourceTitle, 1);
         $result .= $this->addSingleLineFieldToXml($mysourceTitle, 'title');
         $this->titleString = $mysourcePrefix . $mysourceTitle . $mysourceSuffix;
         $this->title = Title::newFromText($this->titleString, NS_MYSOURCE);
     }
     $result .= $this->addSingleLineFieldToXml($this->cleanUrl($request->getVal('url', '')), 'url');
     //      $result .= $this->addMultiLineFieldToXml($request->getVal('altNames', ''), 'formatAltNameXML');
     $result .= $this->addMultiLineFieldToXml($request->getVal('places', ''), 'formatPlace');
     $result .= $this->addMultiLineFieldToXml($request->getVal('surnames', ''), 'formatSurname');
     $result .= $this->addSingleLineFieldToXml($request->getVal('fromYear', ''), 'from_year');
     $result .= $this->addSingleLineFieldToXml($request->getVal('toYear', ''), 'to_year');
     $result .= $this->addSingleLineFieldToXml($request->getVal('abbrev', ''), 'abbrev');
     $result .= $this->addSingleLineFieldToXml($request->getVal('author', ''), 'author');
     $result .= $this->addSingleLineFieldToXml($request->getVal('pubInfo', ''), 'publication_info');
     $result .= $this->addSingleLineFieldToXml($request->getVal('callNumber', ''), 'call_number');
     $result .= $this->addSingleLineFieldToXml($request->getVal('type', ''), 'type');
     $result .= $this->addSingleLineFieldToXml($request->getVal('repoName', ''), 'repository_name');
     $result .= $this->addSingleLineFieldToXml($request->getVal('repoAddr', ''), 'repository_addr');
     return $result;
 }
Пример #9
0
 public static function getPageText($givenname, $surname, $gender, $birthdate, $birthplace, $deathdate, $deathplace, $titleString, $pageids = NULL, $parentFamily = '', $spouseFamily = '', $chrdate = '', $chrplace = '', $burdate = '', $burplace = '')
 {
     // standardize places
     $placeTitles = array();
     if ($birthplace && mb_strpos($birthplace, '|') === false) {
         $placeTitles[] = $birthplace;
     }
     if ($deathplace && mb_strpos($deathplace, '|') === false) {
         $placeTitles[] = $deathplace;
     }
     if ($placeTitles) {
         $correctedTitles = PlaceSearcher::correctPlaceTitles($placeTitles);
         $correctedPlace = @$correctedTitles[$birthplace];
         if ($correctedPlace) {
             $birthplace = strcasecmp($birthplace, $correctedPlace) == 0 ? $correctedPlace : $correctedPlace . '|' . $birthplace;
         }
         $correctedPlace = @$correctedTitles[$deathplace];
         if ($correctedPlace) {
             $deathplace = strcasecmp($deathplace, $correctedPlace) == 0 ? $correctedPlace : $correctedPlace . '|' . $deathplace;
         }
     }
     $result = "<person>\n";
     if ($givenname || $surname) {
         $result .= '<name given="' . StructuredData::escapeXml(trim($givenname)) . '" surname="' . StructuredData::escapeXml(trim($surname)) . "\"/>\n";
     }
     $db =& wfGetDB(DB_MASTER);
     // make sure we get the most current version
     $spouseFamilies = '';
     $parentFamilies = '';
     $images = '';
     $imageId = 0;
     if ($pageids) {
         foreach ($pageids as $pageid) {
             $revision = Revision::loadFromPageId($db, $pageid);
             if ($revision) {
                 if ($revision->getTitle()->getNamespace() == NS_FAMILY) {
                     $text = $revision->getText();
                     $xml = StructuredData::getXml('family', $text);
                     if (isset($xml)) {
                         $familyTitle = StructuredData::escapeXml($revision->getTitle()->getText());
                         foreach ($xml->husband as $member) {
                             if ((string) $member['title'] == $titleString) {
                                 $spouseFamilies .= '<spouse_of_family title="' . $familyTitle . "\"/>\n";
                                 if (!$gender) {
                                     $gender = 'M';
                                 }
                             }
                         }
                         foreach ($xml->wife as $member) {
                             if ((string) $member['title'] == $titleString) {
                                 $spouseFamilies .= '<spouse_of_family title="' . $familyTitle . "\"/>\n";
                                 if (!$gender) {
                                     $gender = 'F';
                                 }
                             }
                         }
                         foreach ($xml->child as $member) {
                             if ((string) $member['title'] == $titleString) {
                                 $parentFamilies .= '<child_of_family title="' . $familyTitle . "\"/>\n";
                             }
                         }
                     }
                 } else {
                     if ($revision->getTitle()->getNamespace() == NS_IMAGE) {
                         $text = $revision->getText();
                         $xml = StructuredData::getXml('image_data', $text);
                         if (isset($xml)) {
                             $imageTitle = StructuredData::escapeXml($revision->getTitle()->getText());
                             foreach ($xml->person as $person) {
                                 if ((string) $person['title'] == $titleString) {
                                     $imageId++;
                                     $images .= '<image id="I' . $imageId . '" filename="' . $imageTitle . "\"/>\n";
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if ($parentFamily) {
         $parentFamilies .= '<child_of_family title="' . StructuredData::escapeXml($parentFamily) . "\"/>\n";
     }
     if ($spouseFamily) {
         $spouseFamilies .= '<spouse_of_family title="' . StructuredData::escapeXml($spouseFamily) . "\"/>\n";
     }
     if ($gender) {
         $result .= '<gender>' . StructuredData::escapeXml($gender) . "</gender>\n";
     }
     $result .= $parentFamilies;
     $result .= $spouseFamilies;
     if ($birthdate || $birthplace) {
         $result .= '<event_fact type="Birth" date="' . StructuredData::escapeXml($birthdate) . '" place="' . StructuredData::escapeXml($birthplace) . "\"/>\n";
     }
     if ($deathdate || $deathplace) {
         $result .= '<event_fact type="Death" date="' . StructuredData::escapeXml($deathdate) . '" place="' . StructuredData::escapeXml($deathplace) . "\"/>\n";
     }
     if ($chrdate || $chrplace) {
         $result .= '<event_fact type="Christening" date="' . StructuredData::escapeXml($chrdate) . '" place="' . StructuredData::escapeXml($chrplace) . "\"/>\n";
     }
     if ($burdate || $burplace) {
         $result .= '<event_fact type="Burial" date="' . StructuredData::escapeXml($burdate) . '" place="' . StructuredData::escapeXml($burplace) . "\"/>\n";
     }
     $result .= $images;
     $result .= "</person>\n";
     return $result;
 }
Пример #10
0
 public function getItems()
 {
     global $wrIconSize;
     $result = '';
     $this->places = array();
     $this->externals = array();
     $this->otherEvents = array();
     $this->latlngs = array();
     foreach ($this->people as $titleText => $p) {
         $given = $surname = $fullname = '';
         $birthDate = $birthPlace = $birthPlaceText = $birthYear = '';
         $deathDate = $deathPlace = $deathPlaceText = $deathYear = '';
         $imageURL = $iconURL = '';
         $parents = $spouse = $allPlace = '';
         $otherEvents = '';
         $xml = $p['xml'];
         $position = $p['position'];
         $allPlaces = array();
         if ($xml) {
             foreach ($xml->name as $name) {
                 $given = (string) $name['given'];
                 $surname = (string) $name['surname'];
                 $fullname = StructuredData::getFullname($name);
                 break;
             }
             list($birthEventType, $birthDate, $birthPlace, $birthPlaceText, $birthYear) = $this->getEventData($xml, array('Birth', 'Christening', 'Baptism'));
             list($deathEventType, $deathDate, $deathPlace, $deathPlaceText, $deathYear) = $this->getEventData($xml, array('Death', 'Burial'));
             $otherEvents = $this->getOtherEventData($xml, array($birthEventType, $deathEventType));
             foreach ($xml->image as $image) {
                 if ($image['primary'] == 'true') {
                     $t = Title::makeTitle(NS_IMAGE, (string) $image['filename']);
                     if ($t && $t->exists()) {
                         $image = new Image($t);
                         $imageURL = $image->createThumb(SearchForm::THUMB_WIDTH);
                         $iconURL = $image->createThumb(PedigreeData::ICON_WIDTH, -1, true);
                         break;
                     }
                 }
             }
             $parents = $this->getTitles($xml, 'child_of_family', 'Family');
             $this->addExternals($parents);
             $spouse = $this->getTitles($xml, 'spouse_of_family', 'Family');
             $this->addExternals($spouse);
             $allPlaces = $this->getAllEventPlaces($xml);
             $this->addPlaces($allPlaces);
         }
         if (substr($position, 0, 1) == 'P') {
             $pos = substr($position, 1);
             $line = self::$LINES[$pos];
             $generation = self::$GENERATIONS[$pos];
         } else {
             if ($position == 'Spouse') {
                 $line = self::$LINES[1];
                 $generation = self::$GENERATIONS[1];
             } else {
                 // $position == 'Child'
                 $line = self::$LINES[0];
                 $generation = self::$GENERATIONS[0];
             }
         }
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'Person') . PedigreeData::outJSON('label', 'Person:' . $titleText) . PedigreeData::outJSON('Surname', $surname) . PedigreeData::outJSON('Givenname', $given) . PedigreeData::outJSON('FullName', $fullname) . PedigreeData::outJSON('BirthYear', $birthYear) . PedigreeData::outJSON('BirthDate', $birthDate) . PedigreeData::outJSON('BirthPlace', $birthPlace) . PedigreeData::outJSON('BirthPlaceText', $birthPlaceText) . PedigreeData::outJSON('DeathYear', $deathYear) . PedigreeData::outJSON('DeathDate', $deathDate) . PedigreeData::outJSON('DeathPlace', $deathPlace) . PedigreeData::outJSON('DeathPlaceText', $deathPlaceText) . PedigreeData::outJSON('OtherEvents', $otherEvents) . PedigreeData::outJSON('ImageURL', $imageURL) . PedigreeData::outJSON('IconURL', $iconURL) . PedigreeData::outJSON('Parents', $parents) . PedigreeData::outJSON('Spouse', $spouse) . PedigreeData::outJSON('AllPlaces', $allPlaces) . PedigreeData::outJSON('Line', $line) . PedigreeData::outJSON('Generation', $generation) . PedigreeData::outJSON('Position', $position, false) . "}";
     }
     foreach ($this->families as $titleText => $p) {
         $marriageDate = $marriagePlace = $marriagePlaceText = $marriageYear = '';
         $husband = $wife = $children = '';
         $otherEvents = '';
         $xml = $p['xml'];
         $position = $p['position'];
         if ($xml) {
             list($marriageEventType, $marriageDate, $marriagePlace, $marriagePlaceText, $marriageYear) = $this->getEventData($xml, array('Marriage'));
             $otherEvents = $this->getOtherEventData($xml, array($marriageEventType));
             $husband = $this->getTitles($xml, 'husband', 'Person');
             $this->addExternals($husband);
             $wife = $this->getTitles($xml, 'wife', 'Person');
             $this->addExternals($wife);
             $children = $this->getTitles($xml, 'child', 'Person');
             $this->addExternals($children);
         }
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'Family') . PedigreeData::outJSON('label', 'Family:' . $titleText) . PedigreeData::outJSON('MarriageYear', $marriageYear) . PedigreeData::outJSON('MarriageDate', $marriageDate) . PedigreeData::outJSON('MarriagePlace', $marriagePlace) . PedigreeData::outJSON('MarriagePlaceText', $marriagePlaceText) . PedigreeData::outJSON('OtherEvents', $otherEvents) . PedigreeData::outJSON('Husband', $husband) . PedigreeData::outJSON('Wife', $wife) . PedigreeData::outJSON('Child', $children) . PedigreeData::outJSON('Position', $position, false) . "}";
     }
     // add externals
     foreach ($this->externals as $titleText => $dummy) {
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'External') . PedigreeData::outJSON('label', $titleText, false) . "}";
     }
     // add other events
     foreach ($this->otherEvents as $index => $event) {
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'Event') . PedigreeData::outJSON('label', 'Event:' . ($index + 1)) . PedigreeData::outJSON('Date', $event['date']) . PedigreeData::outJSON('Place', $event['place']) . PedigreeData::outJSON('PlaceText', $event['placetext']) . PedigreeData::outJSON('EventType', $event['type'], false) . "}";
     }
     // add places
     $stdPlaces = PlaceSearcher::getPlaceTitlesLatLong($this->places);
     foreach ($stdPlaces as $titleText => $stdPlace) {
         if ($stdPlace['lat'] || $stdPlace['lon']) {
             $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'Place') . PedigreeData::outJSON('label', 'Place:' . $titleText) . PedigreeData::outJSON('addressLatLng', $stdPlace['lat'] . ',' . $stdPlace['lon'], false) . "}";
         }
     }
     foreach ($this->latlngs as $latlng) {
         $result .= ($result ? ",\n" : '') . '{ ' . PedigreeData::outJSON('type', 'LatLng') . PedigreeData::outJSON('label', 'LatLng:' . $latlng) . PedigreeData::outJSON('addressLatLng', $latlng, false) . "}";
     }
     return $result;
 }
Пример #11
0
 /**
  * Return a hash of title => lat:long for each passed-in title
  * The hash is empty for a passed-in title if a unique matching place for the title isn't found
  *
  * @param array $titles
  * @return unknown
  */
 public static function getPlaceTitlesLatLong($titles)
 {
     return PlaceSearcher::getPlaces($titles, 'placelatlngtitle');
 }
Пример #12
0
 /**
  * Return xml elements from data in request
  * @param unknown $request
  */
 protected function fromEditFields($request)
 {
     $this->correctedPlaceTitles = PlaceSearcher::correctPlaceTitlesMultiLine($request->getVal('places', ''));
     $subjects = $request->getArray('subject', array());
     $sourceType = $request->getVal('source_type', '');
     $result = $this->addSingleLineFieldToXml($sourceType, 'source_type') . (!$sourceType || in_array($sourceType, array('Book', 'Article', 'Government / Church records', 'Periodical', 'Manuscript collection', 'Website', 'Miscellaneous', 'MySource')) ? $this->addMultiLineFieldToXml($request->getVal('authors', ''), 'formatAuthor') : '') . $this->addSingleLineFieldToXml($request->getVal('source_title', ''), 'source_title') . (!$sourceType || in_array($sourceType, array('Book', 'Article', 'Government / Church records', 'Manuscript collection', 'Website', 'Miscellaneous', 'MySource')) ? $this->addSingleLineFieldToXml($request->getVal('subtitle', ''), 'subtitle') : '') . (!$sourceType || in_array($sourceType, array('Book', 'Article', 'Government / Church records', 'Periodical', 'Manuscript collection', 'Miscellaneous', 'MySource')) ? $this->addSingleLineFieldToXml($request->getVal('publisher', ''), 'publisher') : '') . (!$sourceType || in_array($sourceType, array('Book', 'Article', 'Government / Church records', 'Manuscript collection', 'Miscellaneous', 'MySource')) ? $this->addSingleLineFieldToXml($request->getVal('date_issued', ''), 'date_issued') : '') . (!$sourceType || in_array($sourceType, array('Book', 'Government / Church records', 'Newspaper', 'Periodical', 'Manuscript collection', 'Miscellaneous', 'MySource')) ? $this->addSingleLineFieldToXml($request->getVal('place_issued', ''), 'place_issued') : '') . (!$sourceType || in_array($sourceType, array('Book', 'Article', 'Government / Church records', 'Miscellaneous', 'MySource')) ? $this->addSingleLineFieldToXml($request->getVal('series_name', ''), 'series_name') : '') . (!$sourceType || in_array($sourceType, array('Book', 'Article', 'Government / Church records', 'Miscellaneous', 'MySource')) ? $this->addSingleLineFieldToXml($request->getVal('volumes', ''), 'volumes') : '') . (!$sourceType || in_array($sourceType, array('Article', 'Miscellaneous', 'MySource')) ? $this->addSingleLineFieldToXml($request->getVal('pages', ''), 'pages') : '') . (!$sourceType || in_array($sourceType, array('Book', 'Article', 'Government / Church records', 'Miscellaneous', 'MySource')) ? $this->addSingleLineFieldToXml($request->getVal('references', ''), 'references') : '') . $this->addMultiLineFieldToXml($request->getVal('surnames', ''), 'formatSurname') . $this->addMultiLineFieldToXml($request->getVal('places', ''), 'formatPlace') . $this->addSingleLineFieldToXml($request->getVal('fromYear', ''), 'from_year') . $this->addSingleLineFieldToXml($request->getVal('toYear', ''), 'to_year') . $this->addMultiLineFieldToXml($subjects, 'formatSubject') . (in_array('Ethnic/Cultural', $subjects) ? $this->addSingleLineFieldToXml($request->getVal('ethnicity', ''), 'ethnicity') : '') . (in_array('Church records', $subjects) ? $this->addSingleLineFieldToXml($request->getVal('religion', ''), 'religion') : '') . (in_array('Occupation', $subjects) ? $this->addSingleLineFieldToXml($request->getVal('occupation', ''), 'occupation') : '');
     for ($i = 0; $request->getVal("repository_id{$i}"); $i++) {
         $title = trim($request->getVal("repository_title{$i}"));
         $location = trim($request->getVal("repository_location{$i}"));
         $availability = trim($request->getVal("availability{$i}"));
         if ($title || $location) {
             $result .= $this->addMultiAttrFieldToXml(array('title' => $title, 'source_location' => $location, 'availability' => $availability), 'repository');
         }
     }
     return $result;
 }
Пример #13
0
 /**
  * Return xml elements from data in request
  * @param unknown $request
  */
 protected function fromEditFields($request)
 {
     $this->correctedPlaceTitles = PlaceSearcher::correctPlaceTitlesMultiLine($request->getVal('places', ''));
     $result = '';
     if ($this->isSubpage) {
         $result .= $this->addMultiLineFieldToXml($request->getVal('surnames', ''), 'formatSurname');
         $result .= $this->addMultiLineFieldToXml($request->getVal('places', ''), 'formatPlace');
         $result .= $this->addSingleLineFieldToXml($request->getVal('fromYear', ''), 'from_year');
         $result .= $this->addSingleLineFieldToXml($request->getVal('toYear', ''), 'to_year');
     } else {
         $placesToCorrect = array();
         for ($i = 0; $request->getVal("researching_id{$i}"); $i++) {
             $place = trim($request->getVal("researching_place{$i}"));
             if ($place && mb_strpos($place, '|') === false) {
                 $placesToCorrect[] = $place;
             }
         }
         $correctedPlaceTitles = PlaceSearcher::correctPlaceTitles($placesToCorrect);
         for ($i = 0; $request->getVal("researching_id{$i}"); $i++) {
             $surname = StructuredData::standardizeNameCase(trim($request->getVal("researching_surname{$i}")), false);
             $place = trim($request->getVal("researching_place{$i}"));
             if ($surname || $place) {
                 // if you change this, you must also change FamilyTreeAjaxFunctions
                 if ($place) {
                     $correctedPlace = @$correctedPlaceTitles[$place];
                     if ($correctedPlace) {
                         $place = $correctedPlace;
                     }
                 }
                 $result .= $this->addMultiAttrFieldToXml(array('surname' => $surname, 'place' => $place), 'researching');
             }
         }
     }
     return $result;
 }