Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5973400
InRow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
InRow.php
View Options
<?php
namespace
Wikimedia\RemexHtml\TreeBuilder
;
use
Wikimedia\RemexHtml\Tokenizer\Attributes
;
/**
* The "in row" insertion mode
*/
class
InRow
extends
InsertionMode
{
private
static
$tableRowContext
=
[
'tr'
=>
true
,
'template'
=>
true
,
'html'
=>
true
,
];
public
function
characters
(
$text
,
$start
,
$length
,
$sourceStart
,
$sourceLength
)
{
$this
->
dispatcher
->
inTable
->
characters
(
$text
,
$start
,
$length
,
$sourceStart
,
$sourceLength
);
}
public
function
startTag
(
$name
,
Attributes
$attrs
,
$selfClose
,
$sourceStart
,
$sourceLength
)
{
$builder
=
$this
->
builder
;
$stack
=
$builder
->
stack
;
$dispatcher
=
$this
->
dispatcher
;
switch
(
$name
)
{
case
'th'
:
case
'td'
:
$builder
->
clearStackBack
(
self
::
$tableRowContext
,
$sourceStart
);
$builder
->
insertElement
(
$name
,
$attrs
,
false
,
$sourceStart
,
$sourceLength
);
$dispatcher
->
switchMode
(
Dispatcher
::
IN_CELL
);
$builder
->
afe
->
insertMarker
();
break
;
case
'caption'
:
case
'col'
:
case
'colgroup'
:
case
'tbody'
:
case
'tfoot'
:
case
'thead'
:
case
'tr'
:
if
(
!
$stack
->
isInTableScope
(
'tr'
)
)
{
$builder
->
error
(
"<$name> should close the tr but it is not in scope"
,
$sourceStart
);
// Ignore
return
;
}
$builder
->
clearStackBack
(
self
::
$tableRowContext
,
$sourceStart
);
$builder
->
pop
(
$sourceStart
,
0
);
$dispatcher
->
switchMode
(
Dispatcher
::
IN_TABLE_BODY
)
->
startTag
(
$name
,
$attrs
,
$selfClose
,
$sourceStart
,
$sourceLength
);
break
;
default
:
$dispatcher
->
inTable
->
startTag
(
$name
,
$attrs
,
$selfClose
,
$sourceStart
,
$sourceLength
);
}
}
public
function
endTag
(
$name
,
$sourceStart
,
$sourceLength
)
{
$builder
=
$this
->
builder
;
$stack
=
$builder
->
stack
;
$dispatcher
=
$this
->
dispatcher
;
switch
(
$name
)
{
case
'tr'
:
if
(
!
$stack
->
isInTableScope
(
'tr'
)
)
{
$builder
->
error
(
'</tr> found but no tr element in scope'
,
$sourceStart
);
// Ignore
return
;
}
$builder
->
clearStackBack
(
self
::
$tableRowContext
,
$sourceStart
);
$builder
->
pop
(
$sourceStart
,
$sourceLength
);
$dispatcher
->
switchMode
(
Dispatcher
::
IN_TABLE_BODY
);
break
;
case
'table'
:
if
(
!
$stack
->
isInTableScope
(
'tr'
)
)
{
$builder
->
error
(
"</table> should close the tr but it is not in scope"
,
$sourceStart
);
// Ignore
return
;
}
$builder
->
clearStackBack
(
self
::
$tableRowContext
,
$sourceStart
);
$builder
->
pop
(
$sourceStart
,
0
);
$dispatcher
->
switchMode
(
Dispatcher
::
IN_TABLE_BODY
)
->
endTag
(
$name
,
$sourceStart
,
$sourceLength
);
break
;
case
'tbody'
:
case
'tfoot'
:
case
'thead'
:
if
(
!
$stack
->
isInTableScope
(
$name
)
)
{
$builder
->
error
(
"</$name> encountered but there is no $name element in scope"
,
$sourceStart
);
return
;
}
if
(
!
$stack
->
isInTableScope
(
'tr'
)
)
{
return
;
}
$builder
->
clearStackBack
(
self
::
$tableRowContext
,
$sourceStart
);
$builder
->
pop
(
$sourceStart
,
0
);
$dispatcher
->
switchMode
(
Dispatcher
::
IN_TABLE_BODY
)
->
endTag
(
$name
,
$sourceStart
,
$sourceLength
);
break
;
case
'body'
:
case
'caption'
:
case
'col'
:
case
'colgroup'
:
case
'html'
:
case
'td'
:
case
'th'
:
$builder
->
error
(
"</$name> encountered in row mode, ignoring"
,
$sourceStart
);
return
;
default
:
$dispatcher
->
inTable
->
endTag
(
$name
,
$sourceStart
,
$sourceLength
);
}
}
public
function
endDocument
(
$pos
)
{
$this
->
dispatcher
->
inTable
->
endDocument
(
$pos
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 16:36 (8 h, 31 m ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
02/8a/16b8c7477c999be0395b2831861a
Default Alt Text
InRow.php (3 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment