Jhobs has uploaded a new change for review.

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

Change subject: [Hygiene] Rename internal uses of "article" to "page"
......................................................................

[Hygiene] Rename internal uses of "article" to "page"

Leave all public-facing uses of "article" (including classes) because
the extension is remaining named RelatedArticles. Replace all other
instances with "page" for consistency with other extensions.

Bug: T117908
Change-Id: I0a79826fe2321b6b8fcae1beff385ef8819eaae3
---
M includes/Hooks.php
M includes/ReadMoreHooks.php
M resources/ext.relatedArticles.readMore.bootstrap/index.js
M tests/phpunit/HooksTest.php
4 files changed, 52 insertions(+), 52 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/RelatedArticles 
refs/changes/51/253051/1

diff --git a/includes/Hooks.php b/includes/Hooks.php
index c83c95a..e960f2c 100644
--- a/includes/Hooks.php
+++ b/includes/Hooks.php
@@ -46,19 +46,19 @@
         */
        public static function onFuncRelated( Parser $parser ) {
                $parserOutput = $parser->getOutput();
-               $relatedArticles = $parserOutput->getExtensionData( 
'RelatedArticles' );
-               if ( !$relatedArticles ) {
-                       $relatedArticles = array();
+               $relatedPages = $parserOutput->getExtensionData( 
'RelatedArticles' );
+               if ( !$relatedPages ) {
+                       $relatedPages = array();
                }
                $args = func_get_args();
                array_shift( $args );
 
-               // Add all the related articles passed by the parser function
+               // Add all the related pages passed by the parser function
                // {{#related:Test with read more|Foo|Bar}}
-               foreach ( $args as $relatedArticle ) {
-                       $relatedArticles[] = $relatedArticle;
+               foreach ( $args as $relatedPage ) {
+                       $relatedPages[] = $relatedPage;
                }
-               $parserOutput->setExtensionData( 'RelatedArticles', 
$relatedArticles );
+               $parserOutput->setExtensionData( 'RelatedArticles', 
$relatedPages );
 
                return '';
        }
@@ -66,7 +66,7 @@
        /**
         * Handler for the <code>ParserClearState</code> hook.
         *
-        * Empties the internal list so that related articles are not passed on 
to future
+        * Empties the internal list so that related pages are not passed on to 
future
         * ParserOutput's - note that {{#related:Foo}} appends and can be used 
multiple times
         * in the page.
         *
@@ -108,10 +108,10 @@
        }
 
        /**
-        * Passes the related articles list from the cached parser output
+        * Passes the related pages list from the cached parser output
         * object to the output page for rendering.
         *
-        * The list of related articles will be retrieved using
+        * The list of related pages will be retrieved using
         * <code>ParserOutput#getExtensionData</code> and, if that fails,
         * <code>CustomData#getParserData</code>.
         *
@@ -121,7 +121,7 @@
         */
        public static function onOutputPageParserOutput( OutputPage &$out, 
ParserOutput $parserOutput ) {
                $related = $parserOutput->getExtensionData( 'RelatedArticles' );
-               // Backwards compatability with old cached pages. In cached 
pages, related articles will not be in
+               // Backwards compatability with old cached pages. In cached 
pages, related pages will not be in
                // ParserOutput but will still be in custom data so let's 
retrieve them from there.
                // FIXME: Remove in 30 days (T114915)
                if ( !$related ) {
@@ -136,37 +136,37 @@
        }
 
        /**
-        * Generates anchor element attributes for each entry in list of 
articles.
+        * Generates anchor element attributes for each entry in list of pages.
         *
         * The attributes that are generated are: <code>href</code>,
         * <code>text</code>, and <code>class</code>, with the latter always
         * set to <code>"interwiki-relart"</code>.
         *
-        * If the the article is of the form <code>"Foo && Bar"</code>, then
+        * If the the page is of the form <code>"Foo && Bar"</code>, then
         * the <code>text</code> attribute will be set to "Bar", otherwise the
-        * article's {@see Title::getPrefixedText prefixed text} will be used.
+        * page's {@see Title::getPrefixedText prefixed text} will be used.
         *
-        * @param array[string] $relatedArticles
+        * @param array[string] $relatedPages
         * @return array An array of maps, each with <code>href</code>,
         *  <code>text</code>, and <code>class</code> entries.
         */
-       private static function getRelatedArticlesUrls( array $relatedArticles 
) {
-               $relatedArticlesUrls = array();
+       private static function getRelatedPagesUrls( array $relatedPages ) {
+               $relatedPagesUrls = array();
 
-               foreach ( $relatedArticles as $article ) {
+               foreach ( $relatedPages as $page ) {
                        // Tribute to Evan
-                       $article = urldecode( $article );
+                       $page = urldecode( $page );
 
                        $altText = '';
-                       if ( preg_match( '/\&\&/', $article ) ) {
-                               $parts = array_map( 'trim', explode( '&&', 
$article, 2 ) );
-                               $article = $parts[0];
+                       if ( preg_match( '/\&\&/', $page ) ) {
+                               $parts = array_map( 'trim', explode( '&&', 
$page, 2 ) );
+                               $page = $parts[0];
                                $altText = $parts[1];
                        }
 
-                       $title = Title::newFromText( $article );
+                       $title = Title::newFromText( $page );
                        if ( $title ) {
-                               $relatedArticlesUrls[] = array(
+                               $relatedPagesUrls[] = array(
                                        'href' => $title->getLocalURL(),
                                        'text' => $altText ?: 
$title->getPrefixedText(),
                                        'class' => 'interwiki-relart'
@@ -174,13 +174,13 @@
                        }
                };
 
-               return $relatedArticlesUrls;
+               return $relatedPagesUrls;
        }
 
        /**
         * Handler for the <code>SkinBuildSidebar</code> hook.
         *
-        * Retrieves the list of related articles
+        * Retrieves the list of related pages
         * and adds its HTML representation to the sidebar.
         *
         * @param Skin $skin
@@ -189,18 +189,18 @@
         */
        public static function onSkinBuildSidebar( Skin $skin, &$bar ) {
                $out = $skin->getOutput();
-               $relatedArticles = $out->getProperty( 'RelatedArticles' );
+               $relatedPages = $out->getProperty( 'RelatedArticles' );
 
-               if ( !$relatedArticles ) {
+               if ( !$relatedPages ) {
                        return true;
                }
 
-               $relatedArticlesUrls = self::getRelatedArticlesUrls( 
$relatedArticles );
+               $relatedPagesUrls = self::getRelatedPagesUrls( $relatedPages );
 
                // build relatedarticles <li>'s
-               $relatedArticles = array();
-               foreach ( (array) $relatedArticlesUrls as $url ) {
-                       $relatedArticles[] =
+               $relatedPages = array();
+               foreach ( (array) $relatedPagesUrls as $url ) {
+                       $relatedPages[] =
                                Html::rawElement( 'li', array( 'class' => 
htmlspecialchars( $url['class'] ) ),
                                        Html::element( 'a', array( 'href' => 
htmlspecialchars( $url['href'] ) ),
                                                $url['text']
@@ -211,7 +211,7 @@
                // build complete html
                $bar[$skin->msg( 'relatedarticles-title' )->text()] =
                        Html::rawElement( 'ul', array(),
-                               implode( '', $relatedArticles )
+                               implode( '', $relatedPages )
                        );
 
                return true;
@@ -220,25 +220,25 @@
        /**
         * Handler for the <code>SkinTemplateToolboxEnd</code> hook.
         *
-        * Retrieves the list of related articles from the template and
+        * Retrieves the list of related pages from the template and
         * <code>echo</code>s its HTML representation to the sidebar.
         *
         * @param SkinTemplate $skinTpl
         * @return boolean Always <code>true</code>
         */
        public static function onSkinTemplateToolboxEnd( BaseTemplate &$skinTpl 
) {
-               $relatedArticles = 
$skinTpl->getSkin()->getOutput()->getProperty( 'RelatedArticles' );
+               $relatedPages = $skinTpl->getSkin()->getOutput()->getProperty( 
'RelatedArticles' );
 
-               if ( !$relatedArticles ) {
+               if ( !$relatedPages ) {
                        return true;
                }
 
-               $relatedArticlesUrls = self::getRelatedArticlesUrls( 
$relatedArticles );
+               $relatedPagesUrls = self::getRelatedPagesUrls( $relatedPages );
 
                // build relatedarticles <li>'s
-               $relatedArticles = array();
-               foreach ( (array) $relatedArticlesUrls as $url ) {
-                       $relatedArticles[] =
+               $relatedPages = array();
+               foreach ( (array) $relatedPagesUrls as $url ) {
+                       $relatedPages[] =
                                Html::rawElement( 'li', array( 'class' => 
htmlspecialchars( $url['class'] ) ),
                                        Html::element( 'a', array( 'href' => 
htmlspecialchars( $url['href'] ) ),
                                                $url['text']
@@ -259,7 +259,7 @@
                        Html::element( 'h3', array(), wfMessage( 
'relatedarticles-title' )->text() ) .
                        Html::openElement( 'div', array( 'class' => 'body' ) ) .
                        Html::openElement( 'ul' ) .
-                       implode( '', $relatedArticles );
+                       implode( '', $relatedPages );
 
                return true;
        }
diff --git a/includes/ReadMoreHooks.php b/includes/ReadMoreHooks.php
index ad106b3..4b92273 100644
--- a/includes/ReadMoreHooks.php
+++ b/includes/ReadMoreHooks.php
@@ -11,7 +11,7 @@
         * Handler for the <code>MakeGlobalVariablesScript</code> hook.
         *
         * Sets the value of the <code>wgRelatedArticles</code> global variable
-        * to the list of related articles in the cached parser output.
+        * to the list of related pages in the cached parser output.
         *
         * @param array $vars
         * @param OutputPage $out
diff --git a/resources/ext.relatedArticles.readMore.bootstrap/index.js 
b/resources/ext.relatedArticles.readMore.bootstrap/index.js
index dd988f6..8299646 100644
--- a/resources/ext.relatedArticles.readMore.bootstrap/index.js
+++ b/resources/ext.relatedArticles.readMore.bootstrap/index.js
@@ -1,11 +1,11 @@
 ( function ( $ ) {
 
-       var relatedArticles = mw.config.get( 'wgRelatedArticles' ) || [],
+       var relatedPages = mw.config.get( 'wgRelatedArticles' ) || [],
                config = mw.config.get( [ 'skin', 'wgNamespaceNumber', 
'wgMFMode', 'wgIsMainPage' ] ),
                module;
 
-       // Limit number of related articles to 4 (more of them increases 
likelihood of reader ignoring).
-       relatedArticles = relatedArticles.slice( 0, 4 );
+       // Limit number of related pages to 4 (more of them increases 
likelihood of reader ignoring).
+       relatedPages = relatedPages.slice( 0, 4 );
 
        /**
         * Retrieves the data required to render a card.
@@ -60,7 +60,7 @@
        }
 
        if (
-               relatedArticles.length > 0 &&
+               relatedPages.length > 0 &&
                config.wgNamespaceNumber === 0 &&
                !config.wgIsMainPage &&
                config.skin === 'minerva' &&
@@ -71,7 +71,7 @@
                $( function () {
                        $.when(
                                mw.loader.using( module ),
-                               getData( relatedArticles )
+                               getData( relatedPages )
                        ).done( function ( _, data ) {
                                mw.track( 'ext.relatedArticles.init', { pages: 
data } );
                        } );
diff --git a/tests/phpunit/HooksTest.php b/tests/phpunit/HooksTest.php
index f3331b7..d34e9d3 100644
--- a/tests/phpunit/HooksTest.php
+++ b/tests/phpunit/HooksTest.php
@@ -12,23 +12,23 @@
        public function test_onParserClearState() {
                $parser = new Parser();
                $parserOutput = $parser->mOutput = new ParserOutput();
-               $relatedArticles = array( 'Maybeshewill' );
+               $relatedPages = array( 'Maybeshewill' );
 
-               $parserOutput->setExtensionData( 'RelatedArticles', 
$relatedArticles );
-               $parserOutput->setProperty( 'RelatedArticles', $relatedArticles 
);
+               $parserOutput->setExtensionData( 'RelatedArticles', 
$relatedPages );
+               $parserOutput->setProperty( 'RelatedArticles', $relatedPages );
 
                Hooks::onParserClearState( $parser );
 
                $this->assertEquals(
                        array(),
                        $parserOutput->getExtensionData( 'RelatedArticles' ),
-                       'It clears the list of related articles.'
+                       'It clears the list of related pages.'
                );
 
                $this->assertEquals(
                        false,
                        $parserOutput->getProperty( 'RelatedArticles' ),
-                       '[T115698] It unsets the list of related articles that 
were set as a property.'
+                       '[T115698] It unsets the list of related pages that 
were set as a property.'
                );
        }
 }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0a79826fe2321b6b8fcae1beff385ef8819eaae3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/RelatedArticles
Gerrit-Branch: dev
Gerrit-Owner: Jhobs <[email protected]>

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

Reply via email to