jenkins-bot has submitted this change and it was merged. 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 --- M TopMenuBarCustomizer/TopMenuBarCustomizer.class.php M TopMenuBarCustomizer/resources/bluespice.TopMenuBarCustomizer.css M TopMenuBarCustomizer/views/view.TopMenuItem.php 3 files changed, 76 insertions(+), 20 deletions(-) Approvals: Mglaser: Looks good to me, approved jenkins-bot: Verified diff --git a/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php b/TopMenuBarCustomizer/TopMenuBarCustomizer.class.php index 63c5d32..8b9c6b5 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'] ); } 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/249383 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I99ed9e79242636cadce46550847bb62f1c82b501 Gerrit-PatchSet: 4 Gerrit-Project: mediawiki/extensions/BlueSpiceExtensions Gerrit-Branch: master Gerrit-Owner: Pwirth <wi...@hallowelt.biz> Gerrit-Reviewer: Mglaser <gla...@hallowelt.biz> Gerrit-Reviewer: Robert Vogel <vo...@hallowelt.biz> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits