jenkins-bot has submitted this change and it was merged.

Change subject: Move SiteMatrix special page to its own file
......................................................................


Move SiteMatrix special page to its own file

Change-Id: Ic1e275fec7ba0667a4d51459c871eb8ee13d0f62
---
M SiteMatrix.php
M SiteMatrixApi.php
M SiteMatrix_body.php
A SpecialSiteMatrix.php
4 files changed, 147 insertions(+), 147 deletions(-)

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



diff --git a/SiteMatrix.php b/SiteMatrix.php
index 98a2f56..aa0d29e 100644
--- a/SiteMatrix.php
+++ b/SiteMatrix.php
@@ -72,8 +72,9 @@
 $wgExtensionMessagesFiles['SiteMatrixAlias'] = $dir . 'SiteMatrix.alias.php';
 
 $wgAutoloadClasses['SiteMatrix'] = $dir . 'SiteMatrix_body.php';
-$wgAutoloadClasses['SiteMatrixPage'] = $dir . 'SiteMatrix_body.php';
-$wgSpecialPages['SiteMatrix'] = 'SiteMatrixPage';
+
+$wgAutoloadClasses['SpecialSiteMatrix'] = $dir . 'SpecialSiteMatrix.php';
+$wgSpecialPages['SiteMatrix'] = 'SpecialSiteMatrix';
 $wgSpecialPageGroups['SiteMatrix'] = 'wiki';
 
 $wgAutoloadClasses['ApiQuerySiteMatrix'] = $dir . 'SiteMatrixApi.php';
diff --git a/SiteMatrixApi.php b/SiteMatrixApi.php
index 8fd80ae..5856c3b 100644
--- a/SiteMatrixApi.php
+++ b/SiteMatrixApi.php
@@ -24,7 +24,7 @@
                        'count' => $matrix->getCount(),
                );
 
-               $localLanguageNames = SiteMatrixPage::getLocalLanguageNames();
+               $localLanguageNames = 
SpecialSiteMatrix::getLocalLanguageNames();
 
                $params = $this->extractRequestParams();
                $type = array_flip( $params['type'] );
diff --git a/SiteMatrix_body.php b/SiteMatrix_body.php
index 10c576f..e794812 100644
--- a/SiteMatrix_body.php
+++ b/SiteMatrix_body.php
@@ -5,9 +5,6 @@
        exit( 1 );
 }
 
-global $IP;
-require_once( $IP . '/languages/Names.php' );
-
 class SiteMatrix {
        protected $langlist, $sites, $names, $hosts;
 
@@ -347,146 +344,5 @@
                }
 
                return true;
