function addPage($title) { $titleString = $title->getPrefixedText(); if (@$this->addedPages[$titleString]) { return true; } // already added if (!FamilyTreeUtil::updateTrees($this->dbw, $title, 0, $this->allTrees, array(), $this->treeIds, false)) { return false; } $this->addedPages[$titleString] = 1; //echo("added $titleString\n"); if ($this->count++ > 50) { // commit every 50 pages so we don't keep a tx open too long $this->dbw->commit(); $this->dbw->begin(); $this->count = 0; } return true; }
/** * 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; $cols = intval($wgUser->getOption('cols')); $ew = $wgUser->getOption('editwidth'); if ($ew) { $ew = " style=\"width:100%\""; } else { $ew = ''; } if ('' != $msg) { $sub = wfMsgHtml('uploaderror'); $wgOut->addHTML("<h2>{$sub}</h2>\n" . "<span class='error'>{$msg}</span>\n"); } $wgOut->addHTML('<div id="uploadtext">'); $wgOut->addWikiText(wfMsg('uploadtext')); $wgOut->addHTML('</div>'); $sk = $wgUser->getSkin(); $sourcefilename = wfMsgHtml('sourcefilename'); $destfilename = wfMsgHtml('destfilename'); $summary = wfMsgWikiHtml('fileuploadsummary'); $licenses = new Licenses(); $license = wfMsgHtml('license'); $nolicense = wfMsgHtml('nolicense'); $licenseshtml = $licenses->getHtml(); // WERELATE - added licenseHelp $licenseHelpUrl = $sk->makeInternalOrExternalUrl(wfMsgForContent('licensehelppage')); $licenseHelp = '<a target="helpwindow" href="' . $licenseHelpUrl . '">' . htmlspecialchars(wfMsg('licensehelp')) . '</a>'; // WERELATE - added code to select proper license if ($this->mLicense) { $protectedLicense = str_replace(array('\\', '$', '^', '.', '[', ']', '|', '(', ')', '?', '*', '+', '{', '}', '-'), array('\\\\', '\\$', '\\^', '\\.', '\\[', '\\]', '\\|', '\\(', '\\)', '\\?', '\\*', '\\+', '\\{', '\\}', '\\-'), $this->mLicense); $licenseshtml = preg_replace('$value="(' . $protectedLicense . ')"$', 'value="$1" selected="selected"', $licenseshtml); } $ulb = wfMsgHtml('uploadbtn'); $titleObj = Title::makeTitle(NS_SPECIAL, 'Upload'); // WERELATE: added target and id $query = ''; if ($this->mTarget) { $query = 'target=' . urlencode($this->mTarget) . '&id=' . urlencode($this->mId); } $action = $titleObj->escapeLocalURL($query); $encDestFile = htmlspecialchars($this->mDestFile); //WERELATE - added watchcreations $watchChecked = $wgUser->getOption('watchdefault') || $wgUser->getOption('watchcreations') ? 'checked="checked"' : ''; // WERELATE - add scripts global $wgScriptPath; $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>"); $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/image.1.js\"></script>"); // WERELATE: removed tabindexes; added id to table $wgOut->addHTML("\n\t<form id='upload' method='post' enctype='multipart/form-data' action=\"{$action}\">\n\t\t<table id='image_form_table' border='0'>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wpUploadFile'>{$sourcefilename}:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='file' name='wpUploadFile' id='wpUploadFile' " . ($this->mDestFile ? "" : "onchange='fillDestFilename()' ") . "size='40' />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wpDestFile'>{$destfilename}:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='text' name='wpDestFile' id='wpDestFile' size='40' value=\"{$encDestFile}\" />\n\t\t\t</td>\n\t\t</tr>"); // WERELATE - added check to omit fields in case of a re-upload, since they're ignored $treecheckboxeshtml = ''; if (!$this->mReUploading) { $wgOut->addHTML("\n\t\t<tr><td> </td><td> </td></tr>\n\t\t<tr><td> </td><td align='left'><b>License and copyright</b></td></tr>\n\t\t<tr>"); if ($licenseshtml != '') { global $wgStylePath; $wgOut->addHTML("\n\t\t\t<td align='right'><label for='wpLicense'>{$license} ( {$licenseHelp} ):</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<script type='text/javascript' src=\"{$wgStylePath}/common/upload.2.js\"></script>\n\t\t\t\t<select name='wpLicense' id='wpLicense' \n\t\t\t\t\tonchange='licenseSelectorCheck()'>\n\t\t\t\t\t<option value=''>{$nolicense}</option>\n\t\t\t\t\t{$licenseshtml}\n\t\t\t\t</select>\n\t\t\t</td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t"); } if ($wgUseCopyrightUpload) { $filestatus = wfMsgHtml('filestatus'); $copystatus = htmlspecialchars($this->mUploadCopyStatus); $filesource = wfMsgHtml('filesource'); $uploadsource = htmlspecialchars($this->mUploadSource); $wgOut->addHTML("\n\t\t\t <td align='right' nowrap='nowrap'><label for='wpUploadCopyStatus'>{$filestatus}:</label></td>\n\t\t\t <td><input type='text' name='wpUploadCopyStatus' id='wpUploadCopyStatus' value=\"{$copystatus}\" size='40' /></td>\n\t\t </tr>\n\t\t\t<tr>\n\t\t \t<td align='right'><label for='wpUploadCopyStatus'>{$filesource}:</label></td>\n\t\t\t <td><input type='text' name='wpUploadSource' id='wpUploadCopyStatus' value=\"{$uploadsource}\" size='40' /></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t"); } // WERELATE: added fields $personTbl = $this->toForm($this->mPeople, 'person', NS_PERSON, true); $familyTbl = $this->toForm($this->mFamilies, 'family', NS_FAMILY, true); $wgOut->addHTML("\n\t\t\t<td align='right'><label for='wrCopyright'>Copyright holder:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='text' name='wrCopyright' id='wrCopyright' size='30' value=\"" . htmlspecialchars($this->mCopyright) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr><td> </td><td> </td></tr>\n\t\t<tr><td> </td><td align='left'><b>Time place and people</b></td></tr>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wrDate'>Image date:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input type='text' name='wrDate' id='wrDate' size='15' value=\"" . htmlspecialchars($this->mDate) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right'><label for='wrPlace'>Place:</label></td>\n\t\t\t<td align='left'>\n\t\t\t\t<input class='place_input' type='text' name='wrPlace' id='wrDate' size='30' value=\"" . htmlspecialchars($this->mPlace) . "\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right' valign='top'>Person page:</td>\n\t\t\t<td align='left'>{$personTbl}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td> </td>\n\t\t\t<td align='left'><a id='person_link' href='javascript:void(0)' onClick='addImagePage(\"person\"); return preventDefaultAction(event);'>Add another person</a></td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td align='right' valign='top'>Family page:</td>\n\t\t\t<td align='left'>{$familyTbl}</td>\n\t\t</tr>\n\t\t<tr>\n\t\t\t<td> </td>\n\t\t\t<td align='left'><a id='family_link' href='javascript:void(0)' onClick='addImagePage(\"family\"); return preventDefaultAction(event);'>Add another family</a></td>\n\t\t</tr>\n\t\t"); // WERELATE - move description from above; end reUploading if statement; moved summary label // add id for wpUpload; added tree checkboxes //!!! remove this code dependency before sharing require_once "extensions/familytree/FamilyTreeUtil.php"; $t = null; if ($this->mDestFile) { $t = Title::newFromText($this->mDestFile, NS_IMAGE); } $treecheckboxeshtml = FamilyTreeUtil::generateTreeCheckboxes($wgUser, $t, true); $wgOut->addHtml("\n\t\t\t<tr><td> </td><td> </td></tr>\n\t\t\t<tr><td></td><td align='left'><b>{$summary}</b></td></tr>\n\t\t\t<tr><td></td><td align='left'>\n\t\t\t\t<textarea name='wpUploadDescription' id='wpUploadDescription' rows='6' cols='{$cols}'{$ew}>" . htmlspecialchars($this->mUploadDescription) . "</textarea>\n\t\t\t</td>\n\t\t</tr> "); } $wgOut->addHTML("\n\t\t<tr>\n\t\t<td></td>\n\t\t<td>\n\t\t\t<input type='checkbox' name='wpWatchthis' id='wpWatchthis' {$watchChecked} value='true' />\n\t\t\t<label for='wpWatchthis'>" . wfMsgHtml('watchthis') . "</label>\n\t\t\t<input type='checkbox' name='wpIgnoreWarning' id='wpIgnoreWarning' value='true' />\n\t\t\t<label for='wpIgnoreWarning'>" . wfMsgHtml('ignorewarnings') . "</label>" . $treecheckboxeshtml . "\n\t\t</td>\n\t</tr>\n\t<tr>\n\n\t</tr>\n\t<tr>\n\t\t<td></td>\n\t\t<td align='left'><input type='submit' id='wpUpload' name='wpUpload' value=\"{$ulb}\" /></td>\n\t</tr>\n\n\t<tr>\n\t\t<td></td>\n\t\t<td align='left'>\n\t\t"); $wgOut->addWikiText(wfMsgForContent('edittools')); $wgOut->addHTML("\n\t\t</td>\n\t</tr>\n\n\t</table>\n\t</form>"); }
function getTrees() { if ($this->trees == null) { $this->trees = array(); if ($this->mUser->isLoggedIn() && FamilyTreeUtil::isTreePage($this->mTitle->getNamespace(), $this->mTitle->getDBkey())) { $this->trees = FamilyTreeUtil::getOwnerTrees($this->mUser, $this->mTitle, true); } } return $this->trees; }
private function formatResults($response, $recentDocs, $selfQuery) { global $wgUser; $output = ''; $start = $response['response']['start']; $numFound = $response['response']['numFound']; $end = $start + $this->rows; if ($end > $numFound) { $end = $numFound; } if ($this->target && $this->namespace != 'Image') { // can't currently add images from here; just select them $jsFunction = $this->getAddJSFunction() . '; return preventDefaultAction(event);'; $output .= "<table><tr><td><input type=\"submit\" value=\"Add Page\" onClick=\"{$jsFunction}\"/></td>" . "<td><b> Select one of the pages below, or click <a href=\"javascript:void(0);\" onClick=\"{$jsFunction}\">Add Page</a> to create a new page</b>" . ' <span id="pleasewait" style="display: none"><span style="font-size: 80%; padding: 0 .2em; color: #fff; background-color: #888">Please Wait</span></span>' . ($this->target != 'AddPage' && $this->target != 'gedcom' && ($this->namespace == 'Person' || $this->namespace == 'Family') ? '<br/>' . FamilyTreeUtil::generateTreeCheckboxes($wgUser, null, true) : '') . '</td></tr></table><hr/>'; } if ($numFound == 0 && count($recentDocs) == 0) { $output .= '<p></p><p><font size=+1>Your search did not match any documents.</font></p>'; } else { // display prev..next naviagtion if ($start > 0) { $prevStart = $start - $this->rows; if ($prevStart < 0) { $prevStart = 0; } } $startPlusOne = $start + 1; $prevNextLinks = ($start > 0 ? "<a href=\"{$selfQuery}&start={$prevStart}\">« Prev</a> |" : '') . " Viewing <b>{$startPlusOne}-{$end}</b> of {$numFound}" . ($end < $numFound ? " | <a href=\"{$selfQuery}&start={$end}\">Next »</a>" : ''); $output .= "<div class=\"prev_next_links_top\">{$prevNextLinks}</div>\n"; // add compare button if ($this->match) { $skin =& $wgUser->getSkin(); $wrCompareURL = "/wiki/Special:Compare"; $t = Title::newFromText($this->namespace . ':' . $this->pagetitle); $ts = ''; if ($t) { $ts = htmlspecialchars($t->getText()); $titleText = GedcomUtil::isGedcomTitle($this->pagetitle) ? '<b>' . htmlspecialchars($t->getPrefixedText()) . '</b>' : $skin->makeKnownLinkObj($t); $compareButton = '<input type="submit" value="Compare"/> checked pages with ' . $titleText; } $output .= '<form name="compare" action="' . $wrCompareURL . '" method="post">' . $compareButton . '<input type="hidden" name="ns" value="' . $this->namespace . '"/>' . '<input type="hidden" name="compare_0" value="' . $ts . '"/>'; } // generate the result list $docs = $response['response']['docs']; $highlighting = $response['highlighting']; $output .= '<table class="searchresulttable">'; $pos = 0; foreach ($recentDocs as $doc) { $output .= $this->formatResult($doc, array(), -1, $this->condensedView); } foreach ($docs as $doc) { $pageId = $doc['PageId']; $hl = $highlighting[$pageId]; $output .= $this->formatResult($doc, $hl, $pos, $this->condensedView); $pos++; } $output .= '</table>'; // add compare button if ($this->match) { $output .= $compareButton . '</form>'; } // display prev..next navigation if ($this->namespace == 'Person' || $this->namespace == 'Family') { $similarNamesProject = wfMsgWikiHtml('SimilarNamesProjectLink'); } else { $similarNamesProject = ''; } $output .= <<<END <table style="width:99%"><tr> <td style="width:33%"> </td> <td style="width:33%; text-align:center">{$prevNextLinks}</td> <td style=" width:33%; text-align:right">{$similarNamesProject}</td> </tr></table> END; } return $output; }
public static function updateGedcomMatch($dbw, $treeId, $gedcomId, $key, $matchTitle, $merged, $gedcomUser) { $newTitle = $matchTitle == '#nomatch#' ? null : Title::newFromText($matchTitle); $oldTitle = null; // read old match_namespace and title $row = $dbw->selectRow('familytree_gedcom_data', array('fgd_match_namespace', 'fgd_match_title'), array('fgd_gedcom_id' => $gedcomId, 'fgd_gedcom_key' => $key)); if ($row && $row->fgd_match_namespace > 0) { $oldTitle = Title::makeTitle($row->fgd_match_namespace, $row->fgd_match_title); if ($oldTitle && ($oldTitle->getNamespace() == NS_PERSON || $oldTitle->getNamespace() == NS_FAMILY || $oldTitle->getNamespace() == NS_MYSOURCE) && (!$newTitle || $oldTitle->getPrefixedText() != $newTitle->getPrefixedText())) { // remove match title from tree if (!FamilyTreeUtil::removePage($dbw, $treeId, $oldTitle)) { return false; } // unwatch match title if no other trees contain it if (!$dbw->selectField('familytree_page', 'fp_tree_id', array('fp_namespace' => $row->fgd_match_namespace, 'fp_title' => $row->fgd_match_title, 'fp_user_id' => $gedcomUser->getID()))) { $article = new Article($oldTitle, 0); StructuredData::removeWatch($gedcomUser, $article); } } } if ($newTitle) { $matchTitle = $newTitle->getDBkey(); $matchNamespace = $newTitle->getNamespace(); $potentialMatchesAttr = ''; $potentialMatchesValue = ''; $potentialMatchesUpdate = ''; if (($newTitle->getNamespace() == NS_PERSON || $newTitle->getNamespace() == NS_FAMILY || $newTitle->getNamespace() == NS_MYSOURCE) && (!$oldTitle || $oldTitle->getPrefixedText() != $newTitle->getPrefixedText())) { // add match title to tree if (!FamilyTreeUtil::addPage($dbw, $gedcomUser, $treeId, $newTitle, 0, 0)) { return false; } // watch match title $article = new Article($newTitle, 0); StructuredData::addWatch($gedcomUser, $article); } } else { $matchTitle = ''; $matchNamespace = -1; $merged = 0; $potentialMatchesAttr = ', fgd_potential_matches'; // reset potential matches to what's in the gedcom $potentialMatchesValue = ", ''"; $potentialMatchesUpdate = ", fgd_potential_matches=''"; } $matchTitle = $dbw->addQuotes($matchTitle); $sql = "INSERT INTO familytree_gedcom_data (fgd_gedcom_id, fgd_gedcom_key, fgd_match_namespace, fgd_match_title, fgd_merged{$potentialMatchesAttr})" . " VALUES({$gedcomId}," . $dbw->addQuotes($key) . ",{$matchNamespace},{$matchTitle},{$merged}{$potentialMatchesValue})" . " ON DUPLICATE KEY UPDATE fgd_match_namespace={$matchNamespace}, fgd_match_title={$matchTitle}, fgd_merged={$merged}{$potentialMatchesUpdate}"; $dbw->query($sql); return $dbw->lastErrno() == 0; }
/** * 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')); }
/** * Bookmark 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 wfSetPrimaryFamilyTreePage($args) { global $wgAjaxCachePolicy; // set cache policy $wgAjaxCachePolicy->setPolicy(0); $ns = ''; $titleString = ''; // validate args $args = AjaxUtil::getArgs($args); $status = ftValidateUpdateFamilyTreePageArgs($args); if ($status == FTE_SUCCESS) { // get tree id $treeId = 0; $status = ftGetTreeId($args['user'], $args['name'], $treeId); } if ($status == FTE_SUCCESS) { // get page $ns = $args['ns']; $titleString = $args['title']; $title = Title::newFromText($titleString, $ns); if (!$title) { $status = FTE_INVALID_ARG; } } if ($status == FTE_SUCCESS) { $dbw =& wfGetDB(DB_MASTER); $dbw->ignoreErrors(true); $dbw->begin(); $dbw->update('familytree', array('ft_primary_namespace' => $title->getNamespace(), 'ft_primary_title' => $title->getDBkey()), array('ft_tree_id' => $treeId)); FamilyTreeUtil::deleteFamilyTreesCache($args['user']); $errno = $dbw->lastErrno(); if ($errno > 0) { $status = FTE_DB_ERROR; } if ($status == FTE_SUCCESS) { $dbw->commit(); } else { $dbw->rollback(); } } // return status $ns = @$args['ns']; $titleString = StructuredData::escapeXml(@$args['title']); return "<setprimary status=\"{$status}\" ns=\"{$ns}\" title=\"{$titleString}\"></setprimary>"; }
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); }
/** * Send the edit form and related headers to $wgOut * @param $formCallback Optional callable that takes an OutputPage * parameter; will be called during form output * near the top, for captchas and the like. */ function showEditForm($formCallback = null) { global $wgOut, $wgUser, $wgLang, $wgContLang, $wgMaxArticleSize; $fname = 'EditPage::showEditForm'; wfProfileIn($fname); $sk =& $wgUser->getSkin(); wfRunHooks('EditPage::showEditForm:initial', array(&$this)); $wgOut->setRobotpolicy('noindex,nofollow'); # Enabled article-related sidebar, toplinks, etc. $wgOut->setArticleRelated(true); if ($this->isConflict) { $s = wfMsg('editconflict', $this->mTitle->getPrefixedText()); $wgOut->setPageTitle($s); $wgOut->addWikiText(wfMsg('explainconflict')); $this->textbox2 = $this->textbox1; $this->textbox1 = $this->getContent(); $this->edittime = $this->mArticle->getTimestamp(); } else { if ($this->section != '') { if ($this->section == 'new') { $s = wfMsg('editingcomment', $this->mTitle->getPrefixedText()); } else { // WERELATE: distinguish section from topic $s = wfMsg($this->mTitle->isTalkPage() ? 'editingtopic' : 'editingsection', $this->mTitle->getPrefixedText()); if (!$this->preview && !$this->diff) { preg_match("/^(=+)(.+)\\1/mi", $this->textbox1, $matches); if (!empty($matches[2])) { // WERELATE: remove date from summary for topics if ($this->mTitle->isTalkPage()) { $matches[2] = preg_replace('/\\[[^\\]]+\\] *$/', '', $matches[2]); } $this->summary = "/* " . trim($matches[2]) . " */ "; } } } } else { $s = wfMsg('editing', $this->mTitle->getPrefixedText()); } $wgOut->setPageTitle($s); if ($this->missingComment) { $wgOut->addWikiText(wfMsg('missingcommenttext')); } if ($this->missingSummary) { $wgOut->addWikiText(wfMsg('missingsummary')); } if (!$this->hookError == '') { $wgOut->addWikiText($this->hookError); } if (!$this->checkUnicodeCompliantBrowser()) { $wgOut->addWikiText(wfMsg('nonunicodebrowser')); } if (isset($this->mArticle) && isset($this->mArticle->mRevision) && !$this->mArticle->mRevision->isCurrent()) { $this->mArticle->setOldSubtitle($this->mArticle->mRevision->getId()); $wgOut->addWikiText(wfMsg('editingold')); } } if (wfReadOnly()) { $wgOut->addWikiText(wfMsg('readonlywarning')); } elseif ($wgUser->isAnon() && $this->formtype != 'preview') { $wgOut->addWikiText(wfMsg('anoneditwarning')); } else { if ($this->isCssJsSubpage && $this->formtype != 'preview') { # Check the skin exists if ($this->isValidCssJsSubpage) { $wgOut->addWikiText(wfMsg('usercssjsyoucanpreview')); } else { $wgOut->addWikiText(wfMsg('userinvalidcssjstitle', $this->mTitle->getSkinFromCssJsSubpage())); } } } if ($this->mTitle->isProtected('edit')) { # Is the protection due to the namespace, e.g. interface text? if ($this->mTitle->getNamespace() == NS_MEDIAWIKI) { # Yes; remind the user $notice = wfMsg('editinginterface'); } elseif ($this->mTitle->isSemiProtected()) { # No; semi protected $notice = wfMsg('semiprotectedpagewarning'); if (wfEmptyMsg('semiprotectedpagewarning', $notice) || $notice == '-') { $notice = ''; } } else { # No; regular protection $notice = wfMsg('protectedpagewarning'); } $wgOut->addWikiText($notice); } if ($this->kblength === false) { $this->kblength = (int) (strlen($this->textbox1) / 1024); } if ($this->tooBig || $this->kblength > $wgMaxArticleSize) { $wgOut->addWikiText(wfMsg('longpageerror', $wgLang->formatNum($this->kblength), $wgMaxArticleSize)); } $rows = $wgUser->getIntOption('rows'); $cols = $wgUser->getIntOption('cols'); $ew = $wgUser->getOption('editwidth'); if ($ew) { $ew = " style=\"width:100%\""; } else { $ew = ''; } $q = 'action=submit'; #if ( "no" == $redirect ) { $q .= "&redirect=no"; } $action = $this->mTitle->escapeLocalURL($q); $summary = wfMsg('summary'); $subject = wfMsg('subject'); $minor = wfMsgExt('minoredit', array('parseinline')); $watchthis = wfMsgExt('watchthis', array('parseinline')); $cancel = $sk->makeKnownLink($this->mTitle->getPrefixedText(), wfMsgExt('cancel', array('parseinline'))); $edithelpurl = $sk->makeInternalOrExternalUrl(wfMsgForContent('edithelppage')); $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' . htmlspecialchars(wfMsg('edithelp')) . '</a> ' . htmlspecialchars(wfMsg('newwindow')); global $wgRightsText; $copywarn = "<div id=\"editpage-copywarn\">\n" . wfMsg($wgRightsText ? 'copyrightwarning' : 'copyrightwarning2', '[[' . wfMsgForContent('copyrightpage') . ']]', $wgRightsText) . "\n</div>"; if ($wgUser->getOption('showtoolbar') and !$this->isCssJsSubpage) { # prepare toolbar for edit buttons $toolbar = $this->getEditToolbar(); } else { $toolbar = ''; } // activate checkboxes if user wants them to be always active if (!$this->preview && !$this->diff) { # Sort out the "watch" checkbox if ($wgUser->getOption('watchdefault')) { # Watch all edits $this->watchthis = true; } elseif ($wgUser->getOption('watchcreations') && !$this->mTitle->exists()) { # Watch creations $this->watchthis = true; } elseif ($this->mTitle->userIsWatching()) { # Already watched $this->watchthis = true; } if ($wgUser->getOption('minordefault')) { $this->minoredit = true; } } $minoredithtml = ''; if ($wgUser->isAllowed('minoredit')) { $minoredithtml = "<input tabindex='3' type='checkbox' value='1' name='wpMinoredit'" . ($this->minoredit ? " checked='checked'" : "") . " accesskey='" . wfMsg('accesskey-minoredit') . "' id='wpMinoredit' />\n" . "<label for='wpMinoredit' title='" . wfMsg('tooltip-minoredit') . "'>{$minor}</label>\n"; } $watchhtml = ''; if ($wgUser->isLoggedIn()) { $watchhtml = "<input tabindex='4' type='checkbox' name='wpWatchthis'" . ($this->watchthis ? " checked='checked'" : "") . " accesskey=\"" . htmlspecialchars(wfMsg('accesskey-watch')) . "\" id='wpWatchthis' />\n" . "<label for='wpWatchthis' title=\"" . htmlspecialchars(wfMsg('tooltip-watch')) . "\">{$watchthis}</label>\n"; } $checkboxhtml = $minoredithtml . $watchhtml; if ($wgUser->getOption('previewontop')) { if ('preview' == $this->formtype) { $this->showPreview(); } else { $wgOut->addHTML('<div id="wikiPreview"></div>'); } if ('diff' == $this->formtype) { $wgOut->addHTML($this->getDiff()); } } # if this is a comment, show a subject line at the top, which is also the edit summary. # Otherwise, show a summary field at the bottom $summarytext = htmlspecialchars($wgContLang->recodeForEdit($this->summary)); # FIXME if ($this->section == 'new') { // WERELATE - added extra br $commentsubject = "<span id='wpSummaryLabel'><label for='wpSummary'>{$subject}:</label></span>\n<div class='editOptions'>\n<input tabindex='1' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br /><br />"; $editsummary = ''; } else { $commentsubject = ''; $editsummary = "<span id='wpSummaryLabel'><label for='wpSummary'>{$summary}:</label></span>\n<div class='editOptions'>\n<input tabindex='2' type='text' value=\"{$summarytext}\" name='wpSummary' id='wpSummary' maxlength='200' size='60' /><br />"; } # Set focus to the edit box on load, except on preview or diff, where it would interfere with the display if (!$this->preview && !$this->diff) { // WERELATE - removed -- nothing can be in the onload handler because it might mess up JQuery // $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' ); } $templates = $this->formatTemplates(); global $wgUseMetadataEdit; if ($wgUseMetadataEdit) { $metadata = $this->mMetaData; $metadata = htmlspecialchars($wgContLang->recodeForEdit($metadata)); $top = wfMsgWikiHtml('metadata_help'); $metadata = $top . "<textarea name='metadata' rows='3' cols='{$cols}'{$ew}>{$metadata}</textarea>"; } else { $metadata = ""; } $hidden = ''; $recreate = ''; if ($this->deletedSinceEdit) { if ('save' != $this->formtype) { $wgOut->addWikiText(wfMsg('deletedwhileediting')); } else { // Hide the toolbar and edit area, use can click preview to get it back // Add an confirmation checkbox and explanation. $toolbar = ''; $hidden = 'type="hidden" style="display:none;"'; $recreate = $wgOut->parse(wfMsg('confirmrecreate', $this->lastDelete->user_name, $this->lastDelete->log_comment)); $recreate .= "<br /><input tabindex='1' type='checkbox' value='1' name='wpRecreate' id='wpRecreate' />" . "<label for='wpRecreate' title='" . wfMsg('tooltip-recreate') . "'>" . wfMsg('recreate') . "</label>"; } } // WERELATE - add script to protect leaving edited page $wgOut->addScript(<<<END <script type="text/javascript"> //<![CDATA[ var needConfirm=(window.location.href.indexOf('&action=submit') > 0); \$(document).ready(function() { \$("#editform :input").change(function(){ needConfirm=true; })}); window.onbeforeunload = function() { if (needConfirm) return "If you leave, any edits will be lost."; }; //]]> </script> END ); $temp = array('id' => 'wpSave', 'name' => 'wpSave', 'type' => 'submit', 'tabindex' => '5', 'value' => wfMsg('savearticle'), 'accesskey' => wfMsg('accesskey-save'), 'title' => wfMsg('tooltip-save'), 'onClick' => 'needConfirm=false'); $buttons['save'] = wfElement('input', $temp, ''); $temp = array('id' => 'wpDiff', 'name' => 'wpDiff', 'type' => 'submit', 'tabindex' => '7', 'value' => wfMsg('showdiff'), 'accesskey' => wfMsg('accesskey-diff'), 'title' => wfMsg('tooltip-diff'), 'onClick' => 'needConfirm=false'); $buttons['diff'] = wfElement('input', $temp, ''); global $wgLivePreview; if ($wgLivePreview && $wgUser->getOption('uselivepreview')) { $temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => '', 'title' => wfMsg('tooltip-preview'), 'style' => 'display: none;', 'onClick' => 'needConfirm=false'); $buttons['preview'] = wfElement('input', $temp, ''); $temp = array('id' => 'wpLivePreview', 'name' => 'wpLivePreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showlivepreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => '', 'onclick' => $this->doLivePreviewScript() . '; needConfirm=false'); $buttons['live'] = wfElement('input', $temp, ''); } else { $temp = array('id' => 'wpPreview', 'name' => 'wpPreview', 'type' => 'submit', 'tabindex' => '6', 'value' => wfMsg('showpreview'), 'accesskey' => wfMsg('accesskey-preview'), 'title' => wfMsg('tooltip-preview'), 'onClick' => 'needConfirm=false'); $buttons['preview'] = wfElement('input', $temp, ''); $buttons['live'] = ''; } $safemodehtml = $this->checkUnicodeCompliantBrowser() ? "" : "<input type='hidden' name=\"safemode\" value='1' />\n"; // WERELATE - moved toolbar from here to below $wgOut->addHTML(<<<END <form id="editform" name="editform" method="post" action="{$action}" enctype="multipart/form-data"> END ); if (is_callable($formCallback)) { call_user_func_array($formCallback, array(&$wgOut)); } // Put these up at the top to ensure they aren't lost on early form submission // WERELATE - add cmt $wgOut->addHTML("\n<input type='hidden' value=\"" . htmlspecialchars($this->section) . "\" name=\"wpSection\" />\n<input type='hidden' value=\"" . htmlspecialchars($this->cmt) . "\" name=\"wpCmt\" />\n<input type='hidden' value=\"{$this->starttime}\" name=\"wpStarttime\" />\n\n<input type='hidden' value=\"{$this->edittime}\" name=\"wpEdittime\" />\n\n<input type='hidden' value=\"{$this->scrolltop}\" name=\"wpScrolltop\" id=\"wpScrolltop\" />\n"); // WERELATE - added wfRunHooks, moved {$toolbar} from above, added treecheckboxeshtml require_once "extensions/familytree/FamilyTreeUtil.php"; $treecheckboxeshtml = FamilyTreeUtil::generateTreeCheckboxes($wgUser, $this->mTitle, true); wfRunHooks('ArticleEditShow', array(&$this)); $wgOut->addHTML(<<<END {$recreate} {$commentsubject} {$toolbar} <textarea tabindex='1' accesskey="," name="wpTextbox1" id="wpTextbox1" rows='{$rows}' cols='{$cols}'{$ew} {$hidden}> END . htmlspecialchars($this->safeUnicodeOutput($this->textbox1)) . "\n</textarea>\n\t\t"); $wgOut->addWikiText($copywarn); $wgOut->addHTML("\n{$metadata}\n{$editsummary}\n{$checkboxhtml}\n{$treecheckboxeshtml}\n{$safemodehtml}\n"); $wgOut->addHTML("<div class='editButtons'>\n\t{$buttons['save']}\n\t{$buttons['preview']}\n\t{$buttons['live']}\n\t{$buttons['diff']}\n\t<span class='editHelp'>{$cancel} | {$edithelp}</span>\n</div><!-- editButtons -->\n</div><!-- editOptions -->"); $wgOut->addWikiText(wfMsgForContent('edittools')); $wgOut->addHTML("\n<div class='templatesUsed'>\n{$templates}\n</div>\n"); if ($wgUser->isLoggedIn()) { /** * To make it harder for someone to slip a user a page * which submits an edit form to the wiki without their * knowledge, a random token is associated with the login * session. If it's not passed back with the submission, * we won't save the page, or render user JavaScript and * CSS previews. */ $token = htmlspecialchars($wgUser->editToken()); $wgOut->addHTML("\n<input type='hidden' value=\"{$token}\" name=\"wpEditToken\" />\n"); } # If a blank edit summary was previously provided, and the appropriate # user preference is active, pass a hidden tag here. This will stop the # user being bounced back more than once in the event that a summary # is not required. if ($this->missingSummary) { $wgOut->addHTML("<input type=\"hidden\" name=\"wpIgnoreBlankSummary\" value=\"1\" />\n"); } # For a bit more sophisticated detection of blank summaries, hash the # automatic one and pass that in a hidden field. $autosumm = $this->autoSumm ? $this->autoSumm : md5($this->summary); $wgOut->addHtml(wfHidden('wpAutoSummary', $autosumm)); if ($this->isConflict) { require_once "DifferenceEngine.php"; $wgOut->addWikiText('==' . wfMsg("yourdiff") . '=='); $de = new DifferenceEngine($this->mTitle); $de->setText($this->textbox2, $this->textbox1); $de->showDiff(wfMsg("yourtext"), wfMsg("storedversion")); $wgOut->addWikiText('==' . wfMsg("yourtext") . '=='); $wgOut->addHTML("<textarea tabindex=6 id='wpTextbox2' name=\"wpTextbox2\" rows='{$rows}' cols='{$cols}' wrap='virtual'>" . htmlspecialchars($this->safeUnicodeOutput($this->textbox2)) . "\n</textarea>"); } $wgOut->addHTML("</form>\n"); if (!$wgUser->getOption('previewontop')) { if ($this->formtype == 'preview') { $this->showPreview(); } else { $wgOut->addHTML('<div id="wikiPreview"></div>'); } if ($this->formtype == 'diff') { $wgOut->addHTML($this->getDiff()); } } wfProfileOut($fname); }
/** * 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 deleteFamilyTree($db, $userName, $treeName, $delPages) { global $wgUser; if ($wgUser->isBlocked() || wfReadOnly()) { return FTE_NOT_AUTHORIZED; } $status = FTE_SUCCESS; $treeId = $db->selectField('familytree', 'ft_tree_id', array('ft_user' => $userName, 'ft_name' => $treeName)); $errno = $db->lastErrno(); if ($errno > 0) { $status = FTE_DB_ERROR; } else { if ($treeId === false) { $status = FTE_NOT_FOUND; } else { // set up delete job (the delete job should also remove familytree_page/data/gedcom eventually) $job = new DeleteFamilyTreeJob(array('tree_id' => $treeId, 'user' => $userName, 'delete_pages' => $delPages ? '1' : '0')); $job->insert(); $errno = $db->lastErrno(); if ($errno > 0) { $status = FTE_DB_ERROR; } } } if ($status == FTE_SUCCESS) { // remove familytree $db->delete('familytree', array('ft_tree_id' => $treeId)); FamilyTreeUtil::deleteFamilyTreesCache($userName); $errno = $db->lastErrno(); if ($errno > 0) { $status = FTE_DB_ERROR; } } // purge user page StructuredData::purgeTitle(Title::makeTitle(NS_USER, $userName)); return $status; }
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; }