50 private $namespaceContentModels;
53 private $contentHandlerFactory;
59 private $titleFactory;
69 array $namespaceContentModels,
75 $this->namespaceContentModels = $namespaceContentModels;
76 $this->contentHandlerFactory = $contentHandlerFactory;
77 $this->hookRunner =
new HookRunner( $hookContainer );
78 $this->titleFactory = $titleFactory;
93 $title = $this->titleFactory->castFromPageIdentity( $page );
94 $handler = $this->contentHandlerFactory->getContentHandler( $model );
97 return $handler->canBeUsedOn(
$title );
110 $ns = $page->getNamespace();
111 $model = $this->namespaceContentModels[$ns] ??
null;
115 $title = $this->titleFactory->castFromPageIdentity( $page );
117 $title = $this->titleFactory->castFromLinkTarget( $page );
120 if ( !$this->hookRunner->onContentHandlerDefaultModelFor(
$title, $model ) && $model !==
null ) {
125 $isCodePage = $ns ===
NS_MEDIAWIKI && preg_match(
'!\.(css|js|json)$!u',
$title->getText(), $m );
131 $isCodeSubpage = $ns ===
NS_USER
133 && preg_match(
"/\\/.*\\.(js|css|json)$/",
$title->getText(), $m );
135 if ( $isCodeSubpage ) {
141 $isWikitext = $isWikitext && !$isCodePage && !$isCodeSubpage;
143 if ( !$isWikitext ) {
const CONTENT_MODEL_WIKITEXT
const CONTENT_MODEL_JAVASCRIPT
Exception thrown when an unregistered content model is requested.
A SlotRoleHandler for the main slot.
supportsArticleCount()
Whether this slot should be considered when determining whether a page should be counted as an "artic...
__construct(array $namespaceContentModels, IContentHandlerFactory $contentHandlerFactory, HookContainer $hookContainer, TitleFactory $titleFactory)
isAllowedModel( $model, PageIdentity $page)
Interface for objects (potentially) representing an editable wiki page.
if(!is_readable( $file)) $ext