Robert Vogel has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/223799

Change subject: Moved link data attributes from BSE/ContextMenu
......................................................................

Moved link data attributes from BSE/ContextMenu

As the PDF Export depends on 'data-bs-title' we need this in the
foundation

Change-Id: I46451e94e68caaee7409d5bb40fc88fd7b9443b7
---
M BlueSpice.hooks.php
M includes/CoreHooks.php
2 files changed, 25 insertions(+), 0 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceFoundation 
refs/changes/99/223799/1

diff --git a/BlueSpice.hooks.php b/BlueSpice.hooks.php
index b22a30b..a6a621c 100644
--- a/BlueSpice.hooks.php
+++ b/BlueSpice.hooks.php
@@ -3,6 +3,7 @@
 $wgHooks['SoftwareInfo'][] = 'BsCoreHooks::onSoftwareInfo';
 $wgHooks['BeforePageDisplay'][] = 'BsCoreHooks::onBeforePageDisplay';
 $wgHooks['LinkEnd'][] = 'BsCoreHooks::onLinkEnd';
+$wgHooks['LinkerMakeMediaLinkFile'][] = 
'BsCoreHooks::onLinkerMakeMediaLinkFile';
 $wgHooks['MakeGlobalVariablesScript'][] = 
'BsCoreHooks::onMakeGlobalVariablesScript';
 $wgHooks['LoadExtensionSchemaUpdates'][] = 
'BsCoreHooks::onLoadExtensionSchemaUpdates';
 $wgHooks['ApiCheckCanExecute'][] = 'BsCoreHooks::onApiCheckCanExecute';
diff --git a/includes/CoreHooks.php b/includes/CoreHooks.php
index 1c430c4..5ca516a 100755
--- a/includes/CoreHooks.php
+++ b/includes/CoreHooks.php
@@ -359,6 +359,30 @@
                return true;
        }
 
+
+       /**
+        * Adds data attributes to media link tags
+        * THIS IS FOR FUTURE USE: The hook is available starting with MW 1.24!
+        * @param Title $title
+        * @param File $file The File object
+        * @param string $html The content of the resulting  anchor tag
+        * @param array $attribs An array of attributes that will be used in 
the resulting anchor tag
+        * @param string $ret The HTML output in case the handler returns false
+        * @return boolean Always true to keep hook running
+        */
+       public static function onLinkerMakeMediaLinkFile( $title, $file, 
&$html, &$attribs, &$ret ) {
+
+               $attribs['data-bs-title'] = $title->getPrefixedText();
+               if( $file instanceof File ) {
+                       $attribs['data-bs-filename'] = $file->getName();
+               }
+               else {
+                       $attribs['data-bs-filename'] = $title->getText();
+               }
+
+               return true;
+       }
+
        /**
         * @param User $oUser
         * @param array $aRights

-- 
To view, visit https://gerrit.wikimedia.org/r/223799
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I46451e94e68caaee7409d5bb40fc88fd7b9443b7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceFoundation
Gerrit-Branch: master
Gerrit-Owner: Robert Vogel <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to