Pwirth has uploaded a new change for review.

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

Change subject: TopMenuBarCustomizer: Added anchor ids to output + 
fixes/improvements
......................................................................

TopMenuBarCustomizer: Added anchor ids to output + fixes/improvements

* Added anchorID property + setter to view
* Fixed "wiki" navigation site id
* Added this return to each setter in view
* Fixed white-space wrap for child items
* Did some cc
=> needs merge to REL1_23!

PatchSet2
* Fixed typo in commit messge
* Uses Sanitizer to escape id

PatchSet3
* Also added anchorID to child items

PatchSet 4
* Used id escaping in the correct position

Change-Id: I99ed9e79242636cadce46550847bb62f1c82b501
(cherry picked from commit 8e5e7e31d097a740d457185d2358a3c28b5ed5d8)
---
M TopMenuBarCustomizer/TopMenuBarCustomizer.class.php
M TopMenuBarCustomizer/resources/bluespice.TopMenuBarCustomizer.css
M TopMenuBarCustomizer/views/view.TopMenuItem.php
3 files changed, 77 insertions(+), 21 deletions(-)


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

diff --git a/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php 
b/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php
index b2d8281..ddea9b7 100644
--- a/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php
+++ b/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php
@@ -126,7 +126,7 @@
                $oMainPage = Title::newMainPage();
 
                self::$aNavigationSites[] = array(
-                       'id' => 'wiki',
+                       'id' => 'nt-wiki',
                        'href' => $oMainPage->getFullURL(),
                        'text' => $wgSitename,
                        'active' => $oCurrentTitle->equals( $oMainPage ),
@@ -204,13 +204,16 @@
                foreach( self::getNavigationSites() as $aApp ) {
                        $aApp = array_merge(self::$aNavigationSiteTemplate, 
$aApp);
                        $oMainItem = new ViewTopMenuItem();
-                       $oMainItem->setLevel( $aApp['level'] );
-                       $oMainItem->setName( $aApp['id'] );
-                       $oMainItem->setLink( $aApp['href'] );
-                       $oMainItem->setDisplaytitle( $aApp['text'] );
-                       $oMainItem->setActive( $aApp['active'] );
-                       $oMainItem->setContainsActive( $aApp['containsactive'] 
);
-                       $oMainItem->setExternal( $aApp['external'] );
+                       $oMainItem
+                               ->setName( $aApp['id'] )
+                               ->setLink( $aApp['href'] )
+                               ->setLevel( $aApp['level'] )
+                               ->setActive( $aApp['active'] )
+                               ->setExternal( $aApp['external'] )
+                               ->setAnchorID( $aApp['id'] )
+                               ->setDisplaytitle( $aApp['text'] )
+                               ->setContainsActive( $aApp['containsactive'] )
+                       ;
                        if( !empty($aApp['children']) ) {
                                $oMainItem->setChildren( $aApp['children'] );
                        }
@@ -238,4 +241,4 @@
                        $this->getCacheKey( 'NavigationSitesData' )
                );
        }
-}
\ No newline at end of file
+}
diff --git a/TopMenuBarCustomizer/resources/bluespice.TopMenuBarCustomizer.css 
b/TopMenuBarCustomizer/resources/bluespice.TopMenuBarCustomizer.css
index b10b7a2..f301117 100644
--- a/TopMenuBarCustomizer/resources/bluespice.TopMenuBarCustomizer.css
+++ b/TopMenuBarCustomizer/resources/bluespice.TopMenuBarCustomizer.css
@@ -33,3 +33,6 @@
 .bs-apps-child a:hover{
        background: none;
 }
+.bs-apps-child a{
+       white-space: nowrap;
+}
\ No newline at end of file
diff --git a/TopMenuBarCustomizer/views/view.TopMenuItem.php 
b/TopMenuBarCustomizer/views/view.TopMenuItem.php
index 2e2417d..c5236e1 100644
--- a/TopMenuBarCustomizer/views/view.TopMenuItem.php
+++ b/TopMenuBarCustomizer/views/view.TopMenuItem.php
@@ -26,6 +26,11 @@
         */
        protected $iLevel = 1;
        /**
+        * Item AnchorID
+        * @var string
+        */
+       protected $sAnchorID = '';
+       /**
         * Name of the item
         * @var string
         */