-       }
-}
-
-class SiteMatrixPage extends SpecialPage {
-
-       function __construct() {
-               parent::__construct( 'SiteMatrix' );
-       }
-
-       /**
-        * @return array
-        */
-       public static function getLocalLanguageNames() {
-               if ( class_exists( 'LanguageNames' ) ) {
-                       global $wgLang;
-                       return LanguageNames::getNames( $wgLang->getCode() );
-               }
-               return array();
-       }
-
-       function execute( $par ) {
-               $langNames = Language::fetchLanguageNames();
-
-               $this->setHeaders();
-               $this->outputHeader();
-
-               $matrix = new SiteMatrix();
-
-               $localLanguageNames = self::getLocalLanguageNames();
-
-               # Construct the HTML
-
-               # Header row
-               $s = Xml::openElement( 'table', array( 'class' => 'wikitable', 
'id' => 'mw-sitematrix-table' ) ) .
-                       "<tr>" .
-                       Xml::element( 'th',
-                               array( 'rowspan' => 2 ),
-                               $this->msg( 'sitematrix-language' )->text() ) .
-                       Xml::element( 'th',
-                               array( 'colspan' => count( $matrix->getSites() 
) ),
-                               $this->msg( 'sitematrix-project' )->text() ) .
-                       "</tr>
-                       <tr>";
-               foreach ( $matrix->getNames() as $id => $name ) {
-                       $url = $matrix->getSiteUrl( $id );
-                       $s .= Xml::tags( 'th', null, "<a 
href=\"{$url}\">{$name}</a>" );
-               }
-               $s .= "</tr>\n";
-
-               # Bulk of table
-               foreach ( $matrix->getLangList() as $lang ) {
-                       $anchor = strtolower( '<a id="' . htmlspecialchars( 
$lang ) . '" name="' . htmlspecialchars( $lang ) . '"></a>' );
-                       $s .= '<tr>';
-                       $attribs = array();
-                       if ( isset( $localLanguageNames[$lang] ) ) {
-                               $attribs['title'] = $localLanguageNames[$lang];
-                       }
-
-                       $langDisplay = ( isset( $langNames[$lang] ) ? 
Html::rawElement( 'span', array( 'lang' => htmlspecialchars( $lang ) ), 
$langNames[$lang] ) : '' );
-                       if ( isset( $localLanguageNames[$lang] ) && strlen( 
$localLanguageNames[$lang] ) && $langDisplay != $localLanguageNames[$lang] ) {
-                               $langDisplay .= $this->msg( 'word-separator' 
)->text() .
-                                                $this->msg( 'parentheses', 
$localLanguageNames[$lang] )->text();
-                       }
-                       $s .= '<td>' . $anchor . Html::rawElement( 'strong', 
$attribs, $langDisplay ) . '</td>';
-
-                       foreach ( $matrix->getNames() as $site => $name ) {
-                               $url = $matrix->getUrl( $lang, $site );
-                               if ( $matrix->exist( $lang, $site ) ) {
-                                       # Wiki exists
-                                       $closed = $matrix->isClosed( $lang, 
$site );
-                                       $s .= "<td>" . ( $closed ? "<del>" : '' 
) . "<a href=\"{$url}\">{$lang}</a>" . ( $closed ? "</del>" : '' ) . '</td>';
-                               } else {
-                                       # Non-existent wiki
-                                       $s .= "<td><a href=\"{$url}\" 
class=\"new\">{$lang}</a></td>";
-                               }
-                       }
-                       $s .= "</tr>\n";
-               }
-
-               $language = $this->getLanguage();
-               # Total
-               $totalCount = 0;
-               $s .= '<tr><th rowspan="2"><a id="total" name="total"></a>' . 
$this->msg( 'sitematrix-sitetotal' )->escaped() . '</th>';
-               foreach ( $matrix->getNames() as $site => $name ) {
-                       $url = $matrix->getSiteUrl( $site );
-                       $count = $matrix->getCountPerSite( $site );
-                       $totalCount += $count;
-                       $count = $language->formatNum( $count );
-                       $s .= "<th><a href=\"{$url}\">{$count}</a></th>";
-               }
-               $s .= '</tr>';
-
-               $s .= '<tr>';
-               $noProjects = count( $matrix->getNames() );
-               $totalCount = $language->formatNum( $totalCount );
-               $s .= "<th colspan=\"{$noProjects }\">{$totalCount}</th>";
-               $s .= '</tr>';
-
-               $s .= Xml::closeElement( 'table' ) . "\n";
-
-               # Specials
-               $s .= '<h2 id="mw-sitematrix-others">' . $this->msg( 
'sitematrix-others' )->escaped() . '</h2>';
-
-               $s .= Xml::openElement( 'table', array( 'class' => 'wikitable', 
'id' => 'mw-sitematrix-other-table' ) ) .
-                       "<tr>" .
-                       Xml::element( 'th', null, $this->msg( 
'sitematrix-other-projects' )->text() ) .
-                       "</tr>";
-
-               foreach ( $matrix->getSpecials() as $special ) {
-                       list( $lang, $site ) = $special;
-
-                       // sanity check
-                       if ( !$lang && !$site ) {
-                               continue;
-                       }
-
-                       $langhost = str_replace( '_', '-', $lang );
-                       $url = $matrix->getUrl( $lang, $site );
-
-                       # Handle options
-                       $flags = array();
-                       if ( $matrix->isPrivate( $lang . $site ) ) {
-                               $flags[] = $this->msg( 'sitematrix-private' 
)->escaped();
-                       }
-                       if ( $matrix->isFishbowl( $lang . $site ) ) {
-                               $flags[] = $this->msg( 'sitematrix-fishbowl' 
)->escaped();
-                       }
-                       $flagsStr = implode( ', ', $flags );
-                       if ( $site != 'wiki' ) {
-                               $langhost .= $site;
-                       }
-                       $closed = $matrix->isClosed( $lang, $site );
-                       $s .= '<tr><td>' . ( $closed ? '<del>' : '' ) .
-                               $language->specialList( '<a href="' . $url . 
'/">' . $langhost . "</a>", $flagsStr ) .
-                               ( $closed ? '</del>' : '' ) . "</td></tr>\n";
-               }
-
-               $s .= Xml::closeElement( 'table' ) . "\n";
-
-               $this->getOutput()->addHTML( $s );
-               $this->getOutput()->addWikiMsg( 'sitematrix-total', 
$language->formatNum( $matrix->getCount() ) );
        }
 }
diff --git a/SpecialSiteMatrix.php b/SpecialSiteMatrix.php
new file mode 100644
index 0000000..4880250
--- /dev/null
+++ b/SpecialSiteMatrix.php
@@ -0,0 +1,143 @@
+<?php
+
+
+class SpecialSiteMatrix extends SpecialPage {
+
+       function __construct() {
+               parent::__construct( 'SiteMatrix' );
+       }
+
+       /**
+        * @return array
+        */
+       public static function getLocalLanguageNames() {
+               if ( class_exists( 'LanguageNames' ) ) {
+                       global $wgLang;
+                       return LanguageNames::getNames( $wgLang->getCode() );
+               }
+               return array();
+       }
+
+       function execute( $par ) {
+               $langNames = Language::fetchLanguageNames();
+
+               $this->setHeaders();
+               $this->outputHeader();
+
+               $matrix = new SiteMatrix();
+
+               $localLanguageNames = self::getLocalLanguageNames();
+
+               # Construct the HTML
+
+               # Header row
+               $s = Xml::openElement( 'table', array( 'class' => 'wikitable', 
'id' => 'mw-sitematrix-table' ) ) .
+                       "<tr>" .
+                       Xml::element( 'th',
+                               array( 'rowspan' => 2 ),
+                               $this->msg( 'sitematrix-language' )->text() ) .
+                       Xml::element( 'th',
+                               array( 'colspan' => count( $matrix->getSites() 
) ),
+                               $this->msg( 'sitematrix-project' )->text() ) .
+                       "</tr>
+                       <tr>";
+               foreach ( $matrix->getNames() as $id => $name ) {
+                       $url = $matrix->getSiteUrl( $id );
+                       $s .= Xml::tags( 'th', null, "<a 
href=\"{$url}\">{$name}</a>" );
+               }
+               $s .= "</tr>\n";
+
+               # Bulk of table
+               foreach ( $matrix->getLangList() as $lang ) {
+                       $anchor = strtolower( '<a id="' . htmlspecialchars( 
$lang ) . '" name="' . htmlspecialchars( $lang ) . '"></a>' );
+                       $s .= '<tr>';
+                       $attribs = array();
+                       if ( isset( $localLanguageNames[$lang] ) ) {
+                               $attribs['title'] = $localLanguageNames[$lang];
+                       }
+
+                       $langDisplay = ( isset( $langNames[$lang] ) ? 
Html::rawElement( 'span', array( 'lang' => htmlspecialchars( $lang ) ), 
$langNames[$lang] ) : '' );
+                       if ( isset( $localLanguageNames[$lang] ) && strlen( 
$localLanguageNames[$lang] ) && $langDisplay != $localLanguageNames[$lang] ) {
+                               $langDisplay .= $this->msg( 'word-separator' 
)->text() .
+                                                $this->msg( 'parentheses', 
$localLanguageNames[$lang] )->text();
+                       }
+                       $s .= '<td>' . $anchor . Html::rawElement( 'strong', 
$attribs, $langDisplay ) . '</td>';
+
+                       foreach ( $matrix->getNames() as $site => $name ) {
+                               $url = $matrix->getUrl( $lang, $site );
+                               if ( $matrix->exist( $lang, $site ) ) {
+                                       # Wiki exists
+                                       $closed = $matrix->isClosed( $lang, 
$site );
+                                       $s .= "<td>" . ( $closed ? "<del>" : '' 
) . "<a href=\"{$url}\">{$lang}</a>" . ( $closed ? "</del>" : '' ) . '</td>';
+                               } else {
+                                       # Non-existent wiki
+                                       $s .= "<td><a href=\"{$url}\" 
class=\"new\">{$lang}</a></td>";
+                               }
+                       }
+                       $s .= "</tr>\n";
+               }
+
+               $language = $this->getLanguage();
+               # Total
+               $totalCount = 0;
+               $s .= '<tr><th rowspan="2"><a id="total" name="total"></a>' . 
$this->msg( 'sitematrix-sitetotal' )->escaped() . '</th>';
+               foreach ( $matrix->getNames() as $site => $name ) {
+                       $url = $matrix->getSiteUrl( $site );
+                       $count = $matrix->getCountPerSite( $site );
+                       $totalCount += $count;
+                       $count = $language->formatNum( $count );
+                       $s .= "<th><a href=\"{$url}\">{$count}</a></th>";
+               }
+               $s .= '</tr>';
+
+               $s .= '<tr>';
+               $noProjects = count( $matrix->getNames() );
+               $totalCount = $language->formatNum( $totalCount );
+               $s .= "<th colspan=\"{$noProjects }\">{$totalCount}</th>";
+               $s .= '</tr>';
+
+               $s .= Xml::closeElement( 'table' ) . "\n";
+
+               # Specials
+               $s .= '<h2 id="mw-sitematrix-others">' . $this->msg( 
'sitematrix-others' )->escaped() . '</h2>';
+
+               $s .= Xml::openElement( 'table', array( 'class' => 'wikitable', 
'id' => 'mw-sitematrix-other-table' ) ) .
+                       "<tr>" .
+                       Xml::element( 'th', null, $this->msg( 
'sitematrix-other-projects' )->text() ) .
+                       "</tr>";
+
+               foreach ( $matrix->getSpecials() as $special ) {
+                       list( $lang, $site ) = $special;
+
+                       // sanity check
+                       if ( !$lang && !$site ) {
+                               continue;
+                       }
+
+                       $langhost = str_replace( '_', '-', $lang );
+                       $url = $matrix->getUrl( $lang, $site );
+
+                       # Handle options
+                       $flags = array();
+                       if ( $matrix->isPrivate( $lang . $site ) ) {
+                               $flags[] = $this->msg( 'sitematrix-private' 
)->escaped();
+                       }
+                       if ( $matrix->isFishbowl( $lang . $site ) ) {
+                               $flags[] = $this->msg( 'sitematrix-fishbowl' 
)->escaped();
+                       }
+                       $flagsStr = implode( ', ', $flags );
+                       if ( $site != 'wiki' ) {
+                               $langhost .= $site;
+                       }
+                       $closed = $matrix->isClosed( $lang, $site );
+                       $s .= '<tr><td>' . ( $closed ? '<del>' : '' ) .
+                               $language->specialList( '<a href="' . $url . 
'/">' . $langhost . "</a>", $flagsStr ) .
+                               ( $closed ? '</del>' : '' ) . "</td></tr>\n";
+               }
+
+               $s .= Xml::closeElement( 'table' ) . "\n";
+
+               $this->getOutput()->addHTML( $s );
+               $this->getOutput()->addWikiMsg( 'sitematrix-total', 
$language->formatNum( $matrix->getCount() ) );
+       }
+}

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ic1e275fec7ba0667a4d51459c871eb8ee13d0f62
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/SiteMatrix
Gerrit-Branch: master
Gerrit-Owner: Reedy <re...@wikimedia.org>
Gerrit-Reviewer: Alex Monk <kren...@gmail.com>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to