in CSS. This results in slight size increase before gzip compression (due to
percent-encoding), but up to 20% decrease after it.
* Upgrade jStorage to v0.4.12.
+* MediaWiki now natively supports page status indicators: icons (or short text
+ snippets) usually displayed in the top-right corner of the page. They have
+ been in use on Wikipedia for a long time, implemented using templates and CSS
+ absolute positioning.
+ - Basic wikitext syntax: <indicator name="foo">[[File:Foo.svg|20px]]</indicator>
+ - Usage instructions: https://www.mediawiki.org/wiki/Help:Page_status_indicators
+ - Adjusting custom skins to support indicators:
+ https://www.mediawiki.org/wiki/Manual:Skinning#Page_status_indicators
=== Bug fixes in 1.25 ===
* (bug 71003) No additional code will be generated to try to load CSS-embedded
/** @var array */
protected $mCategories = array();
+ /** @var array */
+ protected $mIndicators = array();
+
/** @var array Array of Interwiki Prefixed (non DB key) Titles (e.g. 'fr:Test page') */
private $mLanguageLinks = array();
return $this->mCategories;
}
+ /**
+ * Add an array of indicators, with their identifiers as array keys and HTML contents as values.
+ *
+ * In case of duplicate keys, existing values are overwritten.
+ *
+ * @param array $indicators
+ * @since 1.25
+ */
+ public function setIndicators( array $indicators ) {
+ $this->mIndicators = $indicators + $this->mIndicators;
+ // Keep ordered by key
+ ksort( $this->mIndicators );
+ }
+
+ /**
+ * Get the indicators associated with this page.
+ *
+ * The array will be internally ordered by item keys.
+ *
+ * @return array Keys: identifiers, values: HTML contents
+ * @since 1.25
+ */
+ public function getIndicators() {
+ return $this->mIndicators;
+ }
+
/**
* Restrict the page to loading modules bundled the software.
*
public function addParserOutputMetadata( $parserOutput ) {
$this->mLanguageLinks += $parserOutput->getLanguageLinks();
$this->addCategoryLinks( $parserOutput->getCategories() );
+ $this->setIndicators( $parserOutput->getIndicators() );
$this->mNewSectionLink = $parserOutput->getNewSection();
$this->mHideNewSectionLink = $parserOutput->getHideNewSection();
$result_array['modulemessages'] = array_values( array_unique( $p_result->getModuleMessages() ) );
}
+ if ( isset( $prop['indicators'] ) ) {
+ foreach ( $p_result->getIndicators() as $name => $content ) {
+ $indicator = array( 'name' => $name );
+ ApiResult::setContent( $indicator, $content );
+ $result_array['indicators'][] = $indicator;
+ }
+ }
+
if ( isset( $prop['iwlinks'] ) ) {
$result_array['iwlinks'] = $this->formatIWLinks( $p_result->getInterwikiLinks() );
}
'sections' => 's',
'headitems' => 'hi',
'modules' => 'm',
+ 'indicators' => 'ind',
'modulescripts' => 'm',
'modulestyles' => 'm',
'modulemessages' => 'm',
'headitems',
'headhtml',
'modules',
+ 'indicators',
'iwlinks',
'wikitext',
'properties',
' headitems - Gives items to put in the <head> of the page',
' headhtml - Gives parsed <head> of the page',
' modules - Gives the ResourceLoader modules used on the page',
+ ' indicators - Gives the HTML of page status indicators used on the page',
' iwlinks - Gives interwiki links in the parsed wikitext',
' wikitext - Gives the original wikitext that was parsed',
' properties - Gives various properties defined in the parsed wikitext',
$parser->setHook( 'pre', array( __CLASS__, 'pre' ) );
$parser->setHook( 'nowiki', array( __CLASS__, 'nowiki' ) );
$parser->setHook( 'gallery', array( __CLASS__, 'gallery' ) );
+ $parser->setHook( 'indicator', array( __CLASS__, 'indicator' ) );
if ( $wgRawHtml ) {
$parser->setHook( 'html', array( __CLASS__, 'html' ) );
}
public static function gallery( $content, $attributes, $parser ) {
return $parser->renderImageGallery( $content, $attributes );
}
+
+ /**
+ * XML-style tag for page status indicators: icons (or short text snippets) usually displayed in
+ * the top-right corner of the page, outside of the main content.
+ *
+ * @param string $content
+ * @param array $attributes
+ * @param Parser $parser
+ * @param PPFrame $frame
+ * @return string
+ * @since 1.25
+ */
+ public static function indicator( $content, array $attributes, Parser $parser, PPFrame $frame ) {
+ if ( !isset( $attributes['name'] ) || trim( $attributes['name'] ) === '' ) {
+ return '<span class="error">' .
+ wfMessage( 'invalid-indicator-name' )->inContentLanguage()->text() .
+ '</span>';
+ }
+
+ $parser->getOutput()->setIndicator(
+ trim( $attributes['name'] ),
+ $parser->recursiveTagParse( $content, $frame )
+ );
+
+ return '';
+ }
}
public $mText, # The output text
$mLanguageLinks, # List of the full text of language links, in the order they appear
$mCategories, # Map of category names to sort keys
+ $mIndicators = array(), # Page status indicators, usually displayed in top-right corner
$mTitleText, # title text of the chosen language variant
$mLinks = array(), # 2-D map of NS/DBK to ID for the links in the document. ID=zero for broken.
$mTemplates = array(), # 2-D map of NS/DBK to ID for the template references. ID=zero for broken.
return $this->mCategories;
}
+ /**
+ * @since 1.25
+ */
+ public function getIndicators() {
+ return $this->mIndicators;
+ }
+
public function getTitleText() {
return $this->mTitleText;
}
$this->mCategories[$c] = $sort;
}
+ /**
+ * @since 1.25
+ */
+ public function setIndicator( $id, $content ) {
+ $this->mIndicators[$id] = $content;
+ }
+
public function addLanguageLink( $t ) {
$this->mLanguageLinks[] = $t;
}
return $footericons;
}
+ /**
+ * Get the suggested HTML for page status indicators: icons (or short text snippets) usually
+ * displayed in the top-right corner of the page, outside of the main content.
+ *
+ * Your skin may implement this differently, for example by handling some indicator names
+ * specially with a different UI. However, it is recommended to use a `<div class="mw-indicator"
+ * id="mw-indicator-<id>" />` as a wrapper element for each indicator, for better compatibility
+ * with extensions and user scripts.
+ *
+ * The raw data is available in `$this->data['indicators']` as an associative array (keys:
+ * identifiers, values: contents) internally ordered by keys.
+ *
+ * @return string HTML
+ * @since 1.25
+ */
+ public function getIndicators() {
+ $out = "<div class=\"mw-indicators\">\n";
+ foreach ( $this->data['indicators'] as $id => $content ) {
+ $out .= Html::rawElement(
+ 'div',
+ array(
+ 'id' => Sanitizer::escapeId( "mw-indicator-$id" ),
+ 'class' => 'mw-indicator',
+ ),
+ $content
+ ) . "\n";
+ }
+ $out .= "</div>\n";
+ return $out;
+ }
+
/**
* Output the basic end-page trail including bottomscripts, reporttime, and
* debug stuff. This should be called right before outputting the closing
}
}
+ $tpl->set( 'indicators', $out->getIndicators() );
+
$tpl->set( 'sitenotice', $this->getSiteNotice() );
$tpl->set( 'bottomscripts', $this->bottomScripts() );
$tpl->set( 'printfooter', $this->printSource() );
"unknown_extension_tag": "Unknown extension tag \"$1\"",
"duplicate-defaultsort": "<strong>Warning:</strong> Default sort key \"$2\" overrides earlier default sort key \"$1\".",
"duplicate-displaytitle": "<strong>Warning:</strong> Display title \"$2\" overrides earlier display title \"$1\".",
+ "invalid-indicator-name": "<strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.",
"version": "Version",
"version-summary": "",
"version-extensions": "Installed extensions",
"unknown_extension_tag": "This is an error shown when you use an unknown extension tag name.\n\nThis feature allows tags like <code><nowiki><pre></nowiki></code> to be called with a parser like <code><nowiki>{{#tag:pre}}</nowiki></code>.\n\nParameters:\n* $1 - the unknown extension tag name",
"duplicate-defaultsort": "See definition of [[w:Sorting|sort key]] on Wikipedia. Parameters:\n* $1 - old default sort key\n* $2 - new default sort key",
"duplicate-displaytitle": "Warning shown when a page has its display title set multiple times. Parameters:\n* $1 - old display title\n* $2 - new display title",
+ "invalid-indicator-name": "Warning shown when the [https://www.mediawiki.org/wiki/Help:Page_status_indicators <indicator name=\"''unique-identifier''\">''content''</indicator>] parser tag is used incorrectly.",
"version": "{{doc-special|Version}}\n{{Identical|Version}}",
"version-summary": "{{doc-specialpagesummary|version}}",
"version-extensions": "Header on [[Special:Version]].",