Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5965553
BeforeHtml.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
BeforeHtml.php
View Options
<?php
namespace
Wikimedia\RemexHtml\TreeBuilder
;
use
Wikimedia\RemexHtml\Tokenizer\Attributes
;
use
Wikimedia\RemexHtml\Tokenizer\PlainAttributes
;
/**
* The "before html" insertion mode
*/
class
BeforeHtml
extends
InsertionMode
{
public
function
characters
(
$text
,
$start
,
$length
,
$sourceStart
,
$sourceLength
)
{
// Ignore whitespace
[
$part1
,
$part2
]
=
$this
->
splitInitialMatch
(
true
,
"
\t\n\f\r
"
,
$text
,
$start
,
$length
,
$sourceStart
,
$sourceLength
);
[
$start
,
$length
,
$sourceStart
,
$sourceLength
]
=
$part2
;
if
(
!
$length
)
{
return
;
}
// Generate missing <html> tag
$this
->
builder
->
insertElement
(
'html'
,
new
PlainAttributes
,
false
,
$sourceStart
,
0
);
$this
->
dispatcher
->
switchMode
(
Dispatcher
::
BEFORE_HEAD
)
->
characters
(
$text
,
$start
,
$length
,
$sourceStart
,
$sourceLength
);
}
public
function
startTag
(
$name
,
Attributes
$attrs
,
$selfClose
,
$sourceStart
,
$sourceLength
)
{
if
(
$name
===
'html'
)
{
$this
->
builder
->
insertElement
(
$name
,
$attrs
,
false
,
$sourceStart
,
$sourceLength
);
$this
->
dispatcher
->
switchMode
(
Dispatcher
::
BEFORE_HEAD
);
}
else
{
$this
->
builder
->
insertElement
(
'html'
,
new
PlainAttributes
,
false
,
$sourceStart
,
0
);
$this
->
dispatcher
->
switchMode
(
Dispatcher
::
BEFORE_HEAD
)
->
startTag
(
$name
,
$attrs
,
$selfClose
,
$sourceStart
,
$sourceLength
);
}
}
public
function
endTag
(
$name
,
$sourceStart
,
$sourceLength
)
{
$allowed
=
[
"head"
=>
true
,
"body"
=>
true
,
"html"
=>
true
,
"br"
=>
true
];
if
(
!
isset
(
$allowed
[
$name
]
)
)
{
$this
->
builder
->
error
(
'end tag not allowed before html'
,
$sourceStart
);
return
;
}
$this
->
builder
->
insertElement
(
'html'
,
new
PlainAttributes
,
false
,
$sourceStart
,
0
);
$this
->
dispatcher
->
switchMode
(
Dispatcher
::
BEFORE_HEAD
)
->
endTag
(
$name
,
$sourceStart
,
$sourceLength
);
}
public
function
endDocument
(
$pos
)
{
$this
->
builder
->
insertElement
(
'html'
,
new
PlainAttributes
,
false
,
$pos
,
0
);
$this
->
dispatcher
->
switchMode
(
Dispatcher
::
BEFORE_HEAD
)
->
endDocument
(
$pos
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 11:03 (6 d, 10 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5e/bd/ac193fd2340cf1fc127854e4b79d
Default Alt Text
BeforeHtml.php (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment