/** * constructor */ function wfSpecialGotoPageOld() { global $wgOut, $wgRequest, $wgUser; $error = ''; $titleList = ''; $addPersonFamily = false; $title = null; $namespace = $wgRequest->getVal('namespace'); $titleText = $wgRequest->getVal('pagetitle'); if ($namespace == 'person') { $addPersonFamily = true; $titleText = wrConstructName($wgRequest->getVal('personGiven'), $wgRequest->getVal('personSurname')); if ($titleText) { $title = Title::newFromText($titleText, NS_PERSON); } } else { if ($namespace == 'family') { $addPersonFamily = true; $husbandText = wrConstructName($wgRequest->getVal('husbandGiven'), $wgRequest->getVal('husbandSurname')); $wifeText = wrConstructName($wgRequest->getVal('wifeGiven'), $wgRequest->getVal('wifeSurname')); $titleText = ''; if ($husbandText && $wifeText) { $titleText = $husbandText . ' and ' . $wifeText; } else { if ($husbandText) { $titleText = $husbandText . ' and Unknown'; } else { if ($wifeText) { $titleText = 'Unknown and ' . $wifeText; } } } if ($titleText) { $title = Title::newFromText($titleText, NS_FAMILY); } } else { if ($titleText) { $title = Title::newFromText($titleText, $namespace); if (is_null($title)) { $error = wfmsg('invalidtitle'); } else { if ($wgRequest->getVal('add') && ($title->getNamespace() == NS_USER || $title->getNamespace() == NS_USER_TALK)) { // user must exist if we're adding a page for them $pos = strpos($title->getText(), '/'); if ($pos !== false) { $userName = substr($title->getText(), 0, $pos); } else { $userName = $title->getText(); } if (!User::isIP($userName) && User::idFromName($userName) == 0) { $error = 'User does not exist. Is the name spelled correctly?'; $title = null; } } } } } } if ($title) { if ($wgRequest->getVal('goto')) { if ($title->getNamespace() == NS_SPECIAL || $title->exists()) { $wgOut->redirect($title->getFullURL()); return; } else { $error = 'Title not found.'; $skin = $wgUser->getSkin(); $n = 0; $moreLink = false; $dbr =& wfGetDB(DB_SLAVE); $res = $dbr->select('page', array('page_title', 'page_namespace', 'page_is_redirect'), 'page_namespace=' . $title->getNamespace() . ' and page_title like "' . $title->getDBkey() . '%"', 'wfSpecialGotoPageOld', array('LIMIT' => 31, 'ORDER BY' => 'page_title')); while ($row = $dbr->fetchObject($res)) { if ($n == 30) { $moreLink = true; break; } if (!$titleList) { $titleList = '<h2>Titles starting with ' . $titleText . '</h2><table style="background: inherit;" border="0" width="100%">'; } $t = Title::makeTitle($row->page_namespace, $row->page_title); if ($t) { $link = ($row->page_is_redirect ? '<div class="allpagesredirect">' : '') . $skin->makeKnownLinkObj($t, htmlspecialchars($t->getPrefixedText())) . ($row->page_is_redirect ? '</div>' : ''); } else { $link = '[[' . htmlspecialchars($row->page_title) . ']]'; } if ($n % 3 == 0) { $titleList .= '<tr>'; } $titleList .= "<td>{$link}</td>"; $n++; if ($n % 3 == 0) { $titleList .= '</tr>'; } } $dbr->freeResult($res); if ($n % 3 != 0) { $titleList .= '</tr>'; } if ($titleList) { $titleList .= '</table>'; $error .= " All pages starting with {$titleText} are listed below."; } if ($moreLink) { $t = Title::makeTitle(NS_SPECIAL, 'Allpages'); $titleList .= '<p>More not shown (' . $skin->makeKnownLinkObj($t, 'show all', "from={$title->getText()}&namespace={$title->getNamespace()}") . ')</p>'; } } } else { if ($wgRequest->getVal('add')) { // PERSON and FAMILY pages must have a unique id if (($title->getNamespace() == NS_PERSON || $title->getNamespace() == NS_FAMILY) && !StructuredData::titleStringHasId($title->getText())) { // standardize name case and append a unique id $title = StructuredData::appendUniqueId(Title::newFromText((string) StructuredData::standardizeNameCase($title->getText()), $title->getNamespace())); } if ($title != null) { $wgOut->redirect($title->getFullURL('action=edit')); } return; } } } // set up page $wgOut->setPagetitle('Go to / Add page'); $wgOut->setArticleRelated(false); $wgOut->setRobotpolicy('noindex,nofollow'); if ($error) { $wgOut->addHTML("<p><font color=red>{$error}</font></p>"); } $wgOut->addHTML("<center>" . getGotoPageForm($namespace, $titleText) . "</center>"); if (!$addPersonFamily) { if ($titleList) { $wgOut->addHTML($titleList); } else { $wgOut->addWikiText("\n\n" . wfmsg('gotopageend')); } } }
/** * Return true if xml property is valid */ protected function validateData(&$textbox1) { global $wgUser; if (!StructuredData::titleStringHasId($this->titleString)) { return false; } if (ESINHandler::hasAmbiguousDates($this->xml)) { return false; } if (!StructuredData::isRedirect($textbox1)) { $husbands = StructuredData::getTitlesAsArray($this->xml->husband); $wives = StructuredData::getTitlesAsArray($this->xml->wife); $children = StructuredData::getTitlesAsArray($this->xml->child); return !StructuredData::titlesOverlap($husbands, $wives) && !StructuredData::titlesOverlap($husbands, $children) && !StructuredData::titlesOverlap($wives, $children) && ($this->isGedcomPage || !StructuredData::titlesMissingId($husbands)) && ($this->isGedcomPage || !StructuredData::titlesMissingId($wives)) && ($this->isGedcomPage || !StructuredData::titlesMissingId($children)) && ($wgUser->isAllowed('patrol') || StructuredData::titlesExist(NS_PERSON, $husbands)) && ($wgUser->isAllowed('patrol') || StructuredData::titlesExist(NS_PERSON, $wives)) && ($wgUser->isAllowed('patrol') || StructuredData::titlesExist(NS_PERSON, $children)); } return true; }
public static function titlesMissingId($titleArray) { foreach ($titleArray as $t) { if (!StructuredData::titleStringHasId($t)) { return true; } } return false; }
/** * Return true if xml property is valid * textbox1 passed by reference for efficiency; don't change it */ protected function validateData(&$textbox1) { global $wgUser; if (!StructuredData::titleStringHasId($this->titleString)) { return false; } if (ESINHandler::hasAmbiguousDates($this->xml)) { return false; } if (!StructuredData::isRedirect($textbox1)) { $parentFamilies = StructuredData::getTitlesAsArray($this->xml->child_of_family); $spouseFamilies = StructuredData::getTitlesAsArray($this->xml->spouse_of_family); return !ESINHandler::isLiving($this->xml) && strlen((string) $this->xml->gender) > 0 && !StructuredData::titlesOverlap($parentFamilies, $spouseFamilies) && ($this->isGedcomPage || !StructuredData::titlesMissingId($parentFamilies)) && ($this->isGedcomPage || !StructuredData::titlesMissingId($spouseFamilies)) && ($wgUser->isAllowed('patrol') || StructuredData::titlesExist(NS_FAMILY, $parentFamilies)) && ($wgUser->isAllowed('patrol') || StructuredData::titlesExist(NS_FAMILY, $spouseFamilies)); } return true; }
function doSubmit() { global $wgOut, $wgUser, $wgRequest; $fname = "MovePageForm::doSubmit"; if ($wgUser->pingLimiter('move')) { $wgOut->rateLimited(); return; } # Variables beginning with 'o' for old article 'n' for new article // WERELATE - default ns on new title to ns on old title $ot = Title::newFromText($this->oldTitle); $nt = Title::newFromText($this->newTitle, $ot->getNamespace()); // WERELATE - added: PERSON and FAMILY pages must have a unique id if ($nt && ($nt->getNamespace() == NS_PERSON || $nt->getNamespace() == NS_FAMILY) && !StructuredData::titleStringHasId($nt->getText())) { $nt = StructuredData::appendUniqueId($nt); } # Delete to make way if requested // WERELATE: added title parm and $nt condition if ($nt && $wgUser->isAllowed('delete', $nt) && $this->deleteAndMove) { $article = new Article($nt); // This may output an error message and exit $article->doDelete(wfMsgForContent('delete_and_move_reason')); } # don't allow moving to pages with # in if (!$nt || $nt->getFragment() != '') { $this->showForm('badtitletext'); return; } $error = $ot->moveTo($nt, true, $this->reason); if ($error !== true) { $this->showForm($error); return; } wfRunHooks('SpecialMovepageAfterMove', array(&$this, &$ot, &$nt)); # Move the talk page if relevant, if it exists, and if we've been told to $ott = $ot->getTalkPage(); if ($ott->exists()) { if ($wgRequest->getVal('wpMovetalk') == 1 && !$ot->isTalkPage() && !$nt->isTalkPage()) { $ntt = $nt->getTalkPage(); # Attempt the move $error = $ott->moveTo($ntt, true, $this->reason); if ($error === true) { $talkmoved = 1; wfRunHooks('SpecialMovepageAfterMove', array(&$this, &$ott, &$ntt)); } else { $talkmoved = $error; } } else { # Stay silent on the subject of talk. $talkmoved = ''; } } else { $talkmoved = 'notalkpage'; } # Give back result to user. $titleObj = Title::makeTitle(NS_SPECIAL, 'Movepage'); $success = $titleObj->getFullURL('action=success&oldtitle=' . wfUrlencode($ot->getPrefixedText()) . '&newtitle=' . wfUrlencode($nt->getPrefixedText()) . '&talkmoved=' . $talkmoved); $wgOut->redirect($success); }
/** * Create family tree page * * @param unknown_type $args user, name, ns, title * @return FTE_SUCCESS, FTE_INVALID_ARG, FTE_NOT_LOGGED_IN, FTE_NOT_AUTHORIZED, FTE_NOT_FOUND, FTE_DUP_KEY, FTE_DB_ERROR */ function wfCreateFamilyTreePage($args) { global $wgUser, $wgAjaxCachePolicy, $wrBotUserID, $wgArticle, $wgTitle; // set cache policy $wgAjaxCachePolicy->setPolicy(0); $status = FTE_SUCCESS; $ns = ''; $titleString = ''; $revid = 0; $xml = simplexml_load_string($args); $userName = (string) $xml['user']; $treeName = (string) $xml['name']; $ns = (int) $xml['ns']; $titleString = (string) $xml['title']; $text = (string) $xml; if (!$userName || !$treeName || !$titleString || !($ns == NS_PERSON || $ns == NS_FAMILY)) { $status = FTE_INVALID_ARG; } else { if (!$wgUser->isLoggedIn()) { $status = FTE_NOT_LOGGED_IN; } else { if ($userName != $wgUser->getName() || $wgUser->isBlocked() || wfReadOnly()) { $status = FTE_NOT_AUTHORIZED; } } } if ($status == FTE_SUCCESS) { // get tree id $treeId = 0; $status = ftGetTreeId($userName, $treeName, $treeId); if ($status == FTE_SUCCESS && !$treeId) { $status = FTE_NOT_FOUND; } } if ($status == FTE_SUCCESS) { $dbw =& wfGetDB(DB_MASTER); $dbw->ignoreErrors(true); $dbw->begin(); $title = Title::newFromText($titleString, $ns); if ($title == null) { $status = FTE_INVALID_ARG; } else { if (!StructuredData::titleStringHasId($titleString)) { $title = StructuredData::appendUniqueId($title, $dbw); } $article = new Article($title, 0); if ($article->exists()) { $status = FTE_DUP_KEY; } } if ($status == FTE_SUCCESS) { // set the global article and title to this, so that propagation works ok $wgArticle = $article; $wgTitle = $article->getTitle(); // NOTE: This doesn't execute the code in FamilyTreePropagator to update familytree_page and add page to tree, but we don't want that to be called // because we add the page to the tree below if (!$article->doEdit($text, 'creating initial family tree', EDIT_NEW)) { $status = FTE_WIKI_ERROR; } else { $revid = $article->mRevIdEdited; } } // add the page to the tree if ($status == FTE_SUCCESS) { if (!FamilyTreeUtil::addPage($dbw, $wgUser, $treeId, $title, $revid, 0)) { $status = FTE_DB_ERROR; } } // watch the page if ($status == FTE_SUCCESS) { StructuredData::addWatch($wgUser, $article, true); } if ($status == FTE_SUCCESS) { $dbw->commit(); } else { $dbw->rollback(); } } // return status $titleString = StructuredData::escapeXml($title->getText()); return "<create status=\"{$status}\" ns=\"{$ns}\" title=\"{$titleString}\" latest=\"{$revid}\"></create>"; }
private function fromPage($request, $name, $ns) { $result = ''; $titles = array(); for ($i = 0; $request->getVal("{$name}_id{$i}"); $i++) { $titleString = $request->getVal("{$name}{$i}"); if ($titleString) { if (!StructuredData::titleStringHasId($titleString)) { $titleString = StructuredData::standardizeNameCase($titleString, true); } if (!in_array($titleString, $titles)) { $result .= $this->formatPageElement($name, $titleString, $ns); $titles[] = $titleString; } } } return $result; }