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


PHP Title类代码示例

本文整理汇总了PHP中Title的典型用法代码示例。如果您正苦于以下问题:PHP Title类的具体用法?PHP Title怎么用?PHP Title使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Title类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: invalidateBasePages

	/**
	 * Invalidate the base pages for this title, so that any SubPageList
	 * there gets refreshed after doing a subpage delete, move or creation.
	 * 
	 * @since 0.3
	 * 
	 * @param Title $title
	 */
	protected static function invalidateBasePages( Title $title ) {
		global $egSPLAutorefresh;
		
		if ( !$egSPLAutorefresh ) {
			return;
		}
		
		$slashPosition = strpos( $title->getDBkey(), '/' );

		if ( $slashPosition !== false ) {
			$baseTitleText = substr( $title->getDBkey(), 0, $slashPosition );
			
			$titleArray = self::getBaseSubPages(
				$baseTitleText,
				$title->getNamespace()
			);
			
			foreach ( $titleArray as $parentTitle ) {
				// No point in invalidating the page itself
				if ( $parentTitle->getArticleID() != $title->getArticleID() ) {
					$parentTitle->invalidateCache();
				}
			}
			
			$baseTitle = Title::newFromText( $baseTitleText, $title->getNamespace() );
			if ( $baseTitle->getArticleID() != $title->getArticleID() ) {
				$baseTitle->invalidateCache();
			}					
		}
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:38,代码来源:SubPageList.hooks.php

示例3: newFromTitle

	/**
	 * @param $title Title
	 * @param $repo ForeignApiRepo
	 * @return ForeignAPIFile|null
	 */
	static function newFromTitle( Title $title, $repo ) {
		$data = $repo->fetchImageQuery( array(
			'titles' => 'File:' . $title->getDBkey(),
			'iiprop' => self::getProps(),
			'prop' => 'imageinfo',
			'iimetadataversion' => MediaHandler::getMetadataVersion()
		) );

		$info = $repo->getImageInfo( $data );

		if ( $info ) {
			$lastRedirect = isset( $data['query']['redirects'] )
				? count( $data['query']['redirects'] ) - 1
				: -1;
			if ( $lastRedirect >= 0 ) {
				$newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to'] );
				$img = new self( $newtitle, $repo, $info, true );
				if ( $img ) {
					$img->redirectedFrom( $title->getDBkey() );
				}
			} else {
				$img = new self( $title, $repo, $info, true );
			}
			return $img;
		} else {
			return null;
		}
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:33,代码来源:ForeignAPIFile.php

示例4: 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

示例5: isItemFixed

 /**
  * Checks if a given article has been fixed by a user
  * inside a productivity loop.
  * @param Title $title
  * @return bool
  */
 public function isItemFixed(Title $title)
 {
     if ($title->getArticleID() !== 0) {
         return $this->removeFixedItem(ucfirst(self::INSIGHT_TYPE), $title);
     }
     return false;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:13,代码来源:InsightsWantedpagesModel.php

示例6: 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

示例7: siblings

	/**
	 * @param Title $title
	 * @return array of SisterSiteLink
	 */
	function siblings( $title ) {
		$normal = self::normalize( $title->getPrefixedText() );
		$dbr = wfGetDB( DB_SLAVE );
		$result = $dbr->select(
			array( 'sistersites_page', 'sistersites_site' ),
			array(
				'ssp_url',
				'ssp_title',
				'sss_name',
				'sss_interwiki',
			),
			array(
				'ssp_normalized_title' => $normal,
				'ssp_site=sss_id',
			),
			__METHOD__ );
		
		$out = array();
		while( $row = $dbr->fetchObject( $result ) ) {
			$out[] = new SisterSitesLink( $row );
		}
		
		$dbr->freeResult( $result );
		return $out;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:29,代码来源:SisterSites.php

示例8: fileCacheName

 public function fileCacheName()
 {
     if (!$this->mFileCache) {
         global $wgCacheDirectory, $wgFileCacheDirectory, $wgFileCacheDepth;
         if ($wgFileCacheDirectory) {
             $dir = $wgFileCacheDirectory;
         } elseif ($wgCacheDirectory) {
             $dir = "{$wgCacheDirectory}/html";
         } else {
             throw new MWException('Please set $wgCacheDirectory in LocalSettings.php if you wish to use the HTML file cache');
         }
         # Store raw pages (like CSS hits) elsewhere
         $subdir = $this->mType === 'raw' ? 'raw/' : '';
         $key = $this->mTitle->getPrefixedDbkey();
         if ($wgFileCacheDepth > 0) {
             $hash = md5($key);
             for ($i = 1; $i <= $wgFileCacheDepth; $i++) {
                 $subdir .= substr($hash, 0, $i) . '/';
             }
         }
         # Avoid extension confusion
         $key = str_replace('.', '%2E', urlencode($key));
         $this->mFileCache = "{$dir}/{$subdir}{$key}.html";
         if ($this->useGzip()) {
             $this->mFileCache .= '.gz';
         }
         wfDebug(__METHOD__ . ": {$this->mFileCache}\n");
     }
     return $this->mFileCache;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:30,代码来源:HTMLFileCache.php

示例9: 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

示例10: onCodeEditorGetPageLanguage

 /**
  * Declares JSON as the code editor language for Schema: pages.
  * This hook only runs if the CodeEditor extension is enabled.
  * @param Title $title
  * @param string &$lang: Page language.
  * @return bool
  */
 static function onCodeEditorGetPageLanguage($title, &$lang)
 {
     if ($title->getNamespace() === NS_SCHEMA) {
         $lang = 'json';
     }
     return true;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:14,代码来源:JsonSchemaHooks.php

示例11: watchTitle

 private function watchTitle(Title $title, User $user, array $params, $compatibilityMode = false)
 {
     if (!$title->isWatchable()) {
         return array('title' => $title->getPrefixedText(), 'watchable' => 0);
     }
     $res = array('title' => $title->getPrefixedText());
     if ($params['unwatch']) {
         $status = UnwatchAction::doUnwatch($title, $user);
         $res['unwatched'] = $status->isOK();
         if ($status->isOK()) {
             $res['message'] = $this->msg('removedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         }
     } else {
         $status = WatchAction::doWatch($title, $user);
         $res['watched'] = $status->isOK();
         if ($status->isOK()) {
             $res['message'] = $this->msg('addedwatchtext', $title->getPrefixedText())->title($title)->parseAsBlock();
         }
     }
     if (!$status->isOK()) {
         if ($compatibilityMode) {
             $this->dieStatus($status);
         }
         $res['error'] = $this->getErrorFromStatus($status);
     }
     return $res;
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:27,代码来源:ApiWatch.php

示例12: makeRedirectContent

 /**
  * Create a redirect that is also valid JavaScript
  *
  * @param Title $destination
  * @param string $text ignored
  * @return JavaScriptContent
  */
 public function makeRedirectContent(Title $destination, $text = '')
 {
     // The parameters are passed as a string so the / is not url-encoded by wfArrayToCgi
     $url = $destination->getFullURL('action=raw&ctype=text/javascript', false, PROTO_RELATIVE);
     $class = $this->getContentClass();
     return new $class('/* #REDIRECT */' . Xml::encodeJsCall('mw.loader.load', [$url]));
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:14,代码来源:JavaScriptContentHandler.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: getExhibitionItems

 public function getExhibitionItems(Title $title)
 {
     wfProfileIn(__METHOD__);
     if (class_exists('CategoryDataService')) {
         $cacheKey = $this->getExhibitionItemsCacheKey($title->getText());
         $items = $this->wg->memc->get($cacheKey);
         if (!is_array($items)) {
             $exh = CategoryDataService::getMostVisited($title->getDBkey(), null, self::EXHIBITION_ITEMS_LIMIT);
             $ids = array_keys($exh);
             $length = count($ids);
             $items = array();
             for ($i = 0; $i < $length; $i++) {
                 $pageId = $ids[$i];
                 $imgRespnse = $this->app->sendRequest('ImageServing', 'index', array('ids' => array($pageId), 'height' => 150, 'width' => 150, 'count' => 1));
                 $img = $imgRespnse->getVal('result');
                 if (!empty($img[$pageId])) {
                     $img = $img[$pageId][0]['url'];
                 } else {
                     $img = false;
                 }
                 $oTitle = Title::newFromID($pageId);
                 $items[] = ['img' => $img, 'title' => $oTitle->getText(), 'url' => $oTitle->getFullURL()];
             }
             $this->wg->memc->set($cacheKey, $items, self::CACHE_TTL_EXHIBITION);
         }
         wfProfileOut(__METHOD__);
         return $items;
     }
     wfProfileOut(__METHOD__);
     return false;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:WikiaMobileCategoryModel.class.php

示例15: makeWlhLink

 /**
  * Make a "what links here" link for a given title
  *
  * @param Title $title Title to make the link for
  * @param Skin $skin Skin to use
  * @param object $result Result row
  * @return string
  */
 private function makeWlhLink($title, $skin, $result)
 {
     global $wgLang;
     $wlh = SpecialPage::getTitleFor('Whatlinkshere');
     $label = wfMsgExt('nlinks', array('parsemag', 'escape'), $wgLang->formatNum($result->value));
     return $skin->link($wlh, $label, array(), array('target' => $title->getPrefixedText()));
 }
开发者ID:amjadtbssm,项目名称:website,代码行数:15,代码来源:SpecialWantedtemplates.php


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