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


PHP MWNamespace::getNamespaceContentModel方法代码示例

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


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

示例1: register

 function register()
 {
     global $wgContLang, $wgNamespaceAliases, $wgDisableCounters;
     $lib = array('getNsIndex' => array($this, 'getNsIndex'), 'pagesInCategory' => array($this, 'pagesInCategory'), 'pagesInNamespace' => array($this, 'pagesInNamespace'), 'usersInGroup' => array($this, 'usersInGroup'), 'interwikiMap' => array($this, 'interwikiMap'));
     $info = array('siteName' => $GLOBALS['wgSitename'], 'server' => $GLOBALS['wgServer'], 'scriptPath' => $GLOBALS['wgScriptPath'], 'stylePath' => $GLOBALS['wgStylePath'], 'currentVersion' => SpecialVersion::getVersion());
     if (!self::$namespacesCache || self::$namespacesCacheLang !== $wgContLang->getCode()) {
         $namespaces = array();
         $namespacesByName = array();
         foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
             $canonical = MWNamespace::getCanonicalName($ns);
             $namespaces[$ns] = array('id' => $ns, 'name' => $title, 'canonicalName' => strtr($canonical, '_', ' '), 'hasSubpages' => MWNamespace::hasSubpages($ns), 'hasGenderDistinction' => MWNamespace::hasGenderDistinction($ns), 'isCapitalized' => MWNamespace::isCapitalized($ns), 'isContent' => MWNamespace::isContent($ns), 'isIncludable' => !MWNamespace::isNonincludable($ns), 'isMovable' => MWNamespace::isMovable($ns), 'isSubject' => MWNamespace::isSubject($ns), 'isTalk' => MWNamespace::isTalk($ns), 'defaultContentModel' => MWNamespace::getNamespaceContentModel($ns), 'aliases' => array());
             if ($ns >= NS_MAIN) {
                 $namespaces[$ns]['subject'] = MWNamespace::getSubject($ns);
                 $namespaces[$ns]['talk'] = MWNamespace::getTalk($ns);
                 $namespaces[$ns]['associated'] = MWNamespace::getAssociated($ns);
             } else {
                 $namespaces[$ns]['subject'] = $ns;
             }
             $namespacesByName[strtr($title, ' ', '_')] = $ns;
             if ($canonical) {
                 $namespacesByName[$canonical] = $ns;
             }
         }
         $aliases = array_merge($wgNamespaceAliases, $wgContLang->getNamespaceAliases());
         foreach ($aliases as $title => $ns) {
             if (!isset($namespacesByName[$title]) && isset($namespaces[$ns])) {
                 $ct = count($namespaces[$ns]['aliases']);
                 $namespaces[$ns]['aliases'][$ct + 1] = $title;
                 $namespacesByName[$title] = $ns;
             }
         }
         $namespaces[NS_MAIN]['displayName'] = wfMessage('blanknamespace')->inContentLanguage()->text();
         self::$namespacesCache = $namespaces;
         self::$namespacesCacheLang = $wgContLang->getCode();
     }
     $info['namespaces'] = self::$namespacesCache;
     $info['stats'] = array('pages' => (int) SiteStats::pages(), 'articles' => (int) SiteStats::articles(), 'files' => (int) SiteStats::images(), 'edits' => (int) SiteStats::edits(), 'views' => $wgDisableCounters ? null : (int) SiteStats::views(), 'users' => (int) SiteStats::users(), 'activeUsers' => (int) SiteStats::activeUsers(), 'admins' => (int) SiteStats::numberingroup('sysop'));
     return $this->getEngine()->registerInterface('mw.site.lua', $lib, $info);
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:39,代码来源:SiteLibrary.php

