private function readXmlData() { $dataString = GedcomUtil::getGedcomDataString(); if ($dataString) { $this->xml = simplexml_load_string($dataString); // if you need attributes other than id, ns, title, save them in submitPage() if ($this->xml && $this->xml['id'] == $this->gedcomkey) { // set data $content = (string) $this->xml->content; unset($this->xml->content); $xmlString = $this->xml->asXML(); $xmlString = substr($xmlString, strpos($xmlString, '<', 1)); // skip past the <?xml version="1.0"? > header // remove attributes from the opening tag because StructuredData::getXml doesn't expect them $xmlString = preg_replace('/<(\\S+)[^>]*>/', '<$1>', $xmlString, 1); $this->data = $xmlString . $content; // append content } return true; } else { return false; } }
public function readQueryParms($par) { global $wgRequest; $this->namespace = $wgRequest->getVal('ns'); $this->gedcomTab = $wgRequest->getVal('gedcomtab'); $this->gedcomKey = $wgRequest->getVal('gedcomkey'); $compare = $wgRequest->getVal('compare'); if ($compare) { $this->compareTitles = explode('|', $compare); } else { for ($i = 0; $i <= 200; $i++) { $t = $wgRequest->getVal('compare_' . $i); if ($t) { if (strpos($t, 'Person:') === 0 || strpos($t, 'Family:') === 0) { $t = substr($t, 7); } $this->compareTitles[] = $t; } } } $isGedcomTitle = false; foreach ($this->compareTitles as &$t) { // fix up titles just in case $t = str_replace('_', ' ', $t); if (GedcomUtil::isGedcomTitle($t)) { $isGedcomTitle = true; } } if ($isGedcomTitle) { $this->gedcomDataString = GedcomUtil::getGedcomDataString(); $this->gedcomData = GedcomUtil::getGedcomDataMap($this->gedcomDataString); } return ($this->namespace == 'Person' || $this->namespace == 'Family') && count($this->compareTitles) > 0 && (!$isGedcomTitle || $this->gedcomDataString); }
private function loadFamilyMembers() { $xml = null; $this->prevFamilyMembers = array(); if ($this->isGedcomPage) { $dataString = GedcomUtil::getGedcomDataString(); if ($dataString) { $xml = simplexml_load_string($dataString); } } else { $revision = StructuredData::getRevision($this->title); if ($revision) { $content =& $revision->getText(); $xml = StructuredData::getXml('family', $content); } } if (isset($xml)) { foreach ($xml->husband as $member) { $title = (string) $member['title']; $this->prevFamilyMembers[$title] = Family::getFamilyMemberAttributes($member); } foreach ($xml->wife as $member) { $title = (string) $member['title']; $this->prevFamilyMembers[$title] = Family::getFamilyMemberAttributes($member); } foreach ($xml->child as $member) { $title = (string) $member['title']; $this->prevFamilyMembers[$title] = Family::getFamilyMemberAttributes($member); } } }
public function readQueryParms($par) { global $wgRequest, $wgUser; $this->formAction = $wgRequest->getVal('formAction'); $this->namespace = $wgRequest->getVal('ns'); $this->editToken = $wgRequest->getVal('wpEditToken'); $this->isMerging = $wgRequest->getCheck('merging'); $this->gedcomTab = $wgRequest->getVal('gedcomtab'); $this->gedcomKey = $wgRequest->getVal('gedcomkey'); $this->gedcomDataString = $wgRequest->getCheck('gedcom') ? GedcomUtil::getGedcomDataString() : $wgRequest->getVal('gedcomdata'); if ($this->gedcomDataString) { $this->gedcomData = GedcomUtil::getGedcomDataMap($this->gedcomDataString); $this->gedcomId = GedcomUtil::getGedcomId($this->gedcomDataString); } $this->isTrusted = CompareForm::isTrustedMerger($wgUser, $this->gedcomDataString); $this->addWatches = $wgUser->getOption('watchdefault'); //wfDebug("merge user={$wgUser->getName()} formAction={$this->formAction} ns=$this->namespace gedcomId={$this->gedcomId} wpEditToken={$this->editToken} merging={$this->isMerging}\n"); if (!$this->editToken) { // first phase $maxPages = $wgRequest->getVal('maxpages'); if ($this->namespace == 'Family') { $maxChildren = $wgRequest->getVal('maxchildren'); for ($i = 0; $i < $maxChildren + self::$CHILD_START_ROW; $i++) { $this->data[$i] = array(); // create a bunch of empty rows } } else { $maxChildren = 0; $this->data[0] = array(); } //wfDebug("merge phase1 maxpages=$maxPages maxchildren=$maxChildren\n"); for ($i = 0; $i < $maxPages; $i++) { $pageTitle = trim($wgRequest->getVal('m_' . $i)); //wfDebug("m_$i=$pageTitle\n"); if ($pageTitle) { $this->appendTitle(0, $pageTitle); if ($this->namespace == 'Family') { $pageTitle = trim($wgRequest->getVal('mh_' . $i)); //wfDebug("mh_$i=$pageTitle\n"); if ($pageTitle) { $this->appendTitle(self::$HUSBAND_ROW, $pageTitle); } $pageTitle = trim($wgRequest->getVal('mw_' . $i)); //wfDebug("mw_$i=$pageTitle\n"); if ($pageTitle) { $this->appendTitle(self::$WIFE_ROW, $pageTitle); } } } } if ($this->namespace == 'Family') { for ($c = 0; $c < $maxChildren; $c++) { for ($i = 0; $i < $maxPages; $i++) { if ($wgRequest->getVal('m_' . $i)) { $mergeRow = $wgRequest->getVal("mcr_{$i}_{$c}"); //wfDebug("mcr_{$i}_$c=$mergeRow\n"); if ($mergeRow) { $childTitle = trim($wgRequest->getVal("mc_{$i}_{$c}")); //wfDebug("mc_{$i}_$c=$childTitle\n"); $this->appendTitle($mergeRow - 1 + self::$CHILD_START_ROW, $childTitle); } } } } $this->removeSingletonFamilyMemberRows(); } } else { // second phase: merges = #merges; merges_m = #pages in merge m; merges_m_p = page title; rows_m = #rows in merge m; // add_m_p_r = 1 if checked; key_m_p_r = key of row r $mergesCount = $wgRequest->getVal('merges'); //wfDebug("merge phase2 merges=$mergesCount\n"); for ($m = 0; $m < $mergesCount; $m++) { $pagesCount = $wgRequest->getVal("merges_{$m}"); $rowsCount = $wgRequest->getVal("rows_{$m}"); $this->target[$m] = $wgRequest->getVal("target_{$m}"); //wfDebug("merges_$m=$pagesCount rows_$m=$rowsCount target_$m={$this->target[$m]}\n"); $this->data[$m] = array(); $this->add[$m] = array(); $this->key[$m] = array(); $pos = 0; $namespace = $this->namespace == 'Family' && $m == 0 ? 'Family' : 'Person'; for ($p = 0; $p < $pagesCount; $p++) { $pageTitle = trim($wgRequest->getVal("merges_{$m}_{$p}")); //wfDebug("merges_{$m}_{$p}=$pageTitle\n"); if ($pageTitle) { $this->data[$m][$pos] = array(); $this->add[$m][$pos] = array(); $this->key[$m][$pos] = array(); $this->data[$m][$pos]['title'] = $pageTitle; // $this->data[$m][$pos]['missingdata'] = false; for ($r = 0; $r < $rowsCount; $r++) { $this->add[$m][$pos][$r] = $wgRequest->getVal("add_{$m}_{$p}_{$r}"); $this->key[$m][$pos][$r] = $wgRequest->getVal("key_{$m}_{$p}_{$r}"); //wfDebug("add_{$m}_{$p}_{$r}={$this->add[$m][$pos][$r]} key_{$m}_{$p}_{$r}={$this->key[$m][$pos][$r]}\n"); // if ($this->key[$m][$pos][$r] && !$this->add[$m][$pos][$r]) { // $this->data[$m][$pos]['missingdata'] = true; // } } $pos++; } else { error_log("merge readQueryParms page title missing user={$wgUser->getName()}"); } } } $this->userComment = $wgRequest->getVal("userComment"); } }
public function readQueryParms($par) { global $wgRequest, $wgUser; $this->target = $wgRequest->getVal('target'); $this->match = $wgRequest->getVal('match'); $this->pagetitle = $wgRequest->getVal('pagetitle'); $gedcomData = null; if ($this->pagetitle && GedcomUtil::isGedcomTitle($this->pagetitle)) { $gedcomDataString = GedcomUtil::getGedcomDataString(); $gedcomData = GedcomUtil::getGedcomDataMap($gedcomDataString); } $this->ecp = $wgRequest->getVal('ecp'); if (!$this->ecp) { if ($this->target || $this->match) { $this->ecp = 'p'; // partial } else { $this->ecp = 'c'; } } $this->talk = $wgRequest->getCheck('talk'); $this->sort = $wgRequest->getVal('sort'); $this->titleLetter = $wgRequest->getVal('tl'); $this->namespace = $wgRequest->getVal('ns'); if (!$this->namespace && $par) { $this->namespace = $par; } if ($this->namespace == 'All') { $this->namespace = ''; } $this->rows = $wgRequest->getVal('rows'); if ($this->rows < 10 || $this->rows > 200) { $this->rows = 20; } $this->condensedView = $wgRequest->getCheck('cv'); $ns = $this->namespace; $this->watch = $wgRequest->getVal('watch'); if (!$this->watch) { $this->watch = "wu"; } if ($ns == '' || $ns == 'Image' || $ns == 'Person') { $this->givenname = trim($wgRequest->getVal('g')); } if ($ns == '' || $ns == 'Image' || $ns == 'Person' || $ns == 'Article' || $ns == 'Source' || $ns == 'MySource' || $ns == 'User') { $this->surname = trim($wgRequest->getVal('s')); } if ($ns == '' || $ns == 'Image' || $ns == 'Article' || $ns == 'Source' || $ns == 'MySource' || $ns == 'User' || $ns == 'Repository') { $this->place = trim($wgRequest->getVal('p')); } if ($ns == 'Person') { if ($this->pagetitle && $this->match == 'on') { $this->givenname = $this->surname = $this->birthdate = $this->birthplace = $this->deathdate = $this->deathplace = $this->fatherGivenname = $this->fatherSurname = $this->motherGivenname = $this->motherSurname = $this->spouseGivenname = $this->spouseSurname = $this->birthrange = $this->deathrange = $this->personGender = $this->parentFamily = $this->spouseFamily = $this->wifeGivenname = $this->wifeSurname = $this->birthType = $this->deathType = ''; $this->setPersonMatchVars($gedcomData); } else { $this->birthdate = trim($wgRequest->getVal('bd')); $this->birthrange = $wgRequest->getVal('br'); if ($this->birthrange == '0') { $this->birthrange = ''; } $this->birthplace = trim($wgRequest->getVal('bp')); $this->deathdate = trim($wgRequest->getVal('dd')); $this->deathrange = $wgRequest->getVal('dr'); if ($this->deathrange == '0') { $this->deathrange = ''; } $this->deathplace = trim($wgRequest->getVal('dp')); $this->fatherGivenname = trim($wgRequest->getVal('fg')); $this->fatherSurname = trim($wgRequest->getVal('fs')); $this->motherGivenname = trim($wgRequest->getVal('mg')); $this->motherSurname = trim($wgRequest->getVal('ms')); $this->spouseGivenname = trim($wgRequest->getVal('sg')); $this->spouseSurname = trim($wgRequest->getVal('ss')); $this->personGender = trim($wgRequest->getVal('gnd')); $this->birthType = trim($wgRequest->getVal('bt')); $this->deathType = trim($wgRequest->getVal('dt')); $this->parentFamily = trim($wgRequest->getVal('pf')); $this->spouseFamily = trim($wgRequest->getVal('sf')); $this->wifeGivenname = trim($wgRequest->getVal('wg')); // if we're adding a father, remember the mother's name $this->wifeSurname = trim($wgRequest->getVal('ws')); $this->personSurnameFacet = $wgRequest->getVal('psf'); $this->personGivennameFacet = $wgRequest->getVal('pgf'); $this->personCountryFacet = $wgRequest->getVal('pcof'); $this->personStateFacet = $wgRequest->getVal('pstf'); $this->personCenturyFacet = $wgRequest->getVal('pcf'); $this->personDecadeFacet = $wgRequest->getVal('pdf'); } } if ($ns == 'Family') { if ($this->pagetitle && $this->match == 'on') { $this->husbandGivenname = $this->husbandSurname = $this->wifeGivenname = $this->wifeSurname = $this->personGender = $this->marriagedate = $this->marriageplace = $this->marriagerange = $this->childTitle = $this->husbandTitle = $this->wifeTitle = ''; $this->setFamilyMatchVars($gedcomData); } else { $this->husbandGivenname = trim($wgRequest->getVal('hg')); $this->husbandSurname = trim($wgRequest->getVal('hs')); $this->wifeGivenname = trim($wgRequest->getVal('wg')); $this->wifeSurname = trim($wgRequest->getVal('ws')); $this->personGender = trim($wgRequest->getVal('gnd')); // used in javascript add person page prompt to determine gender of spouse $this->marriagedate = trim($wgRequest->getVal('md')); $this->marriagerange = $wgRequest->getVal('mr'); if ($this->marriagerange == '0') { $this->marriagerange = ''; } $this->marriageplace = trim($wgRequest->getVal('mp')); $this->childTitle = trim($wgRequest->getVal('ct')); $this->husbandTitle = trim($wgRequest->getVal('ht')); $this->wifeTitle = trim($wgRequest->getVal('wt')); } } if ($ns == 'Place') { $pn = $wgRequest->getVal('pn'); $li = $wgRequest->getVal('li'); $pos = mb_strpos($li, '|'); if ($pos !== false) { $li = mb_substr($li, 0, $pos); } $pn = preg_replace('/(^[, ]+)|([, ]+$)/', '', $pn); $li = preg_replace('/(^[, ]+)|([, ]+$)/', '', $li); $place = $pn . ($pn && $li ? ', ' : '') . $li; $pos = mb_strpos($place, ','); if ($pos !== false) { $this->placename = trim(mb_substr($place, 0, $pos)); $this->locatedinplace = trim(mb_substr($place, $pos + 1)); } else { $this->placename = $place; $this->locatedinplace = ''; } } if ($ns == 'Source') { $this->sourceType = trim($wgRequest->getVal('sty')); $this->sourceTitle = trim($wgRequest->getVal('st')); $this->placeIssued = trim($wgRequest->getVal('pi')); $this->publisher = trim($wgRequest->getVal('pu')); $this->sourceSubject = $wgRequest->getVal('su'); $this->sourceAvailability = $wgRequest->getVal('sa'); $this->sub = $wgRequest->getCheck('sub'); $this->sup = $wgRequest->getCheck('sup'); } if ($ns == 'Source' || $ns == 'MySource') { $this->author = trim($wgRequest->getVal('a')); } if ($ns != '' && $ns != 'Person' && $ns != 'Family' && $ns != 'Place') { $this->title = trim($wgRequest->getVal('t')); } if ($this->target == 'AddPage' && $ns == 'MySource' && $this->title && mb_strpos($this->title, $wgUser->getName() . '/') !== 0) { $this->title = $wgUser->getName() . '/' . $this->title; } $this->keywords = trim($wgRequest->getVal('k')); $this->go = $wgRequest->getVal('go'); $this->start = $wgRequest->getVal('start'); }