当前位置: 首页>>代码示例>>PHP>>正文


PHP Title::getNamespace方法代码示例

本文整理汇总了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;
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:31,代码来源:TitleMoveComplete.php

示例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;
 }
开发者ID:yusufchang,项目名称:app,代码行数:37,代码来源:UserPagesHeaderController.class.php

示例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;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:29,代码来源:LogPage.php

示例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;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:17,代码来源:WallDisabledHooksHelper.class.php

示例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);
         }
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:18,代码来源:SearchResult.php

示例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();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:19,代码来源:SearchResult.php

示例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;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:32,代码来源:SpamBlacklist_body.php

示例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;
}
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:ForumIndexProtector.php

示例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;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:FilePageHooks.class.php

示例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");
     }
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:38,代码来源:SupportAid.php

示例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);
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:12,代码来源:ScribuntoContentHandler.php

示例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;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:17,代码来源:UserProfilePageHooks.class.php

示例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));
 }
开发者ID:yusufchang,项目名称:app,代码行数:31,代码来源:ParsoidCacheUpdateTask.class.php

示例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;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:11,代码来源:SubpageImportTitleFactory.php

示例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));
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:39,代码来源:WikiPage.php


注:本文中的Title::getNamespace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。