示例2: getDefaultModelFor

 /**
  * Returns the name of the default content model to be used for the page
  * with the given title.
  *
  * Note: There should rarely be need to call this method directly.
  * To determine the actual content model for a given page, use
  * Title::getContentModel().
  *
  * Which model is to be used by default for the page is determined based
  * on several factors:
  * - The global setting $wgNamespaceContentModels specifies a content model
  *   per namespace.
  * - The hook ContentHandlerDefaultModelFor may be used to override the page's default
  *   model.
  * - Pages in NS_MEDIAWIKI and NS_USER default to the CSS or JavaScript
  *   model if they end in .js or .css, respectively.
  * - Pages in NS_MEDIAWIKI default to the wikitext model otherwise.
  * - The hook TitleIsCssOrJsPage may be used to force a page to use the CSS
  *   or JavaScript model. This is a compatibility feature. The ContentHandlerDefaultModelFor
  *   hook should be used instead if possible.
  * - The hook TitleIsWikitextPage may be used to force a page to use the
  *   wikitext model. This is a compatibility feature. The ContentHandlerDefaultModelFor
  *   hook should be used instead if possible.
  *
  * If none of the above applies, the wikitext model is used.
  *
  * Note: this is used by, and may thus not use, Title::getContentModel()
  *
  * @since 1.21
  *
  * @param Title $title
  *
  * @return string Default model name for the page given by $title
  */
 public static function getDefaultModelFor(Title $title)
 {
     // NOTE: this method must not rely on $title->getContentModel() directly or indirectly,
     //       because it is used to initialize the mContentModel member.
     $ns = $title->getNamespace();
     $ext = false;
     $m = null;
     $model = MWNamespace::getNamespaceContentModel($ns);
     // Hook can determine default model
     if (!wfRunHooks('ContentHandlerDefaultModelFor', array($title, &$model))) {
         if (!is_null($model)) {
             return $model;
         }
     }
     // Could this page contain custom CSS or JavaScript, based on the title?
     $isCssOrJsPage = NS_MEDIAWIKI == $ns && preg_match('!\\.(css|js)$!u', $title->getText(), $m);
     if ($isCssOrJsPage) {
         $ext = $m[1];
     }
     // Hook can force JS/CSS
     wfRunHooks('TitleIsCssOrJsPage', array($title, &$isCssOrJsPage));
     // Is this a .css subpage of a user page?
     $isJsCssSubpage = NS_USER == $ns && !$isCssOrJsPage && preg_match("/\\/.*\\.(js|css)\$/", $title->getText(), $m);
     if ($isJsCssSubpage) {
         $ext = $m[1];
     }
     // Is this wikitext, according to $wgNamespaceContentModels or the DefaultModelFor hook?
     $isWikitext = is_null($model) || $model == CONTENT_MODEL_WIKITEXT;
     $isWikitext = $isWikitext && !$isCssOrJsPage && !$isJsCssSubpage;
     // Hook can override $isWikitext
     wfRunHooks('TitleIsWikitextPage', array($title, &$isWikitext));
     if (!$isWikitext) {
         switch ($ext) {
             case 'js':
                 return CONTENT_MODEL_JAVASCRIPT;
             case 'css':
                 return CONTENT_MODEL_CSS;
             default:
                 return is_null($model) ? CONTENT_MODEL_TEXT : $model;
         }
     }
     // We established that it must be wikitext
     return CONTENT_MODEL_WIKITEXT;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:78,代码来源:ContentHandler.php

示例3: appendNamespaces

 protected function appendNamespaces($property)
 {
     global $wgContLang;
     $data = array();
     foreach ($wgContLang->getFormattedNamespaces() as $ns => $title) {
         $data[$ns] = array('id' => intval($ns), 'case' => MWNamespace::isCapitalized($ns) ? 'first-letter' : 'case-sensitive');
         ApiResult::setContent($data[$ns], $title);
         $canonical = MWNamespace::getCanonicalName($ns);
         if (MWNamespace::hasSubpages($ns)) {
             $data[$ns]['subpages'] = '';
         }
         if ($canonical) {
             $data[$ns]['canonical'] = strtr($canonical, '_', ' ');
         }
         if (MWNamespace::isContent($ns)) {
             $data[$ns]['content'] = '';
         }
         if (MWNamespace::isNonincludable($ns)) {
             $data[$ns]['nonincludable'] = '';
         }
         $contentmodel = MWNamespace::getNamespaceContentModel($ns);
         if ($contentmodel) {
             $data[$ns]['defaultcontentmodel'] = $contentmodel;
         }
     }
     $this->getResult()->setIndexedTagName($data, 'ns');
     return $this->getResult()->addValue('query', $property, $data);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:28,代码来源:ApiQuerySiteinfo.php


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