本文整理汇总了PHP中Title::getNamespace方法的典型用法代码示例。如果您正苦于以下问题:PHP Title::getNamespace方法的具体用法?PHP Title::getNamespace怎么用?PHP Title::getNamespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Title
的用法示例。
在下文中一共展示了Title::getNamespace方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* @since 1.9
*
* @return true
*/
public function process()
{
$applicationFactory = ApplicationFactory::getInstance();
// Delete all data for a non-enabled target NS
if (!$applicationFactory->getNamespaceExaminer()->isSemanticEnabled($this->newTitle->getNamespace()) || $this->newId == 0) {
$applicationFactory->getStore()->deleteSubject($this->oldTitle);
} else {
// Using a different approach since the hook is not triggered
// by #REDIRECT which can cause inconsistencies
// @see 2.3 / StoreUpdater
// $applicationFactory->getStore()->changeTitle(
// $this->oldTitle,
// $this->newTitle,
// $this->oldId,
// $this->newId
// );
}
$eventHandler = EventHandler::getInstance();
$dispatchContext = $eventHandler->newDispatchContext();
$dispatchContext->set('title', $this->oldTitle);
$eventHandler->getEventDispatcher()->dispatch('cached.propertyvalues.prefetcher.reset', $dispatchContext);
$dispatchContext = $eventHandler->newDispatchContext();
$dispatchContext->set('title', $this->newTitle);
$eventHandler->getEventDispatcher()->dispatch('cached.propertyvalues.prefetcher.reset', $dispatchContext);
return true;
}
示例2: getUserName
/**
* Get name of the user this page referrs to
*/
public static function getUserName(Title $title, $namespaces, $fallbackToGlobal = true)
{
wfProfileIn(__METHOD__);
global $wgUser, $wgRequest;
$userName = null;
if (in_array($title->getNamespace(), $namespaces)) {
// get "owner" of this user / user talk / blog page
$parts = explode('/', $title->getText());
} else {
if ($title->getNamespace() == NS_SPECIAL) {
if ($title->isSpecial('Following') || $title->isSpecial('Contributions')) {
$target = $wgRequest->getText('target');
if ($target != '') {
// /wiki/Special:Contributions?target=FooBar (RT #68323)
$parts = array($target);
} else {
// get user this special page referrs to
$parts = explode('/', $wgRequest->getText('title', false));
// remove special page name
array_shift($parts);
}
}
}
}
if (isset($parts[0]) && $parts[0] != '') {
//this line was usign urldecode($parts[0]) before, see RT #107278, user profile pages with '+' symbols get 'non-existing' message
$userName = str_replace('_', ' ', $parts[0]);
} elseif ($fallbackToGlobal) {
// fallback value
$userName = $wgUser->getName();
}
wfProfileOut(__METHOD__);
return $userName;
}
示例3: saveContent
/**
* @return bool|int|null
*/
protected function saveContent()
{
global $wgLogRestrictions;
$dbw = wfGetDB(DB_MASTER);
$log_id = $dbw->nextSequenceValue('logging_log_id_seq');
$this->timestamp = $now = wfTimestampNow();
$data = array('log_id' => $log_id, 'log_type' => $this->type, 'log_action' => $this->action, 'log_timestamp' => $dbw->timestamp($now), 'log_user' => $this->doer->getId(), 'log_user_text' => $this->doer->getName(), 'log_namespace' => $this->target->getNamespace(), 'log_title' => $this->target->getDBkey(), 'log_page' => $this->target->getArticleId(), 'log_comment' => $this->comment, 'log_params' => $this->params);
$dbw->insert('logging', $data, __METHOD__);
$newId = !is_null($log_id) ? $log_id : $dbw->insertId();
# And update recentchanges
if ($this->updateRecentChanges) {
$titleObj = SpecialPage::getTitleFor('Log', $this->type);
RecentChange::notifyLog($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
} elseif ($this->sendToUDP) {
# Don't send private logs to UDP
if (isset($wgLogRestrictions[$this->type]) && $wgLogRestrictions[$this->type] != '*') {
return true;
}
# Notify external application via UDP.
# We send this to IRC but do not want to add it the RC table.
$titleObj = SpecialPage::getTitleFor('Log', $this->type);
$rc = RecentChange::newLogEntry($now, $titleObj, $this->doer, $this->getRcComment(), '', $this->type, $this->action, $this->target, $this->comment, $this->params, $newId);
$rc->notifyRC2UDP();
}
return $newId;
}
示例4: onAfterEditPermissionErrors
/** @brief Allows to edit or not archived talk pages and its subpages
*
* @author Andrzej 'nAndy' Łukaszewski
*
* @param $pernErrors
* @param Title $title
*
* @return boolean true -- because it's a hook
*/
public function onAfterEditPermissionErrors($permErrors, $title, $removeArray)
{
$app = F::App();
if (empty($app->wg->EnableWallExt) && ($title->getNamespace() == NS_USER_WALL || $title->getNamespace() == NS_USER_WALL_MESSAGE || $title->getNamespace() == NS_USER_WALL_MESSAGE_GREETING)) {
$permErrors[] = array(0 => 'protectedpagetext', 1 => 'archived');
}
return true;
}
示例5: initFromTitle
/**
* Initialize from a Title and if possible initializes a corresponding
* Revision and File.
*
* @param Title $title
*/
protected function initFromTitle($title)
{
$this->mTitle = $title;
if (!is_null($this->mTitle)) {
$id = false;
wfRunHooks('SearchResultInitFromTitle', array($title, &$id));
$this->mRevision = Revision::newFromTitle($this->mTitle, $id, Revision::READ_NORMAL);
if ($this->mTitle->getNamespace() === NS_FILE) {
$this->mImage = wfFindFile($this->mTitle);
}
}
}
示例6: initFromTitle
/**
* Initialize from a Title and if possible initializes a corresponding
* Revision and File.
*
* @param Title $title
*/
protected function initFromTitle($title)
{
$this->mTitle = $title;
if (!is_null($this->mTitle)) {
$id = false;
Hooks::run('SearchResultInitFromTitle', [$title, &$id]);
$this->mRevision = Revision::newFromTitle($this->mTitle, $id, Revision::READ_NORMAL);
if ($this->mTitle->getNamespace() === NS_FILE) {
$this->mImage = wfFindFile($this->mTitle);
}
}
$this->searchEngine = MediaWikiServices::getInstance()->newSearchEngine();
}
示例7: isLocalSource
/**
* Check if the given local page title is a spam regex source.
* @param Title $title
* @return bool
*/
function isLocalSource($title)
{
global $wgDBname;
if ($title->getNamespace() == NS_MEDIAWIKI) {
$sources = array("Spam-blacklist", "Spam-whitelist");
if (in_array($title->getDBkey(), $sources)) {
return true;
}
}
$thisHttp = wfExpandUrl($title->getFullUrl('action=raw'), PROTO_HTTP);
$thisHttpRegex = '/^' . preg_quote($thisHttp, '/') . '(?:&.*)?$/';
foreach ($this->files as $fileName) {
$matches = array();
if (preg_match('/^DB: (\\w*) (.*)$/', $fileName, $matches)) {
if ($wgDBname == $matches[1]) {
if ($matches[2] == $title->getPrefixedDbKey()) {
// Local DB fetch of this page...
return true;
}
}
} elseif (preg_match($thisHttpRegex, $fileName)) {
// Raw view of this page
return true;
}
}
return false;
}
示例8: fnForumIndexProtector
function fnForumIndexProtector(Title &$title, User &$user, $action, &$result)
{
if ($user->isLoggedIn()) {
#this doesnt apply to logged in users, bail, but keep going
return true;
}
if ($action != 'edit' && $action != 'create') {
#only kill editing actions (what else can anons even do?), bail, but keep going
return true;
}
#this only applies to Forum:Index and Forum_talk:Index
#check pagename
if ($title->getText() != 'Index') {
#wrong pagename, bail, but keep going
return true;
}
$ns = $title->getNamespace();
#check namespace(s)
if ($ns == NS_FORUM || $ns == NS_FORUM_TALK) {
#bingo bango, its a match!
$result = array('protectedpagetext');
Wikia::log(__METHOD__, __LINE__, "anon trying to edit forum:index, killing request");
#bail, and stop the request
return false;
}
return true;
}
示例9: onArticleFromTitle
/**
* Determine which FilePage to show based on skin and File type (image/video)
*
* @param Title $oTitle
* @param Article $oArticle
* @return bool true
*/
public static function onArticleFromTitle(&$oTitle, &$oArticle)
{
if ($oTitle instanceof Title && $oTitle->getNamespace() == NS_FILE) {
$oArticle = WikiaFileHelper::getMediaPage($oTitle);
}
return true;
}
示例10: getSupportUrl
/**
* Target URL for a link provided by a support button/aid.
*
* @param $title Title Title object for the translation message.
* @since 2015.09
*/
public static function getSupportUrl(Title $title)
{
global $wgTranslateSupportUrl, $wgTranslateSupportUrlNamespace;
$namespace = $title->getNamespace();
// Fetch the configuration for this namespace if possible, or the default.
if (isset($wgTranslateSupportUrlNamespace[$namespace])) {
$config = $wgTranslateSupportUrlNamespace[$namespace];
} elseif ($wgTranslateSupportUrl) {
$config = $wgTranslateSupportUrl;
} else {
throw new TranslationHelperException("Support page not configured");
}
// Preprocess params
$params = array();
if (isset($config['params'])) {
foreach ($config['params'] as $key => $value) {
$params[$key] = str_replace('%MESSAGE%', $title->getPrefixedText(), $value);
}
}
// Return the URL or make one from the page
if (isset($config['url'])) {
return wfAppendQuery($config['url'], $params);
} elseif (isset($config['page'])) {
$page = Title::newFromText($config['page']);
if (!$page) {
throw new TranslationHelperException("Support page not configured properly");
}
return $page->getFullUrl($params);
} else {
throw new TranslationHelperException("Support page not configured properly");
}
}
示例11: canBeUsedOn
/**
* Only allow this content handler to be used in the Module namespace
* @param Title $title
* @return bool
*/
public function canBeUsedOn(Title $title)
{
if ($title->getNamespace() !== NS_MODULE) {
return false;
}
return parent::canBeUsedOn($title);
}
示例12: onSkinSubPageSubtitleAfterTitle
/**
* @brief remove User:: from back link
*
* @author Tomek Odrobny
*
* @param Title $title
* @param String $ptext
*
* @return Boolean
*/
public static function onSkinSubPageSubtitleAfterTitle($title, &$ptext)
{
if (!empty($title) && $title->getNamespace() == NS_USER) {
$ptext = $title->getText();
}
return true;
}
示例13: invalidateTitle
protected function invalidateTitle(\Title $title)
{
global $wgParsoidCacheServers, $wgContentNamespaces;
if (!in_array($title->getNamespace(), $wgContentNamespaces)) {
return false;
}
# First request the new version
$parsoidInfo = array();
$parsoidInfo['cacheID'] = $title->getPreviousRevisionID($title->getLatestRevID());
$parsoidInfo['changedTitle'] = $this->title->getPrefixedDBkey();
$requests = array();
foreach ($wgParsoidCacheServers as $server) {
$singleUrl = $this->getParsoidURL($title);
$requests[] = array('url' => $singleUrl, 'headers' => array('X-Parsoid: ' . json_encode($parsoidInfo), 'Cache-control: no-cache'));
$this->wikiaLog(array("action" => "invalidateTitle", "get_url" => $singleUrl));
}
$this->checkCurlResults(\CurlMultiClient::request($requests));
# And now purge the previous revision so that we make efficient use of
# the Varnish cache space without relying on LRU. Since the URL
# differs we can't use implicit refresh.
$requests = array();
foreach ($wgParsoidCacheServers as $server) {
// @TODO: this triggers a getPreviousRevisionID() query per server
$singleUrl = $this->getParsoidURL($title, true);
$requests[] = array('url' => $singleUrl);
$this->wikiaLog(array("action" => "invalidateTitle", "purge_url" => $singleUrl));
}
$options = \CurlMultiClient::getDefaultOptions();
$options[CURLOPT_CUSTOMREQUEST] = "PURGE";
return $this->checkCurlResults(\CurlMultiClient::request($requests, $options));
}
示例14: __construct
/**
* @param Title $rootPage The root page under which all pages should be
* created
*/
public function __construct(Title $rootPage)
{
if (!MWNamespace::hasSubpages($rootPage->getNamespace())) {
throw new MWException("The root page you specified, {$rootPage}, is in a " . "namespace where subpages are not allowed");
}
$this->rootPage = $rootPage;
}
示例15: doDeleteUpdates
/**
* Do some database updates after deletion
*
* @param int $id The page_id value of the page being deleted
* @param Content|null $content Optional page content to be used when determining
* the required updates. This may be needed because $this->getContent()
* may already return null when the page proper was deleted.
* @param Revision|null $revision The latest page revision
*/
public function doDeleteUpdates($id, Content $content = null, Revision $revision = null)
{
try {
$countable = $this->isCountable();
} catch (Exception $ex) {
// fallback for deleting broken pages for which we cannot load the content for
// some reason. Note that doDeleteArticleReal() already logged this problem.
$countable = false;
}
// Update site status
DeferredUpdates::addUpdate(new SiteStatsUpdate(0, 1, -(int) $countable, -1));
// Delete pagelinks, update secondary indexes, etc
$updates = $this->getDeletionUpdates($content);
foreach ($updates as $update) {
DeferredUpdates::addUpdate($update);
}
// Reparse any pages transcluding this page
LinksUpdate::queueRecursiveJobsForTable($this->mTitle, 'templatelinks');
// Reparse any pages including this image
if ($this->mTitle->getNamespace() == NS_FILE) {
LinksUpdate::queueRecursiveJobsForTable($this->mTitle, 'imagelinks');
}
// Clear caches
WikiPage::onArticleDelete($this->mTitle);
ResourceLoaderWikiModule::invalidateModuleCache($this->mTitle, $revision, null, wfWikiID());
// Reset this object and the Title object
$this->loadFromRow(false, self::READ_LATEST);
// Search engine
DeferredUpdates::addUpdate(new SearchUpdate($id, $this->mTitle));
}