Jdlrobson has uploaded a new change for review.

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


Change subject: Rewrite footer how skins do it
......................................................................

Rewrite footer how skins do it

This rewrites the footer in a desktop compatible way

Change-Id: I1253edfaa5af3d7782a87caf2e3ab0c9b3ae66f0
---
M includes/skins/SkinMobile.php
M includes/skins/SkinMobileBase.php
M includes/skins/SkinMobileTemplate.php
M less/common/mf-footer.less
M stylesheets/common/mf-footer.css
5 files changed, 155 insertions(+), 106 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/26/58426/1

diff --git a/includes/skins/SkinMobile.php b/includes/skins/SkinMobile.php
index 8fd29b9..379079b 100644
--- a/includes/skins/SkinMobile.php
+++ b/includes/skins/SkinMobile.php
@@ -74,9 +74,8 @@
                        } else {
                                $suffix = '';
                        }
-                       $license = Html::element( 'img', array(
+                       $sitename = Html::element( 'img', array(
                                'src' => $wgMFCustomLogos['copyright'],
-                               'class' => 'license',
                                'alt' => "{$footerSitename}" . $suffix
                        ) );
                } else {
@@ -85,11 +84,11 @@
                        } else {
                                $suffix = '';
                        }
-                       $license = Html::element( 'span', array( 'class' => 
'license' ),
+                       $sitename = Html::element( 'span', array(),
                                "{$footerSitename}" . $suffix
                        );
                }
-               $tpl->set( 'license', $license );
+               $tpl->set( 'sitename', $sitename );
 
                // @todo: kill me with fire
                if ( version_compare( $wgVersion, '1.20alpha', '<' ) ) {
@@ -138,9 +137,9 @@
                $tpl->set( 'historyLink', $historyLink );
                $tpl->set( 'nearbyURL', $nearbyUrl );
                $tpl->set( 'settingsUrl', $settingsUrl );
-               $tpl->set( 'disclaimerLink', $this->disclaimerLink() );
-               $tpl->set( 'privacyLink', $this->footerLink( 
'mobile-frontend-privacy-link-text', 'privacypage' ) );
-               $tpl->set( 'aboutLink', $this->footerLink( 
'mobile-frontend-about-link-text', 'aboutpage' ) );
+               $tpl->set( 'disclaimer', $this->disclaimerLink() );
+               $tpl->set( 'privacy', $this->footerLink( 
'mobile-frontend-privacy-link-text', 'privacypage' ) );
+               $tpl->set( 'about', $this->footerLink( 
'mobile-frontend-about-link-text', 'aboutpage' ) );
                $tpl->set( 'logInOut', $this->getLogInOutLink() );
        }
 
diff --git a/includes/skins/SkinMobileBase.php 
b/includes/skins/SkinMobileBase.php
index 0f3d084..3b20578 100644
--- a/includes/skins/SkinMobileBase.php
+++ b/includes/skins/SkinMobileBase.php
@@ -101,6 +101,9 @@
         */
        protected function prepareTemplate() {
                wfProfileIn( __METHOD__ );
+               $title = $this->getTitle();
+               $ctx = MobileContext::singleton();
+               $req = $this->getRequest();
                $lang = $this->getLanguage();
 
                $tpl = $this->setupTemplate( $this->template );
@@ -114,7 +117,34 @@
                        $hookQuery = $this->hookOptions['toggle_view_desktop'];
                        $url = $this->getRequest()->appendQuery( $hookQuery ) . 
urlencode( $url );
                }
-               $tpl->set( 'viewNormalSiteURL', $url );
+
+               $desktop = wfMessage( 'mobile-frontend-view-desktop' );
+               $mobile = wfMessage( 'mobile-frontend-view-mobile' );
+
+               $switcherHtml = <<<HTML
+<span class="left separator"><a id="mw-mf-display-toggle" 
href="{$url}">{$desktop}
+</a></span><span class="right">{$mobile}</span>
+HTML;
+
+               // urls that do not vary on authentication status
+               if ( !$title->isSpecialPage() ) {
+                       $historyUrl = $ctx->getMobileUrl( wfExpandUrl( 
$req->appendQuery( 'action=history' ) ) );
+                       // FIXME: this creates a link with class external - it 
should be local
+                       $historyLink = wfMessage( 
'mobile-frontend-footer-contributors-text',
+                               htmlspecialchars( $historyUrl ) )->parse();
+               } else {
+                       $historyLink = '';
+               }
+               $licenseText = wfMessage( 'mobile-frontend-footer-license-text' 
)->parse();
+               $termsUse = wfMessage( 'mobile-frontend-terms-use-text' 
)->parse();
+
+               $noticeHtml = <<<HTML
+{$historyLink}<br>
+{$licenseText}<span> | {$termsUse}</span>
+HTML;
+
+               $tpl->set( 'mobile-switcher', $switcherHtml );
+               $tpl->set( 'mobile-notice', $noticeHtml );
                $tpl->set( 'mainPageUrl', Title::newMainPage()->getLocalUrl() );
                $tpl->set( 'randomPageUrl', SpecialPage::getTitleFor( 
'Randompage' )->getLocalUrl() );
                $tpl->set( 'watchlistUrl', SpecialPage::getTitleFor( 
'Watchlist' )->getLocalUrl() );
diff --git a/includes/skins/SkinMobileTemplate.php 
b/includes/skins/SkinMobileTemplate.php
index 5ee26fb..6e5d0b3 100644
--- a/includes/skins/SkinMobileTemplate.php
+++ b/includes/skins/SkinMobileTemplate.php
@@ -140,33 +140,40 @@
 
        private function footer() {
                ?>
-       <div id="footer">
+               <div id="footer">
+                       <h2 id="section_footer">
+                               <?php $this->html( 'sitename' ); ?>
+                       </h2>
+                       <div id="content_footer">
                <?php
-               // @todo: make license icon and text dynamic
+                       foreach( $this->getFooterLinks() as $category => $links 
):
                ?>
-       <h2 id="section_footer">
-               <?php $this->html( 'license' ) ?>
-       </h2>
-       <div id="content_footer">
-               <ul class="settings">
-                       <li>
-                               <span class="left separator"><a 
id="mw-mf-display-toggle" href="<?php $this->text( 'viewNormalSiteURL' ) 
?>"><?php
-                                       $this->msg( 
'mobile-frontend-view-desktop' ) ?></a></span><span class="right"><?php
-                               $this->msg( 'mobile-frontend-view-mobile' ) 
?></span>
-                       </li>
-                       <li class="notice">
-                               <?php $this->html( 'historyLink' ) ?><br>
-                               <?php echo wfMessage( 
'mobile-frontend-footer-license-text' )->parse() ?>
-                               <span>| <?php echo wfMessage( 
'mobile-frontend-terms-use-text' )->parse() ?></span>
-                       </li>
-               </ul>
-               <ul class="links">
-                       <li><?php $this->html( 'privacyLink' ) ?></li><li>
-                       <?php $this->html( 'aboutLink' ) ?></li><li>
-                       <?php $this->html( 'disclaimerLink' ) ?></li>
-               </ul>
-       </div><!-- close footer.div / #content_footer -->
-       </div><!-- close #footer -->
-       <?php
+                               <ul class="footer-<?php echo $category; ?>">
+                                       <?php foreach( $links as $link ): ?><li 
id="footer-<?php echo $category ?>-<?php echo $link ?>"><?php $this->html( 
$link ) ?></li><?php endforeach; ?>
+                               </ul>
+                       <?php endforeach; ?>
+                       </div>
+               </div>
+               <?php
+       }
+
+       /**
+        * Returns an array of footerlinks trimmed down to only those footer 
links that
+        * are valid.
+        * $option currently unused in mobile
+        * @return array|mixed
+        */
+       public function getFooterLinks( $option = null ) {
+               return array(
+                       'notice' => array(
+                               'mobile-switcher',
+                               'mobile-notice',
+                       ),
+                       'places' => array(
+                               'privacy',
+                               'about',
+                               'disclaimer',
+                       ),
+               );
        }
 }
