[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: Migrates links extraction to IndexContent

2017-08-10 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/370807 )

Change subject: Migrates links extraction to IndexContent
..


Migrates links extraction to IndexContent

Change-Id: I1cd83824b309708ccf6cdb2b396f0b2e985c20d9
---
M extension.json
A includes/Link.php
M includes/Pagination/PaginationFactory.php
M includes/Parser/PagesTagParser.php
M includes/index/EditIndexPage.php
M includes/index/IndexContent.php
M includes/index/IndexContentHandler.php
M includes/index/ProofreadIndexPage.php
M tests/phpunit/index/IndexContentTest.php
M tests/phpunit/index/ProofreadIndexPageTest.php
10 files changed, 249 insertions(+), 202 deletions(-)

Approvals:
  jenkins-bot: Verified
  Tpt: Looks good to me, approved



diff --git a/extension.json b/extension.json
index bad3426..12f9ce6 100644
--- a/extension.json
+++ b/extension.json
@@ -46,6 +46,7 @@
"ProofreadPage\\DiffFormatterUtils": 
"includes/DiffFormatterUtils.php",
"ProofreadPage\\FileNotFoundException": 
"includes/FileNotFoundException.php",
"ProofreadPage\\FileProvider": "includes/FileProvider.php",
+   "ProofreadPage\\Link": "includes/Link.php",
"ProofreadIndexEntry": "includes/index/ProofreadIndexEntry.php",
"ProofreadIndexPage": "includes/index/ProofreadIndexPage.php",
"ProofreadPage\\Index\\IndexContent": 
"includes/index/IndexContent.php",
diff --git a/includes/Link.php b/includes/Link.php
new file mode 100644
index 000..6199124
--- /dev/null
+++ b/includes/Link.php
@@ -0,0 +1,40 @@
+target = $target;
+   $this->label = $label;
+   }
+
+   /**
+* @return Title
+*/
+   public function getTarget() {
+   return $this->target;
+   }
+
+   /**
+* @return string
+*/
+   public function getLabel() {
+   return $this->label;
+   }
+}
diff --git a/includes/Pagination/PaginationFactory.php 
b/includes/Pagination/PaginationFactory.php
index 834723d..6e62a3e 100644
--- a/includes/Pagination/PaginationFactory.php
+++ b/includes/Pagination/PaginationFactory.php
@@ -52,7 +52,7 @@
}
 
