Isarra has uploaded a new change for review.

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

Change subject: Make subpage ToC still show a name for projects without a 
displayname
......................................................................

Make subpage ToC still show a name for projects without a displayname

Bug: T149033
Change-Id: I3f2c9307b2b2050dad249a97a569b0b2a6845eb7
---
M includes/content/CollaborationHubTOC.php
1 file changed, 16 insertions(+), 16 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CollaborationKit 
refs/changes/56/318456/1

diff --git a/includes/content/CollaborationHubTOC.php 
b/includes/content/CollaborationHubTOC.php
index e4d296c..0f018f1 100644
--- a/includes/content/CollaborationHubTOC.php
+++ b/includes/content/CollaborationHubTOC.php
@@ -38,11 +38,11 @@
         * @param $colour string variable from collaborationhub content
         * @return string html
         */
-       public function renderToC( $content, $colour ) {
-               $html = Html::openElement( 'div', [ 'class' => 
'wp-toc-container' ] );
+       public function renderToC( $content ) {
+               $html = Html::openElement( 'div', [ 'class' => 
'mw-ck-toc-container' ] );
                $html .= Html::rawElement(
                        'div',
-                       [ 'class' => 'toc-label' ],
+                       [ 'class' => 'mw-ck-toc-label' ],
                        wfMessage( 'collaborationkit-hub-toc-label' 
)->inContentLanguage()->text()
                );
                $html .= Html::openElement( 'ul' );
@@ -60,11 +60,11 @@
                        $linkTarget = Title::newFromText( '#' . 
$this->getToCLinkID( $displayTitle ) );
                        $image = isset( $item['image'] ) ? $item['image'] : 
$displayTitle;
 
-                       $link = $this->renderItem( $linkTarget, $displayTitle, 
$image, $colour, 50 );
+                       $link = $this->renderItem( $linkTarget, $displayTitle, 
$image, 50 );
 
                        $html .= Html::rawElement(
                                'li',
-                               [ 'class' => 'wp-toc-item' ],
+                               [ 'class' => 'mw-ck-toc-item' ],
                                $link
                        );
                }
@@ -88,13 +88,13 @@
                $colour = $content->getThemeColour();
                $image = $content->getImage();
 
-               $html = Html::openElement( 'div', [ 'class' => 
"mw-cktheme-$colour" ] );
-               $html .= Html::openElement( 'div', [ 'class' => 
"wp-subpage-toc" ] );
+               $html = Html::openElement( 'div', [ 'class' => 
"mw-ck-theme-$colour" ] );
+               $html .= Html::openElement( 'div', [ 'class' => 
"mw-ck-subpage-toc" ] );
 
                // ToC label
                $html .= Html::rawElement(
                        'div',
-                       [ 'class' => 'toc-label' ],
+                       [ 'class' => 'mw-ck-toc-label' ],
                        Html::rawElement(
                                'span',
                                [],
@@ -103,15 +103,16 @@
                );
 
                // hubpage
-               $link = $this->renderItem( $title, $content->getDisplayName(), 
$image, $colour, 16 );
+               $name = $content->getDisplayName() == '' ? $title->getText() : 
$content->getDisplayName();
+               $link = $this->renderItem( $title, $name, $image, 16 );
                $html .= Html::rawElement(
                        'div',
-                       [ 'class' => 'toc-subpage-hub' ],
+                       [ 'class' => 'mw-ck-toc-subpage-hub' ],
                        $link
                );
 
                // Contents
-               $html .= Html::openElement( 'ul', [ 'class' => 'toc-contents' ] 
);
+               $html .= Html::openElement( 'ul', [ 'class' => 
'mw-ck-toc-contents' ] );
 
                foreach ( $content->getContent() as $item ) {
                        $itemTitle = Title::newFromText( $item['title'] );
@@ -127,7 +128,7 @@
 
                        $html .= Html::rawElement(
                                'li',
-                               [ 'class' => 'wp-toc-item' ],
+                               [ 'class' => 'mw-ck-toc-item' ],
                                $itemLink
                        );
                }
@@ -143,19 +144,18 @@
         * @param $title Title for target
         * @param $text string diplay text for title
         * @param $image string seed for makeIconOrImage
-        * @param $imageColour string colour id
         * @param $imageSize int size
         * @return string html
         */
-       protected function renderItem( Title $title, $text, $image, 
$imageColour, $imageSize ) {
+       protected function renderItem( Title $title, $text, $image, $imageSize 
) {
                $linkRenderer = 
MediaWikiServices::getInstance()->getLinkRenderer();
 
-               $icon = CollaborationKitIcon::makeIconOrImage( $image, 
$imageSize, $imageColour );
+               $icon = CollaborationKitIcon::makeIconOrImage( $image, 
$imageSize );
 
                $linkContent = new HtmlArmor( Html::rawElement(
                        'div',
                        [],
-                       $icon . Html::element( 'span', [ 'class' => 
'item-label' ], $text )
+                       $icon . Html::element( 'span', [ 'class' => 
'mw-ck-toc-item-label' ], $text )
                ) );
                return $link = $linkRenderer->makeLink( $title, $linkContent );
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3f2c9307b2b2050dad249a97a569b0b2a6845eb7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CollaborationKit
Gerrit-Branch: master
Gerrit-Owner: Isarra <[email protected]>

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

Reply via email to