diff --git a/less/common/mf-footer.less b/less/common/mf-footer.less
index 7cb9f69..2ae0bee 100644
--- a/less/common/mf-footer.less
+++ b/less/common/mf-footer.less
@@ -15,36 +15,24 @@
                height: 24px;
                display: block;
                margin: 0;
-               font-size: 1em;
+               font-weight: bold;
+               font-size: @baseFontSize;
+               line-height: 22px;
+
+               img {
+                       margin-top: 3px; /* (22px line height - 16px height) / 
2) */
+                       height: 16px;
+               }
+
+               ul, span {
+                       float: left;
+                       margin-right: 4px;
+               }
        }
 
        div {
                font-size: @baseFontSize * 0.9;
                clear: both;
-       }
-
-       .license {
-               float: left;
-               margin-right: 4px;
-       }
-
-       img.license {
-               margin-top: 3px; /* (22px line height - 16px height) / 2) */
-               height: 16px;
-       }
-
-       .links {
-               text-align: center;
-
-               li {
-                       display: inline-block;
-                       width: 33%;
-                       font-size: 0.9em;
-                       text-overflow: ellipsis;
-                       white-space: nowrap;
-                       overflow: hidden;
-                       line-height: 1.4;
-               }
        }
 
        ul {
@@ -54,7 +42,19 @@
                list-style: none;
                margin: 0;
 
-               &.settings {
+               &.footer-places {
+                       li {
+                               display: inline-block;
+                               width: 33%;
+                               font-size: 0.9em;
+                               text-overflow: ellipsis;
+                               white-space: nowrap;
+                               overflow: hidden;
+                               line-height: 1.4;
+                       }
+               }
+
+               &.footer-notice {
                        .left,
                        .right {
                                width: 48%;
@@ -74,25 +74,36 @@
                }
        }
 
-       .notice .terms {
+       .footer-notice .terms {
                float: left;
-       }
-
-       .license {
-               font-weight: bold;
-               font-size: @baseFontSize;
-               line-height: 22px;
        }
 }
 
-html[dir="rtl"] #footer .settings li:first-child .left:before,
-html[dir="ltr"] #footer .settings li:first-child .left:after {
+/* FIXME: Desktop specific style - move out of css served to mobile */
+.skin-minerva {
+       #footer {
+               ul.footer-places {
+                       li {
+                               width: 25%;
+                       }
+               }
+       }
+}
+
+.mw-mf-special {
+       #footer {
+               display: none;
+       }
+}
+
+html[dir="rtl"] #footer .footer-notice li:first-child .left:before,
+html[dir="ltr"] #footer .footer-notice li:first-child .left:after {
        content: " | ";
        visibility: visible;
 }
 
