-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOutputPageBodyAttributes.patch
More file actions
53 lines (49 loc) · 2.2 KB
/
Copy pathOutputPageBodyAttributes.patch
File metadata and controls
53 lines (49 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Index: docs/hooks.txt
===================================================================
--- docs/hooks.txt (revision 74133)
+++ docs/hooks.txt (working copy)
@@ -1130,6 +1130,14 @@
$parserOutput: the parserOutput (object) that corresponds to the page
$text: the text that will be displayed, in HTML (string)
+'OutputPageBodyAttributes': called when OutputPage::headElement is creating the body
+tag to allow for extensions to add attributes to the body of the page they might
+need. Or to allow building extensions to add body classes that aren't of high
+enough demand to be included in core.
+$out: The OutputPage which called the hook, can be used to get the real title
+$sk: The Skin that called OutputPage::headElement
+&$bodyAttrs: An array of attributes for the body tag passed to Html::openElement
+
'OutputPageCheckLastModified': when checking if the page has been modified
since the last visit
&$modifiedTimes: array of timestamps.
Index: includes/OutputPage.php
===================================================================
--- includes/OutputPage.php (revision 74133)
+++ includes/OutputPage.php (working copy)
@@ -2171,6 +2171,9 @@
$bodyAttrs['class'] .= ' ' . Sanitizer::escapeClass( 'page-' . $this->getTitle()->getPrefixedText() );
$bodyAttrs['class'] .= ' skin-' . Sanitizer::escapeClass( $wgUser->getSkin()->getSkinName() );
+ $sk->addToBodyAttributes( $this, $bodyAttrs ); // Allow skins to add body attributes they need
+ wfRunHooks( 'OutputPageBodyAttributes', array( $this, $sk, &$bodyAttrs ) );
+
$ret .= Html::openElement( 'body', $bodyAttrs ) . "\n";
return $ret;
Index: includes/Skin.php
===================================================================
--- includes/Skin.php (revision 74133)
+++ includes/Skin.php (working copy)
@@ -683,6 +683,15 @@
$name = Sanitizer::escapeClass( 'page-' . $title->getPrefixedText() );
return "$numeric $type $name";
}
+
+ /**
+ * This will be called by OutputPage::headElement when it is creating the
+ * <body> tag, skins can override it if they have a need to add in any
+ * body attributes or classes of their own.
+ */
+ function addToBodyAttributes( $out, &$bodyAttrs ) {
+ // does nothing by default
+ }
/**
* URL to the logo