// check if it is using pagelist
-   $pagelist = $indexPage->getPagelistTagContent();
+   $pagelist = $indexPage->getContent()->getPagelistTagContent();
if ( $pagelist !== null && $file && $file->isMultipage() ) {
return new FilePagination(
$indexPage,
@@ -61,12 +61,14 @@
$this->context
);
} else {
-   $links = $indexPage->getLinksToPageNamespace();
+   $links = $indexPage->getContent()->getLinksToNamespace(
+   
Context::getDefaultContext()->getPageNamespaceId()
+   );
$pages = [];
$pageNumbers = [];
foreach ( $links as $link ) {
-   $pages[] = new ProofreadPagePage( $link[0], 
$indexPage );
-   $pageNumbers[] = new PageNumber( $link[1] );
+   $pages[] = new ProofreadPagePage( 
$link->getTarget(), $indexPage );
+   $pageNumbers[] = new PageNumber( 
$link->getLabel() );
}
return new PagePagination( $indexPage, $pages, 
$pageNumbers );
}
diff --git a/includes/Parser/PagesTagParser.php 
b/includes/Parser/PagesTagParser.php
index 9d737b2..90cabe0 100644
--- a/includes/Parser/PagesTagParser.php
+++ b/includes/Parser/PagesTagParser.php
@@ -263,26 +263,28 @@
if ( $header == 'toc' ) {
$this->parser->getOutput()->is_toc = true;
}
-   $indexLinks = $indexPage->getLinksToMainNamespace();
+   $indexLinks = 
$indexPage->getContent()->getLinksToNamespace(
+   NS_MAIN, $indexTitle, true
+   );
$pageTitle = $this->parser->getTitle();
$h_out = '{{:MediaWiki:Proofreadpage_header_template';
$h_out .= "|value=$header";
// find next and previous pages in list
$indexLinksCount = count( $indexLinks );
for ( $i = 0; $i < $indexLinksCount; $i++ ) {
-   if ( $pageTitle->equals( $indexLinks[$i][0] ) ) 
{
-   $current = '[[' . 
$indexLinks[$i][0]->getFullText() . '|' .
-   $indexLinks[$i][1] . ']]';
+   if ( $pageTitle->equals( 

[MediaWiki-commits] [Gerrit] mediawiki...ProofreadPage[master]: Migrates links extraction to IndexContent

2017-08-09 Thread Tpt (Code Review)
Tpt has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370807 )

Change subject: Migrates links extraction to IndexContent
..

Migrates links extraction to IndexContent

Change-Id: I1cd83824b309708ccf6cdb2b396f0b2e985c20d9
---
M extension.json
A includes/Link.php
M includes/Pagination/PaginationFactory.php
M includes/Parser/PagesTagParser.php
M includes/index/EditIndexPage.php
M includes/index/IndexContent.php
M includes/index/IndexContentHandler.php
M includes/index/ProofreadIndexPage.php
M tests/phpunit/index/IndexContentTest.php
M tests/phpunit/index/ProofreadIndexPageTest.php
10 files changed, 256 insertions(+), 202 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ProofreadPage 
refs/changes/07/370807/1

diff --git a/extension.json b/extension.json
index bad3426..12f9ce6 100644
--- a/extension.json
+++ b/extension.json
@@ -46,6 +46,7 @@
"ProofreadPage\\DiffFormatterUtils": 
"includes/DiffFormatterUtils.php",
"ProofreadPage\\FileNotFoundException": 
"includes/FileNotFoundException.php",
"ProofreadPage\\FileProvider": "includes/FileProvider.php",
+   "ProofreadPage\\Link": "includes/Link.php",
"ProofreadIndexEntry": "includes/index/ProofreadIndexEntry.php",
"ProofreadIndexPage": "includes/index/ProofreadIndexPage.php",
"ProofreadPage\\Index\\IndexContent": 
"includes/index/IndexContent.php",
diff --git a/includes/Link.php b/includes/Link.php
new file mode 100644
index 000..9c1d649
--- /dev/null
+++ b/includes/Link.php
@@ -0,0 +1,46 @@
+target = $target;
+   $this->label = $label;
+   }
+
+   /**
+* @return Title
+*/
+   public function getTarget() {
+   return $this->target;
+   }
+
+   /**
+* @return string
+*/
+   public function getLabel() {
+   return $this->label;
+   }
+}
diff --git a/includes/Pagination/PaginationFactory.php 
b/includes/Pagination/PaginationFactory.php
index 834723d..6e62a3e 100644
--- a/includes/Pagination/PaginationFactory.php
+++ b/includes/Pagination/PaginationFactory.php
@@ -52,7 +52,7 @@
}
 
// check if it is using pagelist
-   $pagelist = $indexPage->getPagelistTagContent();
+   $pagelist = $indexPage->getContent()->getPagelistTagContent();
if ( $pagelist !== null && $file && $file->isMultipage() ) {
return new FilePagination(
$indexPage,
@@ -61,12 +61,14 @@
$this->context
);
} else {
-   $links = $indexPage->getLinksToPageNamespace();
+   $links = $indexPage->getContent()->getLinksToNamespace(
+   
Context::getDefaultContext()->getPageNamespaceId()
+   );
$pages = [];
$pageNumbers = [];
foreach ( $links as $link ) {
-   $pages[] = new ProofreadPagePage( $link[0], 
$indexPage );
-   $pageNumbers[] = new PageNumber( $link[1] );
+   $pages[] = new ProofreadPagePage( 
$link->getTarget(), $indexPage );
+   $pageNumbers[] = new PageNumber( 
$link->getLabel() );
}
return new PagePagination( $indexPage, $pages, 
$pageNumbers );
}
diff --git a/includes/Parser/PagesTagParser.php 
b/includes/Parser/PagesTagParser.php
index 9d737b2..90cabe0 100644
--- a/includes/Parser/PagesTagParser.php
+++ b/includes/Parser/PagesTagParser.php
@@ -263,26 +263,28 @@
if ( $header == 'toc' ) {
$this->parser->getOutput()->is_toc = true;
}
-   $indexLinks = $indexPage->getLinksToMainNamespace();
+   $indexLinks = 
$indexPage->getContent()->getLinksToNamespace(
+   NS_MAIN, $indexTitle, true
+   );
$pageTitle = $this->parser->getTitle();
$h_out = '{{:MediaWiki:Proofreadpage_header_template';
$h_out .= "|value=$header";
// find next and previous pages in list
$indexLinksCount = count( $indexLinks );
for ( $i = 0; $i < $indexLinksCount; $i++ ) {
-   if ( $pageTitle->equals( $indexLinks[$i][0] ) ) 
{
-   $current = '[[' . 
$indexLinks[$i][0]->getFullText() . '|' .
-   $indexLinks[$i][1] . ']]';
+   if (