-html[dir="rtl"] #footer .settings .left:before,
-html[dir="ltr"] #footer .settings .left:after {
+html[dir="rtl"] #footer .footer-notice .left:before,
+html[dir="ltr"] #footer .footer-notice .left:after {
        content: " | ";
        visibility: hidden;
 }
@@ -108,13 +119,13 @@
                font-size: 0.9em;
        }
 
-       #footer .links li {
+       #footer ul.footer-places li {
                font-size: 1.1em;
        }
 }
 
 @media all and (min-width: 500px) {
-       #footer .links li {
+       #footer ul.footer-places li {
                font-size: 1.2em;
        }
 }
diff --git a/stylesheets/common/mf-footer.css b/stylesheets/common/mf-footer.css
index a6c0c38..3183178 100644
--- a/stylesheets/common/mf-footer.css
+++ b/stylesheets/common/mf-footer.css
@@ -15,33 +15,24 @@
   height: 24px;
   display: block;
   margin: 0;
+  font-weight: bold;
   font-size: 1em;
+  line-height: 22px;
 }
-#footer div {
-  font-size: 0.9em;
-  clear: both;
-}
-#footer .license {
-  float: left;
-  margin-right: 4px;
-}
-#footer img.license {
+#footer h2 img {
   margin-top: 3px;
   /* (22px line height - 16px height) / 2) */
 
   height: 16px;
 }
-#footer .links {
-  text-align: center;
+#footer h2 ul,
+#footer h2 span {
+  float: left;
+  margin-right: 4px;
 }
-#footer .links li {
-  display: inline-block;
-  width: 33%;
+#footer div {
   font-size: 0.9em;
-  text-overflow: ellipsis;
-  white-space: nowrap;
-  overflow: hidden;
-  line-height: 1.4;
+  clear: both;
 }
 #footer ul {
   text-align: center;
@@ -50,35 +41,46 @@
   list-style: none;
   margin: 0;
 }
-#footer ul.settings .left,
-#footer ul.settings .right {
+#footer ul.footer-places li {
+  display: inline-block;
+  width: 33%;
+  font-size: 0.9em;
+  text-overflow: ellipsis;
+  white-space: nowrap;
+  overflow: hidden;
+  line-height: 1.4;
+}
+#footer ul.footer-notice .left,
+#footer ul.footer-notice .right {
   width: 48%;
   display: inline-block;
   box-sizing: border-box;
 }
-#footer ul.settings .left {
+#footer ul.footer-notice .left {
   text-align: right;
   padding-right: 2px;
 }
-#footer ul.settings .right {
+#footer ul.footer-notice .right {
   text-align: left;
   padding-left: 2px;
 }
-#footer .notice .terms {
+#footer .footer-notice .terms {
   float: left;
 }
-#footer .license {
-  font-weight: bold;
-  font-size: 1em;
-  line-height: 22px;
+/* FIXME: Desktop specific style - move out of css served to mobile */
+.skin-minerva #footer ul.footer-places li {
+  width: 25%;
 }
-html[dir="rtl"] #footer .settings li:first-child .left:before,
-html[dir="ltr"] #footer .settings li:first-child .left:after {
+.mw-mf-special #footer {
+  display: none;
+}
+html[dir="rtl"] #footer .footer-notice li:first-child .left:before,
+html[dir="ltr"] #footer .footer-notice li:first-child .left:after {
   content: " | ";
   visibility: visible;
 }
-html[dir="rtl"] #footer .settings .left:before,
-html[dir="ltr"] #footer .settings .left:after {
+html[dir="rtl"] #footer .footer-notice .left:before,
+html[dir="ltr"] #footer .footer-notice .left:after {
   content: " | ";
   visibility: hidden;
 }
@@ -89,12 +91,12 @@
   #footer .content_block {
     font-size: 0.9em;
   }
-  #footer .links li {
+  #footer ul.footer-places li {
     font-size: 1.1em;
   }
 }
 @media all and (min-width: 500px) {
-  #footer .links li {
+  #footer ul.footer-places li {
     font-size: 1.2em;
   }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1253edfaa5af3d7782a87caf2e3ab0c9b3ae66f0
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to