diff --git a/Refreshed.skin.php b/Refreshed.skin.php index df804ab..457507f 100644 --- a/Refreshed.skin.php +++ b/Refreshed.skin.php @@ -1,718 +1,719 @@ addMeta( 'viewport', 'width=device-width' ); $min = $this->getRequest()->getFuzzyBool( 'debug' ) ? '.src' : '.min'; // add jQuery Mobile touch events /*$out->addHeadItem( 'jquerymobiletouchevents', Html::element( 'script', array( 'src' => htmlspecialchars( $wgLocalStylePath ) . "/Refreshed/refreshed/jquery.mobile.custom{$min}.js", 'type' => 'text/javascript' ) ) );*/ // shouldn't this be loaded with ResourceLoader???/what is it? // prevent iOS from zooming out when the sidebar is opened $out->addHeadItem( 'viewportforios', Html::element( 'meta', array( 'name' => 'viewport', 'content' => 'width=device-width, initial-scale=1.0' ) ) ); // Inject webfont loader CSS file inline here so that it'll work even for IE11 // Conditional comments aren't supported in IE10+ so we have no way of loading // this just for IE, so better to have all font declarations here (and // maybe one day we'll rename the file to just "fontloader.css" or something) // Based on some quick-ish testing on 25 July 2016, it appears that font // declarations need to be loaded before they're used so that they work // under IE(11). // See https://phabricator.wikimedia.org/T134653 for more info. $out->addHeadItem( 'webfontfix', Html::element( 'link', array( 'href' => $wgLocalStylePath . '/Refreshed/refreshed/iefontfix.css', 'rel' => 'stylesheet' ) ) ); // Add JavaScript via ResourceLoader $out->addModules( 'skins.refreshed.js' ); } function setupSkinUserCss( OutputPage $out ) { parent::setupSkinUserCss( $out ); // Add CSS via ResourceLoader $out->addModuleStyles( array( 'mediawiki.skinning.interface', 'mediawiki.skinning.content.externallinks', 'skins.refreshed' ) ); } } class RefreshedTemplate extends BaseTemplate { /** * Parses MediaWiki:Refreshed-wiki-dropdown. * Forked from Games' parseSidebarMenu(), which in turn was forked from * Monaco's parseSidebarMenu(), but none of these three methods are * identical. * * @param string $messageKey Message name * @return array */ private function parseDropDownMenu( $messageKey ) { $lines = $this->getLines( $messageKey ); $nodes = array(); $i = 0; if ( is_array( $lines ) ) { foreach ( $lines as $line ) { # ignore empty lines if ( strlen( $line ) == 0 ) { continue; } $node = self::parseItem( $line ); for ( $x = $i; $x >= 0; $x-- ) { if ( $x == 0 ) { break; } } $nodes[$i + 1] = $node; $i++; } } return $nodes; } /** * Parse one pipe-separated line from MediaWiki message to array with * indexes 'logo', 'href' and 'wiki_name'. * * @param string $line Line (beginning with a *) from a MediaWiki: message * @return array */ public static function parseItem( $line ) { // trim spaces and asterisks from line and then split it to maximum three chunks $line_temp = explode( '|', trim( $line, '* ' ), 3 ); // trim [ and ] from line to have just http://en.wikipedia.org instead // of [http://en.wikipedia.org] for external links $line_temp[0] = trim( $line_temp[0], '[]' ); if ( count( $line_temp ) >= 2 && $line_temp[1] != '' ) { $logo = trim( $line_temp[1] ); } else { $logo = trim( $line_temp[0] ); } if ( isset( $line_temp[2] ) && preg_match( '/^(?:' . wfUrlProtocols() . ')/', $line_temp[2] ) ) { $href = $line_temp[2]; } else { $href = '#'; } return array( 'logo' => $logo, 'href' => $href, 'wiki_name' => $line_temp[0] ); } /** * @param string $messageKey Name of a MediaWiki: message * @return array|null Array if $messageKey has been given, otherwise null */ private function getMessageAsArray( $messageKey ) { $messageObj = $this->getSkin()->msg( $messageKey )->inContentLanguage(); if ( !$messageObj->isDisabled() ) { $lines = explode( "\n", $messageObj->text() ); if ( count( $lines ) > 0 ) { return $lines; } } return null; } /** * @param string $messageKey Name of a MediaWiki: message * @return array */ private function getLines( $messageKey ) { $title = Title::newFromText( $messageKey, NS_MEDIAWIKI ); $revision = Revision::newFromTitle( $title ); if ( is_object( $revision ) ) { - if ( trim( $revision->getText() ) != '' ) { + $contentText = ContentHandler::getContentText( $revision->getContent() ); + if ( trim( $contentText ) != '' ) { $temp = $this->getMessageAsArray( $messageKey ); if ( count( $temp ) > 0 ) { wfDebugLog( 'Refreshed', sprintf( 'Get LOCAL %s, which contains %s lines', $messageKey, count( $temp ) ) ); $lines = $temp; } } } if ( empty( $lines ) ) { $lines = $this->getMessageAsArray( $messageKey ); wfDebugLog( 'Refreshed', sprintf( 'Get %s, which contains %s lines', $messageKey, count( $lines ) ) ); } return $lines; } public function execute() { global $wgMemc; $skin = $this->getSkin(); $config = $skin->getConfig(); $user = $skin->getUser(); // Title processing $titleBase = $skin->getTitle(); $title = $titleBase->getSubjectPage(); $titleNamespace = $titleBase->getNamespace(); $key = wfMemcKey( 'refreshed', 'header' ); $headerNav = $wgMemc->get( $key ); if ( !$headerNav ) { $headerNav = array(); $skin->addToSidebar( $headerNav, 'refreshed-navigation' ); $wgMemc->set( $key, $headerNav, 60 * 60 * 24 ); // 24 hours } $dropdownCacheKey = wfMemcKey( 'refreshed', 'dropdownmenu' ); $dropdownNav = $wgMemc->get( $dropdownCacheKey ); if ( !$dropdownNav ) { $dropdownNav = $this->parseDropDownMenu( 'Refreshed-wiki-dropdown' ); $wgMemc->set( $dropdownCacheKey, $dropdownNav, 60 * 60 * 24 ); // 24 hours } $thisWikiURLMsg = $skin->msg( 'refreshed-this-wiki-url' ); if ( $thisWikiURLMsg->isDisabled() ) { $thisWikiURL = htmlspecialchars( Title::newMainPage()->getFullURL() ); } else { $thisWikiURL = $skin->msg( 'refreshed-this-wiki-url' )->escaped(); } $thisWikiWordmarkLogo = $skin->msg( 'refreshed-this-wiki-wordmark' )->escaped(); $logoImgElement = Html::element( 'img', array( 'src' => $thisWikiWordmarkLogo, 'alt' => $config->get( 'Sitename' ), 'width' => 144, 'height' => 30 ) ); $thisWikiMobileLogo = $skin->msg( 'refreshed-this-wiki-mobile-logo' ); $thisWikiMobileLogoImgElement = ''; if ( !$thisWikiMobileLogo->isDisabled() ) { $thisWikiMobileLogoImgElement = Html::element( 'img', array( 'src' => $thisWikiMobileLogo->escaped(), 'alt' => $config->get( 'Sitename' ), // 'width' => ???, // 'height' => ??? ) ); } // Output the tag and whatnot $this->html( 'headelement' ); ?>
isDisabled() ) { // if a mobile logo has been defined ?>
getId(), 'l' ); $avatarImage = $avatar->getAvatarURL( array( 'width' => 30, 'class' => 'avatar' ) ); ?> getName() ?> data['loggedin'] ) { // if no SocialProfile but user is logged in ?> getName() ?> getMsg( 'login' )->text() ?>
$sub ) { ?>
data['sitenotice'] ) { ?>
html( 'newtalk' ) ?>

html( 'title' ) ?>

msg( 'tagline' ) ?>
data['subtitle'] || $this->data['undelete'] ) { ?>
html( 'userlangattributes' ) ?>>html( 'subtitle' ) ?>html( 'undelete' ) ?>
getIndicators(); } ?>
data['content_actions'] ); $pageTab = key( $this->data['content_actions'] ); $isEditing = in_array( $skin->getRequest()->getText( 'action' ), array( 'edit', 'submit' ) ); // determining how many tools need to be generated $totalSmallToolsToGenerate = 0; $listOfToolsToGenerate = array( 'wikiglyph wikiglyph-speech-bubbles' => 'ca-talk', 'wikiglyph wikiglyph-pencil-lock-full' => 'ca-viewsource', 'wikiglyph wikiglyph-pencil' => 'ca-edit', 'wikiglyph wikiglyph-clock' => 'ca-history', 'wikiglyph wikiglyph-trash' => 'ca-delete', 'wikiglyph wikiglyph-move' => 'ca-move', 'wikiglyph wikiglyph-lock' => 'ca-protect', 'wikiglyph wikiglyph-unlock' => 'ca-unprotect', 'wikiglyph wikiglyph-star' => 'ca-watch', 'wikiglyph wikiglyph-unstar' => 'ca-unwatch' ); foreach ( $this->data['content_actions'] as $action ) { if ( in_array( $action['id'], $listOfToolsToGenerate ) ) { // if the icon in question is one of the listed ones $totalSmallToolsToGenerate++; } } if ( MWNamespace::isTalk( $titleNamespace ) ) { // if talk namespace $totalSmallToolsToGenerate--; // remove a tool (the talk page tool) if the user is on a talk page } if ( $totalSmallToolsToGenerate > 0 && !$isEditing ) { // if there's more than zero tools to be generated and the user isn't editing a page ?>
data['content_actions'] as $action ) { if ( $smallToolBeingTested > $amountOfSmallToolsToSkipInFront ) { // if we're not supposed to skip this tool (e.g. if we're supposed to skip the first 2 tools and we're at the 3rd tool, then the boolean is true) // @todo Maybe write a custom makeLink()-like function for generating this code? if ( in_array( $action['id'], $listOfToolsToGenerate ) ) { // if the icon being rendered is one of the listed ones (if we're supposed to generate this tool) ?>
3 ) { ?>
html( 'bodytext' ) ?>
html( 'catlinks' ); if ( $this->data['dataAfterContent'] ) { $this->html( 'dataAfterContent' ); } ?>
printTrail(); echo Html::closeElement( 'body' ); echo Html::closeElement( 'html' ); } }