/** * List all family trees for a user * * @param unknown_type $args user * @return FTE_SUCCESS, FTE_INVALID_ARG, FTE_NOT_LOGGED_IN, FTE_DB_ERROR */ function wfListFamilyTrees($args) { global $wgAjaxCachePolicy, $wgLang; // set cache policy $wgAjaxCachePolicy->setPolicy(0); // validate input arguments $status = FTE_SUCCESS; $result = ''; $args = AjaxUtil::getArgs($args); if (!@$args['user']) { $status = FTE_INVALID_ARG; } else { $familyTrees = FamilyTreeUtil::getFamilyTrees($args['user'], true); if (is_null($familyTrees)) { $status = FTE_DB_ERROR; } else { foreach ($familyTrees as $familyTree) { $treeName = StructuredData::escapeXml($familyTree['name']); $timestamp = StructuredData::escapeXml($wgLang->timeanddate(wfTimestamp(TS_MW, $familyTree['timestamp']), true)); $result .= "<tree name=\"{$treeName}\" timestamp=\"{$timestamp}\" count=\"{$familyTree['count']}\"/>\n"; } } } // return status return "<list status=\"{$status}\">{$result}</list>"; }
/** * There's something wrong with this file, not enough to reject it * totally but we require manual intervention to save it for real. * Stash it away, then present a form asking to confirm or cancel. * * @param string $warning as HTML * @access private */ function uploadWarning($warning) { global $wgOut; global $wgUseCopyrightUpload; $this->mSessionKey = $this->stashSession(); if (!$this->mSessionKey) { # Couldn't save file; an error has been displayed so let's go. return; } $wgOut->addHTML("<h2>" . wfMsgHtml('uploadwarning') . "</h2>\n"); $wgOut->addHTML("<ul class='warning'>{$warning}</ul><br />\n"); $save = wfMsgHtml('savefile'); $reupload = wfMsgHtml('reupload'); $iw = wfMsgWikiHtml('ignorewarning'); $reup = wfMsgWikiHtml('reuploaddesc'); $titleObj = Title::makeTitle(NS_SPECIAL, 'Upload'); // WERELATE: added target and id $query = 'action=submit'; if ($this->mTarget) { $query .= '&target=' . urlencode($this->mTarget) . '&id=' . urlencode($this->mId); } $action = $titleObj->escapeLocalURL($query); if ($wgUseCopyrightUpload) { $copyright = "\n\t<input type='hidden' name='wpUploadCopyStatus' value=\"" . htmlspecialchars($this->mUploadCopyStatus) . "\" />\n\t<input type='hidden' name='wpUploadSource' value=\"" . htmlspecialchars($this->mUploadSource) . "\" />\n\t"; } else { $copyright = ""; } // WERELATE - added back-button instructions; added four fields; added id='wpUpload' to wpUpload button; removed reupload; added $people and $families; added checkboxes // metadata fields and tree checkboxes are ignored in a re-upload situation $people = $this->toForm($this->mPeople, 'person', NS_PERSON, false); $families = $this->toForm($this->mFamilies, 'family', NS_FAMILY, false); //!!! remove this code dependency before sharing require_once "extensions/familytree/FamilyTreeUtil.php"; global $wgUser, $wgRequest; $allTrees = FamilyTreeUtil::getFamilyTrees($wgUser->getName()); $checkedTreeIds = FamilyTreeUtil::readTreeCheckboxes($allTrees, $wgRequest); $treecheckboxeshtml = FamilyTreeUtil::generateHiddenTreeCheckboxes($allTrees, $checkedTreeIds); $wgOut->addHTML("<p><b>Press the \"back button\" on your browser to choose a different file, or</b></p>"); $wgOut->addHTML("\n\t<form id='uploadwarning' method='post' enctype='multipart/form-data' action='{$action}'>\n\t\t<input type='hidden' name='wpIgnoreWarning' value='1' />\n\t\t<input type='hidden' name='wpSessionKey' value=\"" . htmlspecialchars($this->mSessionKey) . "\" />\n\t\t<input type='hidden' name='wpUploadDescription' value=\"" . htmlspecialchars($this->mUploadDescription) . "\" />\n\t\t<input type='hidden' name='wrDate' value=\"" . htmlspecialchars($this->mDate) . "\" />\n\t\t<input type='hidden' name='wrPlace' value=\"" . htmlspecialchars($this->mPlace) . "\" />\n\t\t{$people}\n\t\t{$families}\n\t\t{$treecheckboxeshtml}\n\t\t<input type='hidden' name='wrCopyright' value=\"" . htmlspecialchars($this->mCopyright) . "\" />\n\t\t<input type='hidden' name='wpLicense' value=\"" . htmlspecialchars($this->mLicense) . "\" />\n\t\t<input type='hidden' name='wpDestFile' value=\"" . htmlspecialchars($this->mDestFile) . "\" />\n\t\t<input type='hidden' name='wpWatchthis' value=\"" . htmlspecialchars(intval($this->mWatchthis)) . "\" />\n\t{$copyright}\n\t<table border='0'>\n\t\t<tr>\n\t\t\t<tr>\n\t\t\t\t<td align='right'>\n\t\t\t\t\t<input tabindex='2' type='submit' id='wpUpload' name='wpUpload' value=\"{$save}\" />\n\t\t\t\t</td>\n\t\t\t\t<td align='left'>{$iw}</td>\n\t\t\t</tr>\n\t\t</tr>\n\t</table></form>\n"); }
/** * Displays the main upload form, optionally with a highlighted * error message up at the top. * * @param string $msg as HTML * @access private */ function mainUploadForm($msg = '') { global $wgOut, $wgUser; global $wgUseCopyrightUpload; // set up page $wgOut->setPagetitle('Import GEDCOM'); $wgOut->setArticleRelated(false); $wgOut->setRobotpolicy('noindex,nofollow'); if ('' != $msg) { $sub = 'Import Error'; $wgOut->addHTML("<h2>{$sub}</h2>\n" . "<span class='error'>{$msg}</span>\n"); } $wgOut->addScript(<<<END <script type='text/javascript'>/*<![CDATA[*/ function hideNewTreeName() { \tsel = document.getElementById('wrTreeName'); \ttreeName = sel.options[sel.selectedIndex].value; \$('span.wrNewTreeName').css('display',treeName == '[new]' ? 'inline' : 'none'); } /*]]>*/</script> END ); $sk = $wgUser->getSkin(); $country = $this->mDefaultCountry ? $this->mDefaultCountry : 'United States'; $defaultCountryControl = StructuredData::addSelectToHtml(0, 'wrDefaultCountry', GedcomImport::$DEFAULT_COUNTRIES, $country, '', false); $treeFound = false; $trees = FamilyTreeUtil::getFamilyTrees($wgUser->getName(), false); $treeList = '<select name="wrTreeName" id="wrTreeName" onchange="hideNewTreeName()">'; for ($i = 0; $i < count($trees); $i++) { $encTreeName = htmlspecialchars($trees[$i]['name']); if ($trees[$i]['name'] == $this->mTreeName) { $treeFound = true; $selected = ' selected="selected"'; } else { $selected = ''; } $treeList .= "<option value=\"{$encTreeName}\"{$selected}>{$encTreeName}</option>"; } if ($treeFound || strlen($this->mTreeName) == 0 && count($trees) > 0) { $selected = ''; $display = 'none'; $encNewTreeName = ''; } else { $selected = ' selected="selected"'; $display = 'inline'; $encNewTreeName = htmlspecialchars($this->mNewTreeName); } $treeList .= "<option value=\"[new]\"{$selected}><New tree></option>"; $treeList .= '</select>'; $sourcefilename = 'GEDCOM filename'; $importIntoTree = 'Import into tree'; $newTreeName = 'Tree name'; $importGedcom = 'Import GEDCOM'; $titleObj = Title::makeTitle(NS_SPECIAL, 'ImportGedcom'); $action = $titleObj->escapeLocalURL(); $wgOut->addHTML(<<<END <form id='import' method='post' enctype='multipart/form-data' action="{$action}"> <table border='0'> <tr> <td align='right'><label for='wrUploadFile'>{$sourcefilename}:</label></td> <td align='left'><input type='file' name='wrUploadFile' id='wrUploadFile' size='30' /></td> </tr> <tr> <td align="right"><label for="wrDefaultCountry">Default country:</label></td> <td align="left" style="font-size: 11px; line-height:2em">{$defaultCountryControl} if places in your GEDCOM don't have countries, this country will be assumed</td> </tr> <tr> <td align='right'><label for='wrTreeName'>{$importIntoTree}</label></td> <td align='left'>{$treeList} \t<span class='wrNewTreeName' style='display:{$display}'><label for='wrNewTreeName'>{$newTreeName}</label></span> <span class='wrNewTreeName' style='display:{$display}'><input type='text' name='wrNewTreeName' size='29' value="{$encNewTreeName}"/></span> <input type='submit' id='wrImport' name='wrImport' value="{$importGedcom}" /></td> </tr> </table> </form> END ); $wgOut->addWikiText(wfMsg('importgedcomtext')); }
private function updateTrees($user, $title, $revId, $request) { //wfDebug("updateTrees " . $title->getPrefixedText() . " " . $revId . "\n"); $allTrees = FamilyTreeUtil::getFamilyTrees($user->getName()); $treeOwnerIds = FamilyTreeUtil::getOwnerTrees($user, $title, false); $checkedTreeIds = FamilyTreeUtil::readTreeCheckboxes($allTrees, $request); return FamilyTreeUtil::updateTrees($this->db, $title, $revId, $allTrees, $treeOwnerIds, $checkedTreeIds, true, false); }
/** * Create family tree page * * This is also called by search.js * * @param unknown_type $args * @return GE_SUCCESS, GE_INVALID_ARG, GE_NOT_LOGGED_IN, GE_NOT_AUTHORIZED, GE_NOT_FOUND, GE_DUP_KEY, GE_DB_ERROR */ function wfAddPage($args) { global $wgUser, $wgAjaxCachePolicy, $wgArticle, $wgTitle, $wgLang; // set cache policy $wgAjaxCachePolicy->setPolicy(0); $status = GE_SUCCESS; $title = null; $titleString = null; $error = ''; $args = AjaxUtil::getArgs($args); $ns = $wgLang->getNsIndex($args['ns']); $titleString = @$args['title']; $update = $args['update'] == 'true'; if (!$wgUser->isLoggedIn()) { $status = GE_NOT_LOGGED_IN; } else { if ($wgUser->isBlocked() || wfReadOnly()) { $status = GE_NOT_AUTHORIZED; } } if ($status == GE_SUCCESS) { $dbw =& wfGetDB(DB_MASTER); $dbw->ignoreErrors(true); $dbw->begin(); $text = ''; if ($titleString) { // user passed in existing title; just add to watchlist and trees $title = Title::newFromText($titleString, $ns); } else { if ($ns == NS_PERSON) { if (ESINHandler::isLivingDates($args['bd'], null, $args['dd'], $args['dp'])) { $error = 'Living people cannot be added to WeRelate. People born in the last 110 years must have a death date'; } else { if (ESINHandler::isAmbiguousDate($args['bd']) || ESINHandler::isAmbiguousDate($args['dd'])) { $error = "Please write dates in D MMM YYYY format so they are unambiguous (ie 5 Jan 1900)"; } else { if (!$title) { $title = StructuredData::constructPersonTitle($args['g'], $args['s']); } if ($title) { if ($args['bt'] == 'chr') { $bird = ''; $birp = ''; $chrd = $args['bd']; $chrp = $args['bp']; } else { $bird = $args['bd']; $birp = $args['bp']; $chrd = ''; $chrp = ''; } if ($args['dt'] == 'bur') { $dead = ''; $deap = ''; $burd = $args['dd']; $burp = $args['dp']; } else { $dead = $args['dd']; $deap = $args['dp']; $burd = ''; $burp = ''; } $text = Person::getPageText($args['g'], $args['s'], $args['gnd'], $bird, $birp, $dead, $deap, $title->getText(), null, @$args['pf'], @$args['sf'], $chrd, $chrp, $burd, $burp); } } } } else { if ($ns == NS_FAMILY) { if (ESINHandler::isAmbiguousDate($args['md'])) { $error = "Please write dates in D MMM YYYY format so they are unambiguous (ie 5 Jan 1900)"; } else { $title = StructuredData::constructFamilyTitle($args['hg'], $args['hs'], $args['wg'], $args['ws']); if ($title) { $text = Family::getPageText($args['md'], $args['mp'], $title->getText(), null, @$args['ht'], @$args['wt'], @$args['ct']); } } } else { if ($ns == NS_SOURCE) { $title = StructuredData::constructSourceTitle($args['sty'], $args['st'], $args['a'], $args['p'], $args['pi'], $args['pu']); if ($title) { $text = Source::getPageText($args['sty'], $args['st'], $args['a'], $args['p'], $args['pi'], $args['pu']); } else { $error = 'Required source fields are missing; please press the Back button on your browser to enter the required fields.'; } } else { if ($ns == NS_MYSOURCE) { $t = $args['t']; if (mb_strpos($t, $wgUser->getName() . '/') != 0) { $t = $wgUser->getName() . '/' . $t; } $title = Title::newFromText($t, NS_MYSOURCE); if ($title) { $text = MySource::getPageText($args['a'], $args['p'], $args['s']); } } else { if ($ns == NS_PLACE) { $title = StructuredData::constructPlaceTitle($args['pn'], $args['li']); $text = Place::getPageText(); // check existing located-in, not root $titleText = $title->getFullText(); $pos = mb_strpos($titleText, ','); if ($pos === false) { $title = null; $error = 'You need to fill in the country'; } else { $locatedIn = Title::newFromText(trim(mb_substr($titleText, $pos + 1)), NS_PLACE); if (!$locatedIn->exists()) { $title = null; $error = 'Before you can add this place, you must first add ' . $locatedIn->getFullText(); } } } } } } } } if ($status == GE_SUCCESS && $title == null) { $status = GE_INVALID_ARG; if (!$error) { $error = 'Invalid page title; unable to create page'; } } // don't update in the case of the user passing in a non-existing titleString if ($update && !($titleString && !$title->exists())) { if ($status == GE_SUCCESS) { $article = new Article($title, 0); // don't set the global article and title to this; we don't need to propagate -- but we do for places // 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 ($title->exists()) { // don't update the page if it already exists, except to add a spouse-family if ($ns == NS_PERSON && @$args['sf']) { $content =& $article->fetchContent(); $updated = false; Person::updateFamilyLink('spouse_of_family', '', $args['sf'], $content, $updated); if ($updated) { $article->doEdit($content, 'Add spouse family: [[Family:' . $args['sf'] . ']]', EDIT_UPDATE); StructuredData::purgeTitle($title, +1); // purge person with a fudge factor so family link will be blue } } $revid = 0; // ok for revid to be 0 if page exists because we no longer use revid } else { if (!$article->doEdit($text, '')) { $status = GE_WIKI_ERROR; } else { $revid = $article->mRevIdEdited; } } } if ($status == GE_SUCCESS) { // add the page to the trees (or to no trees) $allTrees = FamilyTreeUtil::getFamilyTrees($wgUser->getName()); $trees = explode('|', @$args['tree']); $checkedTreeIds = array(); foreach ($allTrees as $tree) { if (in_array(FamilyTreeUtil::toInputName($tree['name']), $trees)) { $checkedTreeIds[] = $tree['id']; // if (!FamilyTreeUtil::addPage($dbw, $wgUser, $tree['id'], $title, $revid, 0)) { // $status = GE_DB_ERROR; // } } } // update which trees are checked FamilyTreeUtil::updateTrees($dbw, $title, $revid, $allTrees, array(), $checkedTreeIds); } // watch the page if ($status == GE_SUCCESS) { StructuredData::addWatch($wgUser, $article, true); } } if ($status == GE_SUCCESS) { $dbw->commit(); } else { $dbw->rollback(); if (!$error) { $error = 'Unable to create page'; } } } // return status $titleString = ''; if ($title) { $titleString = StructuredData::escapeXml($title->getText()); } return "<addpage status=\"{$status}\" title=\"{$titleString}\" error=\"{$error}\"></addpage>"; }
public static function generateTreeCheckboxes($user, $title, $editPage, $allTrees = null, $treeOwnerIds = null) { global $wgRequest, $wgUser; $result = ''; $cnt = 0; // $editPage is true also for adding a page in Special:Search // title may be null for image upload or adding a page in Special:Search if ($title == null || FamilyTreeUtil::isTreePage($title->getNamespace(), $title->getDBkey())) { $isNew = $title == null || $title->getArticleID() == 0; if (!is_array($allTrees)) { $allTrees = FamilyTreeUtil::getFamilyTrees($user->getName()); } if (count($allTrees) > 0) { if ($editPage && $wgRequest->wasPosted()) { $checkedTrees = FamilyTreeUtil::readTreeCheckboxes($allTrees, $wgRequest); } else { if (is_array($treeOwnerIds)) { $checkedTrees = $treeOwnerIds; } else { $checkedTrees = $title == null ? array() : FamilyTreeUtil::getOwnerTrees($user, $title, false); } // if we're creating the page and the user has just one tree and no tree is checked if ($editPage && $isNew && count($allTrees) == 1 && count($checkedTrees) == 0) { $checkedTrees[] = $allTrees[0]['id']; } } // if no trees checked, check the default tree(s) if (count($checkedTrees) == 0 && !$wgRequest->wasPosted() && !($isNew && $wgUser->getIntOption('watchcreations') === 0 || !$isNew && $wgUser->getIntOption('watchdefault') === 0)) { foreach ($allTrees as $tree) { if ($tree['checked']) { $checkedTrees[] = $tree['id']; } } } foreach ($allTrees as $tree) { $cnt++; $class = ''; if ($editPage && !$wgRequest->wasPosted() && ($title == null || $title->getArticleID() == 0)) { if ($cnt == 1 && count($checkedTrees) == 0) { $class = ' treeCheckbox'; // defaultTreeCheckbox"'; } else { $class = ' treeCheckbox'; } } $result .= " <input type=\"checkbox\" class=\"treeCheck{$class}\"" . ' name="' . htmlspecialchars(FamilyTreeUtil::toInputName($tree['name'])) . '"' . (in_array($tree['id'], $checkedTrees) ? " checked='checked'" : "") . "/> " . htmlspecialchars($tree['name']) . ($editPage ? '' : "<br/>\n"); } } } if ($editPage && $cnt) { $result = wfMsg('addtotreecheckbox') . $result; } return $result; }
private function getTrees() { global $wgUser; $skin =& $wgUser->getSkin(); $dbr =& wfGetDB(DB_SLAVE); $gedcoms = array(); $rows = $dbr->select(array('familytree_gedcom', 'familytree'), array('fg_id', 'fg_tree_id', 'fg_gedcom_filename'), array('fg_tree_id = ft_tree_id', 'ft_user' => $wgUser->getName(), 'fg_status' => FG_STATUS_PHASE2)); while ($row = $dbr->fetchObject($rows)) { $gedcoms[] = array('fg_id' => $row->fg_id, 'fg_tree_id' => $row->fg_tree_id, 'fg_gedcom_filename' => $row->fg_gedcom_filename); } $dbr->freeResult($rows); $ret = '<div class="myrelate-header">Tree(s)</div><ul>'; $familyTrees = FamilyTreeUtil::getFamilyTrees($wgUser->getName()); foreach ($familyTrees as $familyTree) { $ret .= '<li>' . htmlspecialchars($familyTree['name']) . ' ( ' . $skin->makeKnownLinkObj(Title::makeTitle(NS_SPECIAL, 'Search'), 'view', 'k=' . urlencode('+Tree:"' . $wgUser->getName() . '/' . $familyTree['name'] . '"')) . ' ) ( ' . '<a href="/fte/index.php?userName='******'&treeName=' . urlencode($familyTree['name']) . '">launch FTE</a> )'; $found = false; foreach ($gedcoms as $gedcom) { if ($gedcom['fg_tree_id'] == $familyTree['id']) { if (!$found) { $ret .= '<ul>'; } $found = true; $ret .= '<li>' . htmlspecialchars($gedcom['fg_gedcom_filename']) . ' <a href="/gedcom/index.php?gedcomId=' . $gedcom['fg_id'] . '" rel="nofollow">Waiting for review</a></li>'; } } if ($found) { $ret .= '</ul>'; } $ret .= '</li>'; } $tip = 'Create, rename, delete, and email trees'; $ret .= '</ul>' . $skin->makeKnownLinkObj(Title::makeTitle(NS_SPECIAL, 'Trees'), 'Manage trees', '', '', '', '', " title=\"{$tip}\""); return $ret; }
function wrDoContentActions($action, $article) { global $wgUser, $wgOut, $wgRequest; if ($action != 'treeUpdate' && $action != 'treeUpdateConfirm') { return true; // handle by another content action handler } if ($wgUser->isAnon()) { $wgOut->showErrorPage('treenologintitle', 'treenologintext'); return false; } if (!FamilyTreeUtil::isTreePage($article->getTitle()->getNamespace(), $article->getTitle()->getDBkey())) { $wgOut->showErrorPage('treenonamespacetitle', 'treenonamespacetext'); return false; } if (wfReadOnly()) { $wgOut->readOnlyPage(); return false; } $allTrees = FamilyTreeUtil::getFamilyTrees($wgUser->getName()); $treeOwnerIds = FamilyTreeUtil::getOwnerTrees($wgUser, $article->getTitle(), false); $checkedTreeIds = FamilyTreeUtil::readTreeCheckboxes($allTrees, $wgRequest); $ancGenerations = $wgRequest->getVal('ancestorgenerations'); $includeAncestorChildren = $wgRequest->getCheck('includeancestorchildren'); $descGenerations = $wgRequest->getVal('descendantgenerations'); $wgOut->setRobotpolicy('noindex,nofollow'); if ($action == 'treeUpdateConfirm' && ($ancGenerations == 0 && $descGenerations == 0 || count($checkedTreeIds) > 0)) { $dbw =& wfGetDB(DB_MASTER); $result = FamilyTreeUtil::updateTrees($dbw, $article->getTitle(), $article->getRevIdFetched(), $allTrees, $treeOwnerIds, $checkedTreeIds); if ($result) { $dbw->commit(); } else { $dbw->rollback(); } if ($ancGenerations > 0 || $descGenerations > 0) { $job = new AddTreePagesJob(array('trees' => join(',', $checkedTreeIds), 'user' => $wgUser->getName(), 'title' => $article->getTitle()->getPrefixedText(), 'ancGenerations' => $ancGenerations, 'includeAncestorChildren' => $includeAncestorChildren, 'descGenerations' => $descGenerations)); $job->insert(); $treesUpdatedMsg = 'treesupdatedtextdeferred'; } else { $treesUpdatedMsg = 'treesupdatedtext'; } $wgOut->setPagetitle(wfMsg('treesupdatedtitle')); $wgOut->addWikiText(wfMsg($treesUpdatedMsg)); $wgOut->returnToMain(true, $article->getTitle()->getPrefixedText()); } else { if (count($allTrees) == 0) { $wgOut->showErrorPage('treenonetitle', 'treenonetext'); } else { // show form $wgOut->setPagetitle(wfMsg('treeupdatetitle')); if ($action == 'treeUpdateConfirm') { $wgOut->addHTML('<font color="red">Please check the box next to the tree(s) you want to add the pages to.</font>'); } $wgOut->addWikiText('==Trees=='); $wgOut->addWikiText(wfMsg('treeupdatetext')); // TODO show form $action = $article->getTitle()->escapeLocalURL('action=treeUpdateConfirm'); $wgOut->addHTML(<<<END <form id="treeUpdate" method="post" action="{$action}" enctype="multipart/form-data"> END ); $wgOut->addHTML(FamilyTreeUtil::generateTreeCheckboxes($wgUser, $article->getTitle(), false, $allTrees, $treeOwnerIds)); if ($article->getTitle()->getNamespace() == NS_PERSON || $article->getTitle()->getNamespace() == NS_FAMILY) { $wgOut->addWikiText('==Include relatives=='); $wgOut->addWikiText(":'''''Warning''': including relatives can add potentially many people to your tree and to your watchlist.''"); $wgOut->addWikiText(':Add the following relatives to the checked trees.'); $options = array(); for ($i = 0; $i <= 20; $i++) { $options["{$i}"] = $i; } $ancGenerations = StructuredData::addSelectToHtml(0, 'ancestorgenerations', $options, 0); $options = array(); for ($i = 0; $i <= 5; $i++) { $options["{$i}"] = $i; } $descGenerations = StructuredData::addSelectToHtml(0, 'descendantgenerations', $options, 0); $wgOut->addHTML(<<<END <dl><dd>Include ancestors for {$ancGenerations} generations \t<dl><dd><input type="checkbox" name="includeancestorchildren"/>Also include ancestors' children</dd></dl></dd> <dd> </dd> <dd>Include descendants for {$descGenerations} generations</dd> </dl> END ); } $updateButton = array('id' => 'wrTreeUpdate', 'name' => 'wrTreeUpdate', 'type' => 'submit', 'value' => wfMsg('treeupdatebutton'), 'title' => wfMsg('treeupdatebuttontip')); $wgOut->addHTML(wfElement('input', $updateButton, '')); $wgOut->addHTML("</form>\n"); } } return false; // stop processing }
/** * Create wiki text from xml property */ protected function toWikiText($parser) { global $wrHostName; $result = ''; if (!$this->isSubpage) { $familyTrees = FamilyTreeUtil::getFamilyTrees($this->userName, true); $personalResearchPages = $this->getPersonalResearchPages(); } else { $familyTrees = array(); $personalResearchPages = array(); } // $result = '{| id="structuredData" border=1 class="floatright" cellpadding=4 cellspacing=0 width=40%'."\n"; // $result = "<div class=\"infobox-header\">Profile</div>\n{|\n"; // if (count($familyTrees) > 0) { // $result .= $this->addRowsToTable('Family Tree(s)', $familyTrees, 'formatFamilyTree', null); // } if (isset($this->xml)) { // if ($this->isSubpage) { // $result .= $this->addValuesToTableDL('Surname(s):', $this->xml->surname, 'formatAsLink', 'Surname'); // $result .= $this->addValuesToTableDL('Place(s):', $this->xml->place, 'formatAsLink', 'Place'); // if ((string)$this->xml->from_year || (string)$this->xml->to_year) { // $result .= $this->addValueToTableDL("Year range:", "{$this->xml->from_year} - {$this->xml->to_year}"); // } // } // else { // $result .= $this->addRowsToTable('Researching', $this->xml->researching, 'formatResearchLinks', null); // $result .= $this->addRowsToTable('User Pages', $this->getPersonalResearchPages(), 'formatPersonalResearchPageLink', null); // } $values = array(); foreach ($this->xml->researching as $researching) { $surname = StructuredData::standardizeNameCase((string) $researching['surname'], false); // $fields = explode('|',(string)$researching['place']); // $place = trim($fields[0]); // $surnames = array(); // $places = array(); // if ($surname) $surnames[] = $surname; // if ($place) $places[] = $place; // $categories = StructuredData::addCategories($surnames, $places, true, '', NS_MAIN, true); // $ret = ''; // if ($surname && $place) { // $ret = "<dl><dt>[[$surname in $place]]<dd>Categories: $categories</dl>"; // } // else if ($surname) { // $ret = "<dl><dt>[[Surname:$surname]]<dd>Category: $categories</dl>"; // } // else if ($place) { // $ret = "<dl><dt>[[Place:$place]]<dd>Category: $categories</dl>"; // } // if ($ret) $values[] = $ret; if ($surname) { $values[] = '[http://' . $wrHostName . '/wiki/Special:Search?ns=User&s=' . $surname . ' ' . $surname . ']'; } } $researching = $this->getLV('Users Researching', array_unique($values)); $values = array(); foreach ($this->xml->surname as $surname) { $values[] = $this->formatAsLink((string) $surname, 'Surname'); } $surnames = $this->getLV('Surnames', $values); $values = array(); foreach ($this->xml->place as $place) { $values[] = $this->formatAsLink((string) $place, 'Place'); } $places = $this->getLV('Places', $values); $fromYear = (string) $this->xml->from_year; $toYear = (string) $this->xml->to_year; $yearRange = ''; if ($fromYear || $toYear) { $yearRange = $this->getLV('Year range', "{$fromYear} - {$toYear}"); } $values = array(); foreach ($familyTrees as $familyTree) { $values[] = '<dl><dt>' . $familyTree['name'] . ' <span class="plainlinks">' . ' ([http://' . $wrHostName . '/wiki/Special:Search?k=' . urlencode('+Tree:"' . $this->userName . '/' . $familyTree['name'] . '"') . " view])" . ' ([http://' . $wrHostName . '/fte/index.php?userName='******'&treeName=' . urlencode($familyTree['name']) . " launch FTE])" . "</span><dd>people: {$familyTree['count']}</dl>"; } $familyTrees = $this->getLV('Family Trees', $values); $values = array(); foreach ($personalResearchPages as $personalResearchPage) { $t = Title::newFromText($personalResearchPage, NS_USER); if ($t) { $values[] = '[[' . $t->getPrefixedText() . '|' . $t->getText() . ']]'; } } $personalResearchPages = $this->getLV('User pages', $values); $heading = $surnames || $places || $yearRange ? 'Page Covers' : ''; $result = "<div class=\"wr-infobox wr-infobox-userpage\"><div class=\"wr-infobox-heading\">{$heading}</div><dl>{$surnames}{$places}{$yearRange}{$familyTrees}{$researching}{$personalResearchPages}</dl></div>"; } // $result .= $this->showWatchers(); // $result .= "|}\n"; if (isset($this->xml)) { if ($this->isSubpage) { $result .= StructuredData::addCategories($this->xml->surname, $this->xml->place); } else { foreach ($this->xml->researching as $researching) { $surnames = array(); $places = array(); $surnames[] = (string) $researching['surname']; $places[] = (string) $researching['place']; $result .= StructuredData::addCategories($surnames, $places); } } } return $result; }
private function getTrees() { global $wgUser, $wrHostName; $skin =& $wgUser->getSkin(); $ret = '<div id="familytree-table"><table width="99%" cellpadding="5" cellspacing="0" border="0">' . '<tr><td><b>Name</b></td><td><b>People</b></td><td><b>GEDCOM</b></td><td><b>Share</b></td><td><b>Rename</b></td><td><b>Delete</b></td></tr>'; $dbr =& wfGetDB(DB_SLAVE); $familyTrees = FamilyTreeUtil::getFamilyTrees($wgUser->getName()); if (!is_null($familyTrees)) { foreach ($familyTrees as $familyTree) { $gedcom = $this->getGedcoms($dbr, $familyTree['id'], $familyTree['name']); $share = '<span class="plainlinks">[http://' . $wrHostName . '/wiki/Special:FamilyTree?action=shareTree&name=' . urlencode($familyTree['name']) . ' share]</span>'; $rename = '<span class="plainlinks">[http://' . $wrHostName . '/wiki/Special:FamilyTree?action=renameTree&name=' . urlencode($familyTree['name']) . ' rename]</span>'; $delete = '<span class="plainlinks">[http://' . $wrHostName . '/wiki/Special:FamilyTree?action=deleteTree&name=' . urlencode($familyTree['name']) . ' delete]</span>'; $ret .= '<tr><td>' . htmlspecialchars($familyTree['name']) . ' <span class="plainlinks">' . ' ( [http://' . $wrHostName . '/wiki/Special:ShowFamilyTree?user='******'&name=' . urlencode($familyTree['name']) . " list] )" . ' ( [http://' . $wrHostName . '/fte/index.php?userName='******'&treeName=' . urlencode($familyTree['name']) . " launch FTE] )" . '</span><td>' . $familyTree['count'] . "</td><td>{$gedcom}</td><td>{$share}</td><td>{$rename}</td><td>{$delete}</td></tr>"; // $ret .= '<tr><td>' . htmlspecialchars($familyTree['name']) . // ' ( ' . $skin->makeKnownLinkObj(Title::makeTitle(NS_SPECIAL, 'ShowFamilyTree'), 'list', wfArrayToCGI(array('user' => $wgUser->getName(), 'name' => $familyTree['name'])), '', '', '', " title=\"$listTip\"") . ' ) '. // ' ( <a href="/fte/index.php?' . wfArrayToCGI(array('userName' => $wgUser->getName(), 'treeName' => $familyTree['name'])) . '" title="'.$launchTip.'">launch FTE</a> )</td>'. // '<td>' . $familyTree['count'] . "</td><td>$gedcom</td><td>$rename</td><td>$delete</td></tr>"; } } $ret .= '</table></div>'; return $ret; }