Converts HTML into a mobile-friendly version.
More...
|
| __construct ( $html, Title $title, Config $config, MobileContext $context) |
|
| disableScripts () |
| Disables the generation of script tags in output HTML.
|
|
| enableExpandableSections ( $flag=true) |
| Set support of page for expandable sections to $flag (standard: true)
|
|
| setIsMainPage ( $value=true) |
| Change mainPage (is this the main page) to $value (standard: true) This enables special casing for the main page.
|
|
| filterContent ( $removeDefaults=true, $unused=false, $removeImages=false, $showFirstParagraphBeforeInfobox=false) |
| Performs various transformations to the content to make it appropriate for mobile devices.
|
|
| disableLegacyTransforms (bool $disable) |
| Disable any legacy transforms.
|
|
| getText ( $element=null) |
| Performs final transformations to mobile format and returns resulting HTML.
|
|
|
const | STYLE_COLLAPSIBLE_SECTION_CLASS = 'collapsible-block' |
| Class name for collapsible section wrappers.
|
|
| $topHeadingTags = [] |
|
const | SHOW_FIRST_PARAGRAPH_BEFORE_INFOBOX = 'showFirstParagraphBeforeInfobox' |
| Name of the transformation option.
|
|
|
| makeSections (DOMDocument $doc, array $headings, array $transformOptions) |
| Splits the body of the document into sections demarcated by the $headings elements.
|
|
| makeHeadingsEditable (array $headings) |
| Marks the headings as editable by adding the in-block class to each of them, if it hasn't already been added.
|
|
|
| $lazyTransform |
|
| $title |
|
| $expandableSections = false |
|
| $mainPage = false |
|
Converts HTML into a mobile-friendly version.
◆ __construct()
MobileFormatter::__construct |
( |
|
$html, |
|
|
Title |
$title, |
|
|
Config |
$config, |
|
|
MobileContext |
$context |
|
) |
| |
- Parameters
-
string | $html | Text to process |
Title | $title | Title to which $html belongs |
Config | $config | |
MobileContext | $context | |
◆ canApply()
static MobileFormatter::canApply |
( |
|
$text, |
|
|
|
$options |
|
) |
| |
|
static |
Check whether the MobileFormatter can be applied to the text of a page.
- Parameters
-
string | $text | |
array | $options | with 'maxHeadings' and 'maxImages' keys that limit the MobileFormatter to pages with less than or equal to that number of headings and images. |
- Returns
- bool
◆ disableLegacyTransforms()
MobileFormatter::disableLegacyTransforms |
( |
bool |
$disable | ) |
|
Disable any legacy transforms.
- Parameters
-
bool | $disable | whether legacy transforms should be disabled. |
◆ enableExpandableSections()
MobileFormatter::enableExpandableSections |
( |
|
$flag = true | ) |
|
Set support of page for expandable sections to $flag (standard: true)
- Todo:
- kill with fire when there will be minimum of pre-1.1 app users remaining
- Parameters
-
bool | $flag | should expandable sections be supported? |
◆ filterContent()
MobileFormatter::filterContent |
( |
|
$removeDefaults = true , |
|
|
|
$unused = false , |
|
|
|
$removeImages = false , |
|
|
|
$showFirstParagraphBeforeInfobox = false |
|
) |
| |
Performs various transformations to the content to make it appropriate for mobile devices.
- Parameters
-
bool | $removeDefaults | Whether default settings at $wgMFRemovableClasses should be used |
bool | $unused | kept for backwards compatibility - previously used for lazy loaded references |
bool | $removeImages | Whether to move images into noscript tags |
bool | $showFirstParagraphBeforeInfobox | Whether the first paragraph from the lead section should be shown before all infoboxes that come earlier. |
- Returns
- array
◆ getText()
MobileFormatter::getText |
( |
|
$element = null | ) |
|
Performs final transformations to mobile format and returns resulting HTML.
- Parameters
-
DOMElement | string | null | $element | ID of element to get HTML from or false to get it from the whole tree |
- Returns
- string Processed HTML
@phan-suppress-next-line PhanTypeMismatchArgument DOMNode vs. DOMElement
◆ makeHeadingsEditable()
MobileFormatter::makeHeadingsEditable |
( |
array |
$headings | ) |
|
|
protected |
Marks the headings as editable by adding the in-block
class to each of them, if it hasn't already been added.
FIXME: in-block
isn't semantic in that it isn't obviously connected to being editable.
- Parameters
-
DOMElement[] | $headings | Heading elements |
◆ makeSections()
MobileFormatter::makeSections |
( |
DOMDocument |
$doc, |
|
|
array |
$headings, |
|
|
array |
$transformOptions |
|
) |
| |
|
protected |
Splits the body of the document into sections demarcated by the $headings elements.
Also moves the first paragraph in the lead section above the infobox.
All member elements of the sections are added to a
so that the section bodies are clearly defined (to be "expandable" for example).
- Parameters
-
DOMDocument | $doc | representing the HTML of the current article. In the HTML the sections should not be wrapped. |
DOMElement[] | $headings | The headings returned by { |
- See also
- MobileFormatter::getHeadings}
- Parameters
-
array | $transformOptions | Options to pass when transforming content per section |
@phan-suppress-next-line PhanTypeMismatchArgument DOMNode vs. DOMElement
◆ newFromContext()
Creates and returns a MobileFormatter.
- Parameters
-
MobileContext | $context | in which the page is being rendered. Needed to access page title and MobileFrontend configuration. |
IContentProvider | $provider | |
bool | $enableSections | whether to wrap the content of sections |
Config | $config | |
- Returns
- self
◆ setIsMainPage()
MobileFormatter::setIsMainPage |
( |
|
$value = true | ) |
|
Change mainPage (is this the main page) to $value (standard: true) This enables special casing for the main page.
- Deprecated:
- Parameters
-
The documentation for this class was generated from the following file:
- includes/MobileFormatter.php