public function followRedirect() { $this->loadFile(); if ($this->img->isLocal()) { return parent::followRedirect(); } $from = $this->img->getRedirected(); $to = $this->img->getName(); if ($from == $to) { return false; } return Title::makeTitle(NS_FILE, $to); }
/** * Update the redirect entry for a given page * @param $id int The page_id of the redirect */ private function fixRedirect( $id ){ global $wgTitle; $wgTitle = Title::newFromID( $id ); $dbw = wfGetDB( DB_MASTER ); if ( is_null( $wgTitle ) ) { // This page doesn't exist (any more) // Delete any redirect table entry for it $dbw->delete( 'redirect', array( 'rd_from' => $id ), __METHOD__ ); return; } $article = new Article($wgTitle); $rt = $article->followRedirect(); if($rt == false || !is_object($rt)) { // $wgTitle is not a redirect // Delete any redirect table entry for it $dbw->delete( 'redirect', array( 'rd_from' => $id ), __METHOD__ ); } else { $article->updateRedirectOn($dbw,$rt); } }
/** * Get the text of a blacklist from a specified source * * @param $source A blacklist source from $wgTitleBlacklistSources * @return The content of the blacklist source as a string */ private static function getBlacklistText($source) { if (!is_array($source) || count($source) <= 0) { return ''; // Return empty string in error case } if ($source['type'] == 'message') { return wfMessage('titleblacklist')->inContentLanguage()->text(); } elseif ($source['type'] == 'localpage' && count($source) >= 2) { $title = Title::newFromText($source['src']); if (is_null($title)) { return ''; } if ($title->getNamespace() == NS_MEDIAWIKI) { $msg = wfMessage($title->getText())->inContentLanguage()->text(); if (!wfMessage('titleblacklist', $msg)->isDisabled()) { return $msg; } else { return ''; } } else { $article = new Article($title); if ($article->exists()) { $article->followRedirect(); return $article->getContent(); } } } elseif ($source['type'] == 'url' && count($source) >= 2) { return self::getHttp($source['src']); } elseif ($source['type'] == 'file' && count($source) >= 2) { if (file_exists($source['src'])) { return file_get_contents($source['src']); } else { return ''; } } return ''; }
/** * Get the text of a blacklist from a specified source * * @param $source A blacklist source from $wgTitleBlacklistSources * @return The content of the blacklist source as a string */ private static function getBlacklistText($source) { if (!is_array($source) || count($source) <= 0) { return ''; //Return empty string in error case } if ($source['type'] == TBLSRC_MSG) { return wfMsgForContent('titleblacklist'); } elseif ($source['type'] == TBLSRC_LOCALPAGE && count($source) >= 2) { $title = Title::newFromText($source['src']); if (is_null($title)) { return ''; } if ($title->getNamespace() == NS_MEDIAWIKI) { //Use wfMsgForContent() for getting messages $msg = wfMsgForContent($title->getText()); if (!wfEmptyMsg('titleblacklist', $msg)) { return $msg; } else { return ''; } } else { $article = new Article($title); if ($article->exists()) { $article->followRedirect(); return $article->getContent(); } } } elseif ($source['type'] == TBLSRC_URL && count($source) >= 2) { return self::getHttp($source['src']); } elseif ($source['type'] == TBLSRC_FILE && count($source) >= 2) { if (file_exists($source['src'])) { return file_get_contents($source['src']); } else { return ''; } } return ''; }
public function getDeletionTemplateName() { $delete_name_title = Title::makeTitle(NS_MEDIAWIKI, "DeleteTemplate"); $delete_name_article = new Article($delete_name_title); $delete_template = $delete_name_article->followRedirect(); if (is_object($delete_template)) { return $delete_template->getText(); } return false; }
public static function followPollID($pollTitle) { $pollArticle = new Article($pollTitle); $pollWikiContent = $pollArticle->getContent(); if ($pollArticle->isRedirect($pollWikiContent)) { $pollTitle = $pollArticle->followRedirect(); return PollNYHooks::followPollID($pollTitle); } else { return $pollTitle; } }
function wfAjaxCollectionGetPopupData($title) { global $wgScriptPath; $json = new Services_JSON(); $result = array(); $imagePath = "{$wgScriptPath}/extensions/Collection/images"; $t = Title::newFromText($title); if ($t && $t->isRedirect()) { $a = new Article($t, 0); $t = $a->followRedirect(); if ($t instanceof Title) { $title = $t->getPrefixedText(); } } if (CollectionSession::findArticle($title) == -1) { $result['action'] = 'add'; $result['text'] = wfMsg('coll-add_linked_article'); $result['img'] = "{$imagePath}/silk-add.png"; } else { $result['action'] = 'remove'; $result['text'] = wfMsg('coll-remove_linked_article'); $result['img'] = "{$imagePath}/silk-remove.png"; } $result['title'] = $title; $r = new AjaxResponse($json->encode($result)); $r->setContentType('application/json'); return $r; }