Pwirth has uploaded a new change for review.

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

Change subject: Backported Anchor-IDs in TopMenu from commit: 249383
......................................................................

Backported Anchor-IDs in TopMenu from commit: 249383

* https://gerrit.wikimedia.org/r/#/c/249383/2

Change-Id: I5fa07c4d5f043c0bcb4f9a72e68a24db0ce92e7b
---
M TopMenuBarCustomizer/TopMenuBarCustomizer.class.php
M TopMenuBarCustomizer/views/view.TopMenuItem.php
M TopMenuBarCustomizer/views/view.TopMenuItemMain.php
3 files changed, 40 insertions(+), 2 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/BlueSpiceExtensions 
refs/changes/90/249390/1

diff --git a/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php 
b/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php
index 6d6e913..8f51d2f 100644
--- a/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php
+++ b/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php
@@ -152,6 +152,7 @@
                        $oMainItem->setActive( $aApp['active'] );
                        $oMainItem->setContainsActive( $aApp['containsactive'] 
);
                        $oMainItem->setExternal( $aApp['external'] );
+                       $oMainItem->setAnchorID( 
Sanitizer::escapeId($aApp['name']) );
                        if( !empty($aApp['children']) ) {
                                $oMainItem->setChildren( $aApp['children'] );
                        }
diff --git a/TopMenuBarCustomizer/views/view.TopMenuItem.php 
b/TopMenuBarCustomizer/views/view.TopMenuItem.php
index 0211680..b0c0231 100644
--- a/TopMenuBarCustomizer/views/view.TopMenuItem.php
+++ b/TopMenuBarCustomizer/views/view.TopMenuItem.php
@@ -31,6 +31,11 @@
         */
        protected $sName = '';
        /**
+        * AnchorID of the item
+        * @var string
+        */
+       protected $sAnchorID = '';
+       /**
         * Displayname of the item
         * @var string
         */
@@ -60,6 +65,13 @@
         * @var array
         */
        protected $aChildren = array();
+       /**
+        * Sets the AnchorID property
+        * @param string $sAnchorID
+        */
+       public function setAnchorID( $sAnchorID ) {
+               $this->sAnchorID = $sAnchorID;
+       }
 
        /**
         * Constructor
@@ -147,9 +159,14 @@
                $sLinkTarget = '';
                if( $this->bExternal && !empty($wgExternalLinkTarget) ) 
$sLinkTarget = 'target="'.$wgExternalLinkTarget.'"';
 
+               $sAnchorID = $this->sAnchorID;
+               if( !empty($sAnchorID) ) {
+                       $sAnchorID = "id='$sAnchorID'";
+               }
+
                $aOut = array();
                $aOut[] = '<li>';
-               $aOut[] =       '<a href="'.$this->sLink .'" title="'.( 
empty($this->sDisplayTitle) ? $this->sName : $this->sDisplayTitle ).'" 
class="'.$sClass.'" '.$sLinkTarget.'>'.( empty($this->sDisplayTitle) ? 
$this->sName : $this->sDisplayTitle ).'</a>';
+               $aOut[] =       '<a href="'.$this->sLink .'" '.$sAnchorID.' 
title="'.( empty($this->sDisplayTitle) ? $this->sName : $this->sDisplayTitle 
).'" class="'.$sClass.'" '.$sLinkTarget.'>'.( empty($this->sDisplayTitle) ? 
$this->sName : $this->sDisplayTitle ).'</a>';
                if( !empty($this->aChildren) ) {
                        $aOut[] = $this->rederChildItems();
                }
@@ -168,6 +185,7 @@
                        $oItem->setDisplaytitle( $aApp['displaytitle'] );
                        $oItem->setActive( $aApp['active'] );
                        $oItem->setContainsActive( $aApp['containsactive'] );
+                       $oItem->setAnchorID( Sanitizer::escapeId($aApp['name']) 
);
                        if( !empty($aApp['children']) ) {
                                $oItem->setChildren( $aApp['children'] );
                        }
diff --git a/TopMenuBarCustomizer/views/view.TopMenuItemMain.php 
b/TopMenuBarCustomizer/views/view.TopMenuItemMain.php
index 49181ac..2831647 100644
--- a/TopMenuBarCustomizer/views/view.TopMenuItemMain.php
+++ b/TopMenuBarCustomizer/views/view.TopMenuItemMain.php
@@ -31,6 +31,11 @@
         */
        protected $sName = '';
        /**
+        * AnchorID of the item
+        * @var string
+        */
+       protected $sAnchorID = '';
+       /**
         * Displayname of the item
         * @var string
         */
@@ -133,6 +138,14 @@
        }
 
        /**
+        * Sets the AnchorID property
+        * @param string $sAnchorID
+        */
+       public function setAnchorID( $sAnchorID ) {
+               $this->sAnchorID = $sAnchorID;
+       }
+
+       /**
         * This method actually generates the output
         * @param array $aParams not used here
         * @return string HTML output
@@ -147,9 +160,14 @@
                $sLinkTarget = '';
                if( $this->bExternal && !empty($wgExternalLinkTarget) ) 
$sLinkTarget = 'target="'.$wgExternalLinkTarget.'"';
 
+               $sAnchorID = $this->sAnchorID;
+               if( !empty($sAnchorID) ) {
+                       $sAnchorID = "id='$sAnchorID'";
+               }
+
                $aOut = array();
                $aOut[] = '<li>';
-               $aOut[] =       '<a href="'.$this->sLink .'" title="'.( 
empty($this->sDisplayTitle) ? $this->sName : $this->sDisplayTitle ).'" 
class="'.$sClass.'" '.$sLinkTarget.'>'.( empty($this->sDisplayTitle) ? 
$this->sName : $this->sDisplayTitle ).'</a>';
+               $aOut[] =       '<a href="'.$this->sLink .'" '.$sAnchorID.' 
title="'.( empty($this->sDisplayTitle) ? $this->sName : $this->sDisplayTitle 
).'" class="'.$sClass.'" '.$sLinkTarget.'>'.( empty($this->sDisplayTitle) ? 
$this->sName : $this->sDisplayTitle ).'</a>';
                if( !empty($this->aChildren) ) {
                        $aOut[] = $this->rederChildItems();
                }
@@ -169,6 +187,7 @@
                        $oItem->setActive( $aApp['active'] );
                        $oItem->setContainsActive( $aApp['containsactive'] );
                        $oItem->setExternal( $aApp['external'] );
+                       $oItem->setAnchorID( Sanitizer::escapeId($aApp['name']) 
);
                        if( !empty($aApp['children']) ) {
                                $oItem->setChildren( $aApp['children'] );
                        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5fa07c4d5f043c0bcb4f9a72e68a24db0ce92e7b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_22
Gerrit-Owner: Pwirth <[email protected]>

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

Reply via email to