Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F7404426
Opts.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
Opts.php
View Options
<?php
declare
(
strict_types
=
1
);
namespace
Wikimedia\Parsoid\Ext\Gallery
;
use
Wikimedia\Parsoid\Core\Sanitizer
;
use
Wikimedia\Parsoid\Ext\ParsoidExtensionAPI
;
use
Wikimedia\Parsoid\Ext\Utils
;
class
Opts
{
/**
* Parse options from an attribute array.
* @param ParsoidExtensionAPI $extApi
* @param array<string,string> $attrs The attribute array
*/
public
function
__construct
(
ParsoidExtensionAPI
$extApi
,
array
$attrs
)
{
$siteConfig
=
$extApi
->
getSiteConfig
();
// Set default values from config
// The options 'showDimensions' and 'showBytes' for traditional mode are not implemented,
// They are not used for galleries in wikitext (only on category pages or special pages)
// The deprecated option 'captionLength' for traditional mode is not implemented.
$galleryOptions
=
$siteConfig
->
galleryOptions
();
$this
->
imagesPerRow
=
$galleryOptions
[
'imagesPerRow'
];
$this
->
imageWidth
=
$galleryOptions
[
'imageWidth'
];
$this
->
imageHeight
=
$galleryOptions
[
'imageHeight'
];
$this
->
mode
=
$galleryOptions
[
'mode'
];
// Override values from given attributes
if
(
is_numeric
(
$attrs
[
'perrow'
]
??
null
)
)
{
$this
->
imagesPerRow
=
intval
(
$attrs
[
'perrow'
],
10
);
}
$maybeDim
=
Utils
::
parseMediaDimensions
(
$siteConfig
,
$attrs
[
'widths'
]
??
''
,
true
,
false
);
if
(
$maybeDim
&&
Utils
::
validateMediaParam
(
$maybeDim
[
'x'
]
)
)
{
$this
->
imageWidth
=
$maybeDim
[
'x'
];
}
$maybeDim
=
Utils
::
parseMediaDimensions
(
$siteConfig
,
$attrs
[
'heights'
]
??
''
,
true
,
false
);
if
(
$maybeDim
&&
Utils
::
validateMediaParam
(
$maybeDim
[
'x'
]
)
)
{
$this
->
imageHeight
=
$maybeDim
[
'x'
];
}
$mode
=
strtolower
(
$attrs
[
'mode'
]
??
''
);
if
(
Mode
::
byName
(
$mode
)
!==
null
)
{
$this
->
mode
=
$mode
;
}
$this
->
showfilename
=
isset
(
$attrs
[
'showfilename'
]
);
$this
->
showthumbnails
=
isset
(
$attrs
[
'showthumbnails'
]
);
$this
->
caption
=
(
bool
)(
$attrs
[
'caption'
]
??
false
);
// TODO: Good contender for T54941
$validUlAttrs
=
Sanitizer
::
attributesAllowedInternal
(
'ul'
);
$this
->
attrs
=
[];
foreach
(
$attrs
as
$k
=>
$v
)
{
if
(
!
isset
(
$validUlAttrs
[
$k
]
)
)
{
continue
;
}
if
(
$k
===
'style'
)
{
$v
=
Sanitizer
::
checkCss
(
$v
);
}
$this
->
attrs
[
$k
]
=
$v
;
}
}
/** @var array<string,string> */
public
$attrs
;
/** @var int */
public
$imagesPerRow
;
/** @var int */
public
$imageWidth
;
/** @var int */
public
$imageHeight
;
/** @var string */
public
$mode
;
/** @var bool */
public
$showfilename
;
/** @var bool */
public
$showthumbnails
;
/** @var bool */
public
$caption
;
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Nov 21, 19:10 (1 d, 1 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b9/f9/2eee77fecbeaf3c54240d832fe22
Default Alt Text
Opts.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment