Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1427007
CodeEditorHooks.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1023 B
Referenced Files
None
Subscribers
None
CodeEditorHooks.php
View Options
<?php
namespace
MediaWiki\Extension\Gadgets
;
use
MediaWiki\Extension\CodeEditor\Hooks\CodeEditorGetPageLanguageHook
;
use
MediaWiki\Title\Title
;
/**
* Hooks for optional integration with the CodeEditor extension.
*/
class
CodeEditorHooks
implements
CodeEditorGetPageLanguageHook
{
/**
* Set the CodeEditor language for GadgetDefinition pages.
*
* The CodeEditor extension sets the default syntax highlight language based
* on the content model (not page title), so while gadget definitions have ".json"
* page titles, the fact that we use a more specific subclass as content model,
* means we must explicitly opt-in to JSON syntax highlighting.
*
* @param Title $title
* @param string|null &$lang
* @param string $model
* @param string $format
* @return bool
*/
public
function
onCodeEditorGetPageLanguage
(
Title
$title
,
?
string
&
$lang
,
string
$model
,
string
$format
)
{
if
(
$title
->
hasContentModel
(
'GadgetDefinition'
)
)
{
$lang
=
'json'
;
return
false
;
}
return
true
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 14:04 (1 d, 16 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
29/c9/2c256f0fb40b1da938987c26a63c
Default Alt Text
CodeEditorHooks.php (1023 B)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment