aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--RELEASE-NOTES-1.355
-rw-r--r--autoload.php1
-rw-r--r--docs/hooks.txt5
-rw-r--r--includes/HookContainer/DeprecatedHooks.php1
-rw-r--r--includes/HookContainer/HookRunner.php8
-rw-r--r--includes/skins/BaseTemplate.php4
-rw-r--r--includes/skins/Hook/BaseTemplateAfterPortletHook.php2
-rw-r--r--includes/skins/Hook/SkinAfterPortletHook.php24
-rw-r--r--includes/skins/Skin.php18
9 files changed, 67 insertions, 1 deletions
diff --git a/RELEASE-NOTES-1.35 b/RELEASE-NOTES-1.35
index 22d91864f84a..70242167fb74 100644
--- a/RELEASE-NOTES-1.35
+++ b/RELEASE-NOTES-1.35
@@ -1173,6 +1173,11 @@ because of Phabricator reports.
Use the new UserGroupManager service instead.
* wfWaitForSlaves() has been hard deprecated. Use LBFactory::waitForReplication
instead. It was soft deprecated in 1.27.
+* BaseTemplate::getAfterPortlet and ::renderAfterPortlet have been deprecated in
+ favor of the Skin::getAfterPortlet method. Skin::getAfterPortlet does not wrap
+ the result in a div, callers are responsible for that.
+ The hook BaseTemplateAfterPortlet, called by both methods has been deprecated
+ as well and is replaced by SkinAfterPortlet.
* …
=== Other changes in 1.35 ===
diff --git a/autoload.php b/autoload.php
index bfaf6ac0e079..b353e418226a 100644
--- a/autoload.php
+++ b/autoload.php
@@ -1104,6 +1104,7 @@ $wgAutoloadLocalClasses = [
'MediaWiki\\Mail\\IEmailer' => __DIR__ . '/includes/mail/IEmailer.php',
'MediaWiki\\ProcOpenError' => __DIR__ . '/includes/exception/ProcOpenError.php',
'MediaWiki\\ShellDisabledError' => __DIR__ . '/includes/exception/ShellDisabledError.php',
+ 'MediaWiki\\Skins\\Hook\\SkinAfterPortletHook' => __DIR__ . '/includes/skins/Hook/SkinAfterPortletHook.php',
'MediaWiki\\Special\\SpecialPageFactory' => __DIR__ . '/includes/specialpage/SpecialPageFactory.php',
'MediaWiki\\Storage\\IncompleteRevisionException' => __DIR__ . '/includes/Revision/IncompleteRevisionException.php',
'MediaWiki\\Storage\\MutableRevisionRecord' => __DIR__ . '/includes/Revision/MutableRevisionRecord.php',
diff --git a/docs/hooks.txt b/docs/hooks.txt
index 0e0040876498..861bcf7a0849 100644
--- a/docs/hooks.txt
+++ b/docs/hooks.txt
@@ -3094,6 +3094,11 @@ the text you're going to add.
&$data: (string) Text to be printed out directly (without parsing)
$skin: Skin object
+'SkinAfterPortlet': Allows injecting custom HTML after the portlet.
+$skin: Skin object
+$portlet: string portlet name
+&$html: string
+
'SkinBuildSidebar': At the end of Skin::buildSidebar().
$skin: Skin object
&$bar: Sidebar contents
diff --git a/includes/HookContainer/DeprecatedHooks.php b/includes/HookContainer/DeprecatedHooks.php
index d25e7c22aa86..95aab0778d67 100644
--- a/includes/HookContainer/DeprecatedHooks.php
+++ b/includes/HookContainer/DeprecatedHooks.php
@@ -44,6 +44,7 @@ class DeprecatedHooks {
'ArticleEditUpdatesDeleteFromRecentchanges' => [ 'deprecatedVersion' => '1.35' ],
'ArticleRevisionUndeleted' => [ 'deprecatedVersion' => '1.35' ],
'ArticleRollbackComplete' => [ 'deprecatedVersion' => '1.35' ],
+ 'BaseTemplateAfterPortlet' => [ 'deprecatedVersion' => '1.35', 'silent' => true ],
'BeforeParserrenderImageGallery' => [ 'deprecatedVersion' => '1.35' ],
'InternalParseBeforeSanitize' => [ 'deprecatedVersion' => '1.35' ],
'LinkBegin' => [ 'deprecatedVersion' => '1.28' ],
diff --git a/includes/HookContainer/HookRunner.php b/includes/HookContainer/HookRunner.php
index 5f869db31725..6ed86cc9133c 100644
--- a/includes/HookContainer/HookRunner.php
+++ b/includes/HookContainer/HookRunner.php
@@ -506,6 +506,7 @@ class HookRunner implements
\MediaWiki\Session\Hook\SessionMetadataHook,
\MediaWiki\Session\Hook\UserSetCookiesHook,
\MediaWiki\Shell\Hook\WfShellWikiCmdHook,
+ \MediaWiki\Skins\Hook\SkinAfterPortletHook,
\MediaWiki\SpecialPage\Hook\AuthChangeFormFieldsHook,
\MediaWiki\SpecialPage\Hook\ChangeAuthenticationDataAuditHook,
\MediaWiki\SpecialPage\Hook\ChangesListSpecialPageQueryHook,
@@ -3466,6 +3467,13 @@ class HookRunner implements
);
}
+ public function onSkinAfterPortlet( $skin, $portlet, &$html ) {
+ return $this->container->run(
+ 'SkinAfterPortlet',
+ [ $skin, $portlet, &$html ]
+ );
+ }
+
public function onSkinBuildSidebar( $skin, &$bar ) {
return $this->container->run(
'SkinBuildSidebar',
diff --git a/includes/skins/BaseTemplate.php b/includes/skins/BaseTemplate.php
index 0c45ed4c3f10..17067c0121a4 100644
--- a/includes/skins/BaseTemplate.php
+++ b/includes/skins/BaseTemplate.php
@@ -206,6 +206,7 @@ abstract class BaseTemplate extends QuickTemplate {
}
/**
+ * @deprecated since 1.35 use Skin::getAfterPortlet directly
* @param string $name
*/
protected function renderAfterPortlet( $name ) {
@@ -215,6 +216,8 @@ abstract class BaseTemplate extends QuickTemplate {
/**
* Allows extensions to hook into known portlets and add stuff to them
*
+ * @deprecated since 1.35 use Skin::getAfterPortlet directly
+ *
* @param string $name
*
* @return string html
@@ -224,6 +227,7 @@ abstract class BaseTemplate extends QuickTemplate {
$html = '';
$content = '';
$this->getHookRunner()->onBaseTemplateAfterPortlet( $this, $name, $content );
+ $content .= $this->getSkin()->getAfterPortlet( $name );
if ( $content !== '' ) {
$html = Html::rawElement(
diff --git a/includes/skins/Hook/BaseTemplateAfterPortletHook.php b/includes/skins/Hook/BaseTemplateAfterPortletHook.php
index 260a8c8becdf..cc3a9d642384 100644
--- a/includes/skins/Hook/BaseTemplateAfterPortletHook.php
+++ b/includes/skins/Hook/BaseTemplateAfterPortletHook.php
@@ -5,7 +5,7 @@ namespace MediaWiki\Hook;
use BaseTemplate;
/**
- * @stable for implementation
+ * @deprecated since 1.35 Use SkinAfterPortlet instead
* @ingroup Hooks
*/
interface BaseTemplateAfterPortletHook {
diff --git a/includes/skins/Hook/SkinAfterPortletHook.php b/includes/skins/Hook/SkinAfterPortletHook.php
new file mode 100644
index 000000000000..03554aa4069c
--- /dev/null
+++ b/includes/skins/Hook/SkinAfterPortletHook.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace MediaWiki\Skins\Hook;
+
+use Skin;
+
+/**
+ * @stable for implementation
+ * @ingroup Hooks
+ */
+interface SkinAfterPortletHook {
+ /**
+ * This hook is called when generating portlets.
+ * It allows injecting custom HTML after the portlet.
+ *
+ * @since 1.35
+ *
+ * @param Skin $skin
+ * @param string $portlet
+ * @param string &$html
+ * @return bool|void True or no return value to continue or false to abort
+ */
+ public function onSkinAfterPortlet( $skin, $portlet, &$html );
+}
diff --git a/includes/skins/Skin.php b/includes/skins/Skin.php
index 8ab97da606ef..9e0753a1605c 100644
--- a/includes/skins/Skin.php
+++ b/includes/skins/Skin.php
@@ -2423,4 +2423,22 @@ abstract class Skin extends ContextSource {
throw new MWException( 'Unknown mode passed to BaseTemplate::makeSearchButton' );
}
}
+
+ /**
+ * Allows extensions to hook into known portlets and add stuff to them.
+ * Unlike its BaseTemplate counterpart, this method does not wrap the html
+ * provided by the hook in a div.
+ *
+ * @param string $name
+ *
+ * @return string html
+ * @since 1.35
+ */
+ public function getAfterPortlet( string $name ) : string {
+ $html = '';
+
+ $this->getHookRunner()->onSkinAfterPortlet( $this, $name, $html );
+
+ return $html;
+ }
}