function wfGetWatchers($args) { $args = AjaxUtil::getArgs($args); $title = Title::newFromText($args['title']); $offset = isset($args['offset']) ? (int) $args['offset'] : false; $limit = isset($args['limit']) ? (int) $args['limit'] : false; $watchers = StructuredData::getWatchers($title, $offset, $limit); return join('', $watchers); }
function wfBrowse($args) { global $wgAjaxCachePolicy, $wgUser, $wgContLang; // set cache policy $wgAjaxCachePolicy->setPolicy(0); // init vars $status = FTE_SUCCESS; $args = AjaxUtil::getArgs($args); $ns = @$args['ns']; $nsText = $wgContLang->getNsText($ns); $scope = @$args['scope']; $titleString = @$args['title']; $titleKey = @$args['title']; $dir = @$args['dir']; $prev = ''; $next = ''; $result = ''; // validate input arguments if ($scope != 'all' && !$wgUser->isLoggedIn()) { $status = FTE_NOT_LOGGED_IN; } if ($status == FTE_SUCCESS) { if ($titleString) { $title = Title::newFromText($titleString, $ns); if ($title) { $ns = $title->getNamespace(); $nsText = $title->getNsText(); $titleString = $title->getText(); $titleKey = $title->getDBkey(); } } // issue query $status = ftBrowseResults($scope, $ns, $titleKey, $dir, $cnt, $result); // if paging up and not enough results, start over from the beginning if ($status == FTE_SUCCESS && $dir == -1 && $cnt < 10) { $dir = 1; $titleKey = ''; $titleString = ''; $status = ftBrowseResults($scope, $ns, $titleKey, $dir, $cnt, $result); } } if ($status == FTE_SUCCESS) { if ($dir == -1) { if ($cnt == 11) { $prev = '1'; } $next = '1'; } else { if ($titleKey) { $prev = '1'; } if ($cnt == 11) { $next = '1'; } } } // return $titleString = StructuredData::escapeXml($titleString); return "<browse status=\"{$status}\" ns=\"{$ns}\" nsText=\"{$nsText}\" title=\"{$titleString}\" dir=\"{$dir}\" prev=\"{$prev}\" next=\"{$next}\">{$result}</browse>"; }
function wfAddGedcomSourceMatches($args) { global $wgUser, $wgAjaxCachePolicy, $wrBotUserID; // set cache policy $wgAjaxCachePolicy->setPolicy(0); $status = GE_SUCCESS; if (!$wgUser->isLoggedIn()) { $status = GE_NOT_LOGGED_IN; } else { if (wfReadOnly() || $wgUser->getID() != $wrBotUserID) { $status = GE_NOT_AUTHORIZED; } } $args = AjaxUtil::getArgs($args); if ($status == GE_SUCCESS) { $dbw =& wfGetDB(DB_MASTER); $dbw->ignoreErrors(true); $dbw->begin(); if ($args['author'] && $args['title']) { $stat = fgAddGedcomSourceMatch($dbw, $args['userID'], $args['author'] . $args['title'], 'AT', $args['pageTitle']); if ($stat != GE_SUCCESS) { $status = $stat; } } if ($args['author'] && $args['abbrev']) { $stat = fgAddGedcomSourceMatch($dbw, $args['userID'], $args['author'] . $args['abbrev'], 'AA', $args['pageTitle']); if ($stat != GE_SUCCESS) { $status = $stat; } } if ($args['title']) { $stat = fgAddGedcomSourceMatch($dbw, $args['userID'], $args['title'], 'T', $args['pageTitle']); if ($stat != GE_SUCCESS) { $status = $stat; } } if ($args['abbrev']) { $stat = fgAddGedcomSourceMatch($dbw, $args['userID'], $args['abbrev'], 'A', $args['pageTitle']); if ($stat != GE_SUCCESS) { $status = $stat; } } if ($status != GE_SUCCESS) { $dbw->rollback(); } else { $dbw->commit(); } } // return status return "<addGedcomSourceMatches status=\"{$status}\"/>"; }