MobileFrontend
Mobile optimised frontend for MediaWiki
Loading...
Searching...
No Matches
MobileFrontend\Transforms\MakeSectionsTransform Class Reference

Implements IMobileTransform, that splits the body of the document into sections demarcated by the $headings elements. More...

+ Inheritance diagram for MobileFrontend\Transforms\MakeSectionsTransform:
+ Collaboration diagram for MobileFrontend\Transforms\MakeSectionsTransform:

Public Member Functions

 __construct (array $topHeadingTags, bool $scriptsEnabled)
 
 getFirstHeading (DOMElement $doc)
 Retrieves the tag name of the first heading element (e.g., h1, h2, etc.) inside the .mw-parser-output container.
 
 apply (DOMElement $doc)
 Performs html transformation that splits the body of the document into sections demarcated by the $headings elements.
 

Static Public Member Functions

static interimTogglingSupport ()
 Make it possible to open sections while JavaScript is still loading.
 

Public Attributes

const STYLE_COLLAPSIBLE_SECTION_CLASS = 'collapsible-block'
 Class name for collapsible section wrappers.
 

Detailed Description

Implements IMobileTransform, that 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).

See also
IMobileTransform

Constructor & Destructor Documentation

◆ __construct()

MobileFrontend\Transforms\MakeSectionsTransform::__construct ( array $topHeadingTags,
bool $scriptsEnabled )
Parameters
array$topHeadingTagslist of tags could ne cosidered as sections
bool$scriptsEnabledwheather scripts are enabled

Member Function Documentation

◆ apply()

MobileFrontend\Transforms\MakeSectionsTransform::apply ( DOMElement $doc)

Performs html transformation that 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.

Parameters
DOMElement$dochtml document

Implements MobileFrontend\Transforms\IMobileTransform.

◆ getFirstHeading()

MobileFrontend\Transforms\MakeSectionsTransform::getFirstHeading ( DOMElement $doc)

Retrieves the tag name of the first heading element (e.g., h1, h2, etc.) inside the .mw-parser-output container.

If no headings are found, returns an empty string.

Note: The function loops over all top-level sibling elements inside .mw-parser-output until it finds the first heading element. This approach is considered acceptable because:

  1. It breaks immediately upon finding the first heading, so performance is not significantly impacted.
  2. Practical HTML article structures are unlikely to contain a large number of elements without headings.
Parameters
DOMElement$doc
Returns
string

◆ interimTogglingSupport()

static MobileFrontend\Transforms\MakeSectionsTransform::interimTogglingSupport ( )
static

Make it possible to open sections while JavaScript is still loading.

Returns
string The JavaScript code to add event handlers to the skin

The documentation for this class was generated from the following file: