本文整理汇总了PHP中ApiMain::GetResultData方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiMain::GetResultData方法的具体用法?PHP ApiMain::GetResultData怎么用?PHP ApiMain::GetResultData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ApiMain
的用法示例。
在下文中一共展示了ApiMain::GetResultData方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
public function get($limit = 10, User $user = null)
{
wfProfileIn(__METHOD__);
global $wgUser;
if (!$user instanceof User) {
$user = $wgUser;
}
$result = array();
$params = array();
$params['action'] = 'query';
$params['list'] = 'usercontribs';
$params['ucuser'] = $user->getName();
$params['ucprop'] = 'ids|title|timestamp|flags|comment|wikiamode';
$params['uclimit'] = $limit;
$api = new ApiMain(new FauxRequest($params));
$api->execute();
$res =& $api->GetResultData();
$i = -1;
foreach ($res['query']['usercontribs'] as &$entry) {
$titleObj = Title::newFromText($entry['title']);
$result[++$i] = array('url' => $titleObj->getLocalURL(), 'title' => $titleObj->getText(), 'timestamp' => $entry['timestamp'], 'namespace' => $entry['ns'], 'type' => 'edit', 'new' => $entry['rev_parent_id'] == 0 ? '1' : '0', 'diff' => empty($entry['rev_parent_id']) ? '' : $titleObj->getLocalURL('diff=' . $entry['revid'] . '&oldid=' . $entry['rev_parent_id']));
if (MWNamespace::isTalk($entry['ns']) || in_array($entry['ns'], array(400, NS_USER, NS_TEMPLATE, NS_MEDIAWIKI))) {
$title = $titleObj->getPrefixedText();
if (defined('ARTICLECOMMENT_PREFIX') && strpos($title, '/') !== false && strpos(end(explode('/', $title)), ARTICLECOMMENT_PREFIX) === 0) {
$result[$i]['title'] = end(explode(':', reset(explode('/', $title, 2)), 2));
} else {
$result[$i]['title'] = $title;
}
}
if (defined('NS_BLOG_ARTICLE_TALK') && $entry['ns'] == NS_BLOG_ARTICLE_TALK) {
$result[$i]['title'] = wfMsg('myhome-namespace-blog') . ':' . $result[$i]['title'];
}
if ($entry['ns'] == NS_FILE) {
list(, $title) = explode(':', $entry['title'], 2);
$title = str_replace(' ', '_', $title);
$tsUnix = wfTimestamp(TS_UNIX, $entry['timestamp']);
$tsMin = wfTimestamp(TS_MW, $tsUnix - 5);
$tsMax = wfTimestamp(TS_MW, $tsUnix + 5);
//get type of file operations
$dbr = wfGetDB(DB_SLAVE);
$type = $dbr->selectField(array('logging'), array('log_type'), array('log_type' => 'upload', 'log_namespace' => $entry['ns'], 'log_title' => $title, "log_timestamp BETWEEN {$tsMin} AND {$tsMax}"), __METHOD__);
if ($type !== false) {
$result[$i]['type'] = 'upload';
$result[$i]['diff'] = '';
}
}
}
wfProfileOut(__METHOD__);
return $result;
}
示例2: get
public function get($limit, $start = null)
{
wfProfileIn(__METHOD__);
if (!empty($start)) {
$this->APIparams['wlstart'] = $start;
} else {
unset($this->APIparams['wlstart']);
}
$this->APIparams['wllimit'] = $limit;
$api = new ApiMain(new FauxRequest($this->APIparams));
$api->execute();
$res =& $api->GetResultData();
$out = array();
if (isset($res['query']) && isset($res['query']['watchlist'])) {
$out['results'] = $res['query']['watchlist'];
}
if (isset($res['query-continue'])) {
$out['query-continue'] = $res['query-continue']['watchlist']['wlstart'];
}
wfProfileOut(__METHOD__);
return $out;
}
示例3: deleteComplete
/**
* deleteComplete -- hook
*
* @static
* @access public
*
* @param WikiPage $oArticle,
* @param User $oUser,
* @param String $reason,
* @param String $articleId,
*
* @author Piotr Molski (MoLi)
* @return true
*/
public static function deleteComplete(&$oArticle, &$oUser, $reason, $articleId)
{
global $wgCityId;
wfProfileIn(__METHOD__);
$use_api = 0;
if (is_object($oArticle) && $oUser instanceof User) {
$pageId = !empty($articleId) ? $articleId : $oArticle->getID();
$logid = 0;
if ($pageId > 0) {
if ($use_api == 1) {
$oTitle = $oArticle->getTitle();
$pageName = Title::makeName($oTitle->getNamespace(), $oTitle->getDBkey());
$oFauxRequest = new FauxRequest(array('action' => 'query', 'list' => 'logevents', 'letype' => 'delete', 'letitle' => $pageName, 'lelimit' => 1));
$oApi = new ApiMain($oFauxRequest);
try {
#---
$oApi->execute();
$aResult = $oApi->GetResultData();
if (isset($aResult['query']['logevents']) && !empty($aResult['query']['logevents'])) {
list($row) = $aResult['query']['logevents'];
if (isset($row['logid'])) {
$logid = $row['logid'];
}
}
} catch (Exception $e) {
Wikia::log(__METHOD__, 'cannot fetch data from logging table via API request', $e->getMessage());
}
} else {
$table = 'recentchanges';
$oTitle = $oArticle->getTitle();
$what = array('rc_logid');
$cond = array('rc_title' => $oTitle->getDBkey(), 'rc_namespace' => $oTitle->getNamespace(), 'rc_log_action' => 'delete', 'rc_user' => $oUser->getID());
$options = array('ORDER BY' => 'rc_id DESC');
$dbr = wfGetDB(DB_MASTER);
$oRow = $dbr->selectRow($table, $what, $cond, __METHOD__, $options);
if ($oRow) {
$logid = $oRow->rc_logid;
}
}
if ($logid > 0) {
#---
$oScribeProducer = new ScribeProducer('delete', $pageId, 0, $logid, 0);
if (is_object($oScribeProducer)) {
$oScribeProducer->send_log();
}
} else {
$title = $oArticle->getTitle()->getText();
Wikia::log(__METHOD__, "error", "Cannot send log via scribe ({$wgCityId}): log id not found: {$title}");
}
} else {
$title = $oArticle->getTitle()->getText();
Wikia::log(__METHOD__, "error", "Cannot send log via scribe ({$wgCityId}): page ID is empty: {$title}");
}
} else {
$isArticle = is_object($oArticle);
$isUser = is_object($oUser);
Wikia::log(__METHOD__, "error", "Cannot send log via scribe ({$wgCityId}): invalid user: {$isUser}, invalid article: {$isArticle}");
}
wfProfileOut(__METHOD__);
return true;
}
示例4: userCanVote
public function userCanVote()
{
$pageId = $this->mTitle->getArticleId();
$oFauxRequest = new FauxRequest(array("action" => "query", "list" => "wkvoteart", "wkpage" => $pageId, "wkuservote" => 1));
$oApi = new ApiMain($oFauxRequest);
$oApi->execute();
$aResult = $oApi->GetResultData();
if (isset($aResult['query']['wkvoteart'][$pageId]['uservote'])) {
$result = false;
} else {
$result = true;
}
return $result;
}
示例5: userCanVote
/**
* Checks if the user has already casted a vote
*
* @author ADi
* @return boolean true if no vote has been recorded for the user, false otherwise
*/
public function userCanVote()
{
$pageId = $this->getArticle()->getId();
$oContext = RequestContext::newExtraneousContext(RequestContext::getMain()->getTitle(), array("action" => "query", "list" => "wkvoteart", "wkpage" => $pageId, "wkuservote" => 1));
$oContext->setUser(F::app()->wg->User);
$oApi = new ApiMain($oContext, F::app()->wg->EnableWriteAPI);
$oApi->execute();
$aResult = $oApi->GetResultData();
if (isset($aResult['query']['wkvoteart'][$pageId]['uservote'])) {
$result = false;
} else {
$result = true;
}
return $result;
}
示例6: userCanVote
public function userCanVote()
{
$pageId = $this->mTitle->getArticleId();
$oFauxRequest = new FauxRequest(['action' => 'query', 'list' => 'wkvoteart', 'wkpage' => $pageId, 'wkuservote' => 1]);
$oApi = new ApiMain($oFauxRequest);
$oApi->execute();
$aResult = $oApi->GetResultData();
if (isset($aResult['query']['wkvoteart'][$pageId]['uservote'])) {
$result = false;
} else {
$result = true;
}
return $result;
}
示例7: GetUserEventMessages
public static function GetUserEventMessages($limit = 1)
{
global $wgOut;
wfProfileIn(__METHOD__);
#$memckey = "{$wgDBname}:UserEventMessages";
#$results = $wgMemc->get( $memckey );
$oApi = new ApiMain(new FauxRequest(array("action" => "query", "list" => "wkevents", "wklimit" => $limit)));
$oApi->execute();
$aResult =& $oApi->GetResultData();
$results = array();
if (count($aResult['query']['wkevents']) > 0) {
foreach ($aResult['query']['wkevents'] as $eventType => $val) {
#--- title
if (!empty($val['title'])) {
$parseTitle = wfMsg($val['title']);
if (!empty($parseTitle)) {
$val['title'] = $wgOut->parse($parseTitle, false, true);
}
}
#--- content
if (!empty($val['content'])) {
$parseContent = wfMsg($val['content']);
if (!empty($parseContent)) {
$val['content'] = $wgOut->parse($parseContent, false, true);
}
}
$results[] = $val;
}
}
#$wgMemc->set( $memckey, $results, 300 );
wfProfileOut(__METHOD__);
return $results;
}
示例8: wfProfileIn
function _homepage_questions($key, $title, $ignore_cache = false)
{
global $wgMemc;
wfProfileIn(__METHOD__);
$mkey = wfMemcKey("HPL", $key);
$html = $ignore_cache ? "" : $wgMemc->get($mkey);
if (empty($html)) {
$req = new FauxRequest(array("action" => "query", "list" => "categorymembers", "cmtitle" => "Category:" . $title, "cmnamespace" => 0, "cmprop" => "title|timestamp", "cmsort" => "timestamp", "cmdir" => "desc", "cmlimit" => 5));
$api = new ApiMain($req);
$api->execute();
$res = $api->GetResultData();
if ($res["query"]["categorymembers"]) {
foreach ($res["query"]["categorymembers"] as $recent_q => $ignore_me) {
$page = $res["query"]["categorymembers"][$recent_q];
$url = str_replace(" ", "_", $page["title"]);
$oQuestion = new DefaultQuestion($url);
if (!is_null($oQuestion) && !$oQuestion->badWordsTest() && !$oQuestion->filterWordsTest()) {
$text = $page["title"] . "?";
$html .= "<li><a href=\"/wiki/" . htmlspecialchars($url) . "\">" . htmlspecialchars(Answer::s2q($text)) . "</a></li>";
}
}
}
$wgMemc->set($mkey, $html, self::CACHE_EXPIRE);
}
wfProfileOut(__METHOD__);
return $html;
}
示例9: __getCategory
private static function __getCategory($sPageName, $iPage)
{
wfProfileIn(__METHOD__);
$aCategories = array();
$oFauxRequest = new FauxRequest(array("action" => "query", "prop" => "categories", "titles" => $sPageName));
$oApi = new ApiMain($oFauxRequest);
$oApi->execute();
$aResult =& $oApi->GetResultData();
if (count($aResult['query']['pages']) > 0) {
if (!empty($aResult['query']['pages'][$iPage]['categories'])) {
foreach ($aResult['query']['pages'][$iPage]['categories'] as $id => $aCategory) {
$oCatTitle = Title::newFromText($aCategory['title'], $aCategory['ns']);
if ($oCatTitle instanceof Title) {
$aCategories[] = $oCatTitle->getFullURL();
}
}
}
}
# ---
wfProfileOut(__METHOD__);
return $aCategories;
}
示例10: movePage
public function movePage(PCPUserCredentials $userCredentials = NULL, $fromTitle = NULL, $toTitle = NULL, $movetalk = false, $noredirect = false)
{
if ($fromTitle == NULL || $toTitle == NULL) {
// trigger an error?
return false;
}
$this->getEditToken($userCredentials, $fromTitle);
// if movetalk is not set, do not use it
if ($movetalk) {
$this->queryMovePage = array_merge($this->queryMovePage, array('movetalk'));
}
if ($noredirect) {
$this->queryMovePage = array_merge($this->queryMovePage, array('noredirect'));
}
$__request = new FauxRequest(PCPUtil::replaceInHash($this->queryMovePage, array($fromTitle, $toTitle, $this->usedUC->editToken)));
$__api = new ApiMain($__request, true);
$__api->execute();
// $__result =& $__api->GetResultData();
// return true;
return $__api->GetResultData();
}
示例11: loginAfterCreateAccount
private function loginAfterCreateAccount()
{
wfProfileIn(__METHOD__);
$apiParams = array("action" => "login", "lgname" => $this->mUsername, "lgpassword" => $this->mPassword);
$oApi = new ApiMain(new FauxRequest($apiParams));
$oApi->execute();
$aResult =& $oApi->GetResultData();
wfProfileOut(__METHOD__);
return isset($aResult['login']['result']) && $aResult['login']['result'] == 'Success';
}