@@ -71,65 +76,91 @@
        /**
         * Sets the level property
         * @param integer $iLevel
+        * @return ViewTopMenuItem
         */
        public function setLevel( $iLevel ) {
                $this->iLevel = $iLevel;
+               return $this;
+       }
+
+       /**
+        * Sets the sAnchorID property
+        * @param string sAnchorID
+        * @return ViewTopMenuItem
+        */
+       public function setAnchorID( $sAnchorID ) {
+               $this->sAnchorID = $sAnchorID;
+               return $this;
        }
 
        /**
         * Sets the name property
         * @param string $sName
+        * @return ViewTopMenuItem
         */
        public function setName( $sName ) {
                $this->sName = $sName;
+               return $this;
        }
 
        /**
         * Sets the display title property
         * @param string $sDisplayTitle
+        * @return ViewTopMenuItem
         */
        public function setDisplaytitle( $sDisplayTitle ) {
                $this->sDisplayTitle = $sDisplayTitle;
+               return $this;
        }
 
        /**
         * Sets the Link property
         * @param string $sLink
+        * @return ViewTopMenuItem
         */
        public function setLink( $sLink ) {
                $this->sLink = $sLink;
+               return $this;
        }
 
        /**
         * Sets the active property
         * @param boolean $bActive
+        * @return ViewTopMenuItem
         */
        public function setActive( $bActive ) {
                $this->bActive = $bActive;
+               return $this;
        }
 
        /**
         * Sets the contains active property
         * @param boolean $bContainsActive
+        * @return ViewTopMenuItem
         */
        public function setContainsActive( $bContainsActive ) {
                $this->bContainsActive = $bContainsActive;
+               return $this;
        }
 
        /**
         * Sets the external property
         * @param boolean $bExternal
+        * @return ViewTopMenuItem
         */
        public function setExternal( $bExternal ) {
                $this->bExternal = $bExternal;
+               return $this;
        }
 
        /**
         * Sets the children property
         * @param boolean $aChildren
+        * @return ViewTopMenuItem
         */
        public function setChildren( $aChildren ) {
                $this->aChildren = $aChildren;
+               return $this;
        }
 
        /**
@@ -140,26 +171,39 @@
        public function execute( $aParams = false ) {
                $aClasses = array();
 
-               $aClasses[] = empty($this->aChildren) ? 'menu-item-single' : 
'menu-item-container';
+               $aClasses[] = empty( $this->aChildren )
+                       ? 'menu-item-single'
+                       : 'menu-item-container'
+               ;
                $aClasses[] = "level-$this->iLevel";
                if( $this->bContainsActive) $aClasses[] = 'contains-active';
                if( $this->bActive) $aClasses[] = 'active';
+               $sClasses = 'class="'.implode(' ', $aClasses).'"';
 
-               $sTitle = $sText = empty($this->sDisplayTitle) ? $this->sName : 
$this->sDisplayTitle;
+               $sTitle = $sText = empty( $this->sDisplayTitle )
+                       ? $this->sName
+                       : $this->sDisplayTitle
+               ;
                if( wfMessage($sTitle)->exists() ) {
                        $sTitle = $sText = wfMessage($sTitle)->plain();
+               }
+               $sAnchorID = $this->sAnchorID;
+               if( !empty($sAnchorID) ) {
+                       $sAnchorID = "id='".Sanitizer::escapeId($sAnchorID)."'";
                }
 
                global $wgExternalLinkTarget;
 
                $sLinkTarget = '';
                if( $this->bExternal && !empty($wgExternalLinkTarget) ) {
-                       $sLinkTarget = 'target="'.$wgExternalLinkTarget.'"';
+                       $sLinkTarget = "target='$wgExternalLinkTarget'";
                }
 
                $sOut = '';
                $sOut .= '<li>';
-               $sOut .= "<a href='$this->sLink' class='".implode(' ', 
$aClasses)."' $sLinkTarget>$sText</a>";
+               $sOut .= "<a href='$this->sLink' $sAnchorID $sClasses 
$sLinkTarget>";
+               $sOut .= $sText;
+               $sOut .= "</a>";
                if( !empty($this->aChildren) ) {
                        $sOut .= $this->rederChildItems();
                }
@@ -171,16 +215,22 @@
                $aOut[] ='<ul class="bs-apps-child 
level-'.($this->iLevel+1).'">';
 
                foreach( $this->aChildren as $aApp ) {
-                       $aApp = 
array_merge(TopMenuBarCustomizer::$aNavigationSiteTemplate, $aApp);
+                       $aApp = array_merge(
+                               TopMenuBarCustomizer::$aNavigationSiteTemplate,
+                               $aApp
+                       );
 
                        $oItem = new ViewTopMenuItem();
-                       $oItem->setLevel( $aApp['level'] );
-                       $oItem->setName( $aApp['id'] );
-                       $oItem->setLink( $aApp['href'] );
-                       $oItem->setActive( $aApp['active'] );
-                       $oItem->setExternal( $aApp['external'] );
-                       $oItem->setDisplaytitle( $aApp['text'] );
-                       $oItem->setContainsActive( $aApp['containsactive'] );
+                       $oItem
+                               ->setName( $aApp['id'] )
+                               ->setLink( $aApp['href'] )
+                               ->setLevel( $aApp['level'] )
+                               ->setActive( $aApp['active'] )
+                               ->setExternal( $aApp['external'] )
+                               ->setAnchorID( $aApp['id'] )
+                               ->setDisplaytitle( $aApp['text'] )
+                               ->setContainsActive( $aApp['containsactive'] )
+                       ;
                        if( !empty($aApp['children']) ) {
                                $oItem->setChildren( $aApp['children'] );
                        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I99ed9e79242636cadce46550847bb62f1c82b501
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions
Gerrit-Branch: REL1_23
Gerrit-Owner: Pwirth <wi...@hallowelt.biz>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to