SamanthaNguyen has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/388383 )

Change subject: Split classes into their own files and folder
......................................................................

Split classes into their own files and folder

Classes are now their own file, as well as in the folder `/includes`.

Change-Id: I85bc4564081de310b443897bf97f6db017f834dd
---
A includes/GamepressSkinNavigationService.php
R includes/GamepressTemplate.php
A includes/SkinGamepress.php
M skin.json
4 files changed, 215 insertions(+), 213 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/skins/Gamepress 
refs/changes/83/388383/1

diff --git a/includes/GamepressSkinNavigationService.php 
b/includes/GamepressSkinNavigationService.php
new file mode 100644
index 0000000..132218a
--- /dev/null
+++ b/includes/GamepressSkinNavigationService.php
@@ -0,0 +1,168 @@
+<?php
+
+/**
+ * A fork of Oasis' NavigationService with some changes.
+ * Namely the name was changed and "magic word" handling was removed from
+ * parseMessage() and some (related) unused functions were also removed.
+ */
+class GamepressSkinNavigationService {
+
+       const version = '0.01';
+
+       /**
+        * Parses a system message by exploding along newlines.
+        *
+        * @param $messageName String: name of the MediaWiki message to parse
+        * @param $maxChildrenAtLevel Array:
+        * @param $duration Integer: cache duration for memcached calls
+        * @param $forContent Boolean: is the message we're supposed to parse in
+        *                                                              the 
wiki's content language (true) or not?
+        * @return Array
+        */
+       public function parseMessage( $messageName, $maxChildrenAtLevel = 
array(), $duration, $forContent = false ) {
+               global $wgLang, $wgContLang, $wgMemc;
+
+               $this->forContent = $forContent;
+
+               $useCache = $wgLang->getCode() == $wgContLang->getCode();
+
+               if ( $useCache || $this->forContent ) {
+                       $cacheKey = wfMemcKey( $messageName, self::version );
+                       $nodes = $wgMemc->get( $cacheKey );
+               }
+
+               if ( empty( $nodes ) ) {
+                       if ( $this->forContent ) {
+                               $lines = explode( "\n", wfMessage( $messageName 
)->inContentLanguage()->text() );
+                       } else {
+                               $lines = explode( "\n", wfMessage( $messageName 
)->text() );
+                       }
+                       $nodes = $this->parseLines( $lines, $maxChildrenAtLevel 
);
+
+                       if ( $useCache || $this->forContent ) {
+                               $wgMemc->set( $cacheKey, $nodes, $duration );
+                       }
+               }
+
+               return $nodes;
+       }
+
+       /**
+        * Function used by parseMessage() above.
+        *
+        * @param $lines String: newline-separated lines from the supplied MW: 
msg
+        * @param $maxChildrenAtLevel Array:
+        * @return Array
+        */
+       private function parseLines( $lines, $maxChildrenAtLevel = array() ) {
+               $nodes = array();
+
+               if ( is_array( $lines ) && count( $lines ) > 0 ) {
+                       $lastDepth = 0;
+                       $i = 0;
+                       $lastSkip = null;
+
+                       foreach ( $lines as $line ) {
+                               // we are interested only in lines that are not 
empty and start with asterisk
+                               if ( trim( $line ) != '' && $line{0} == '*' ) {
+                                       $depth = strrpos( $line, '*' ) + 1;
+
+                                       if ( $lastSkip !== null && $depth >= 
$lastSkip ) {
+                                               continue;
+                                       } else {
+                                               $lastSkip = null;
+                                       }
+
+                                       if ( $depth == $lastDepth + 1 ) {
+                                               $parentIndex = $i;
+                                       } elseif ( $depth == $lastDepth ) {
+                                               $parentIndex = 
$nodes[$i]['parentIndex'];
+                                       } else {
+                                               for ( $x = $i; $x >= 0; $x-- ) {
+                                                       if ( $x == 0 ) {
+                                                               $parentIndex = 
0;
+                                                               break;
+                                                       }
+                                                       if ( 
$nodes[$x]['depth'] <= $depth - 1 ) {
+                                                               $parentIndex = 
$x;
+                                                               break;
+                                                       }
+                                               }
+                                       }
+
+                                       if ( isset( $maxChildrenAtLevel[$depth 
- 1] ) ) {
+                                               if ( isset( 
$nodes[$parentIndex]['children'] ) ) {
+                                                       if ( count( 
$nodes[$parentIndex]['children'] ) >= $maxChildrenAtLevel[$depth - 1] ) {
+                                                               $lastSkip = 
$depth;
+                                                               continue;
+                                                       }
+                                               }
+                                       }
+
+                                       $node = $this->parseOneLine( $line );
+                                       $node['parentIndex'] = $parentIndex;
+                                       $node['depth'] = $depth;
+
+                                       
$nodes[$node['parentIndex']]['children'][] = $i + 1;
+                                       $nodes[$i + 1] = $node;
+                                       $lastDepth = $node['depth'];
+                                       $i++;
+                               }
+                       }
+               }
+
+               return $nodes;
+       }
+
+       /**
+        * @param $line String: line to parse
+        * @return Array
+        */
+       private function parseOneLine( $line ) {
+               // trim spaces and asterisks from line and then split it to 
maximum two chunks
+               $lineArr = explode( '|', trim( $line, '* ' ), 2 );
+
+               // trim [ and ] from line to have just http://en.wikipedia.org 
instead of [http://en.wikipedia.org] for external links
+               $lineArr[0] = trim( $lineArr[0], '[]' );
+
+               if ( count( $lineArr ) == 2 && $lineArr[1] != '' ) {
+                       $link = trim( wfMessage( $lineArr[0] 
)->inContentLanguage()->text() );
+                       $desc = trim( $lineArr[1] );
+               } else {
+                       $link = $desc = trim( $lineArr[0] );
+               }
+
+               $text = $this->forContent ? wfMessage( $desc 
)->inContentLanguage() : wfMessage( $desc );
+               if ( $text->isDisabled() ) {
+                       $text = $desc;
+               }
+
+               if ( wfMessage( $lineArr[0] )->isDisabled() ) {
+                       $link = $lineArr[0];
+               }
+
+               if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
+                       $href = $link;
+               } else {
+                       if ( empty( $link ) ) {
+                               $href = '#';
+                       } elseif ( $link{0} == '#' ) {
+                               $href = '#';
+                       } else {
+                               $title = Title::newFromText( $link );
+                               if ( is_object( $title ) ) {
+                                       $href = 
$title->fixSpecialName()->getLocalURL();
+                               } else {
+                                       $href = '#';
+                               }
+                       }
+               }
+
+               return array(
+                       'original' => $lineArr[0],
+                       'text' => $text,
+                       'href' => $href
+               );
+       }
+
+}
\ No newline at end of file
diff --git a/Gamepress.skin.php b/includes/GamepressTemplate.php
similarity index 67%
rename from Gamepress.skin.php
rename to includes/GamepressTemplate.php
index 94e8259..d8bb813 100644
--- a/Gamepress.skin.php
+++ b/includes/GamepressTemplate.php
@@ -9,47 +9,6 @@
  * @see http://wp-themes.com/gamepress/
  */
 
-/**
- * Inherit main code from SkinTemplate, set the CSS and template filter.
- *
- * @ingroup Skins
- */
-class SkinGamepress extends SkinTemplate {
-       public $skinname = 'gamepress', $stylename = 'gamepress',
-               $template = 'GamepressTemplate', $useHeadElement = true;
-
-       /**
-        * Initializes OutputPage and sets up skin-specific parameters
-        *
-        * @param OutputPage $out
-        */
-       public function initPage( OutputPage $out ) {
-               parent::initPage( $out );
-
-               $out->addMeta( 'viewport', 'width=device-width;' );
-       }
-
-       /**
-        * @param $out OutputPage
-        */
-       function setupSkinUserCss( OutputPage $out ) {
-               parent::setupSkinUserCss( $out );
-
-               // Load CSS via ResourceLoader
-               $out->addModuleStyles( array(
-                       'mediawiki.skinning.interface',
-                       'mediawiki.skinning.content.externallinks',
-                       'skins.gamepress'
-               ) );
-
-               // CSS fixes for older Internet Explorers
-               $out->addStyle( 'Gamepress/resources/css/style_ie.css', 
'screen', 'IE' );
-
-               // And JS too!
-               $out->addModuleScripts( 'skins.gamepress' );
-       }
-}
-
 class GamepressTemplate extends BaseTemplate {
        /**
         * Template filter callback for the Gamepress skin.
@@ -429,171 +388,4 @@
        </div>
 <?php
        }
-}
-
-/**
- * A fork of Oasis' NavigationService with some changes.
- * Namely the name was changed and "magic word" handling was removed from
- * parseMessage() and some (related) unused functions were also removed.
- */
-class GamepressSkinNavigationService {
-
-       const version = '0.01';
-
-       /**
-        * Parses a system message by exploding along newlines.
-        *
-        * @param $messageName String: name of the MediaWiki message to parse
-        * @param $maxChildrenAtLevel Array:
-        * @param $duration Integer: cache duration for memcached calls
-        * @param $forContent Boolean: is the message we're supposed to parse in
-        *                                                              the 
wiki's content language (true) or not?
-        * @return Array
-        */
-       public function parseMessage( $messageName, $maxChildrenAtLevel = 
array(), $duration, $forContent = false ) {
-               global $wgLang, $wgContLang, $wgMemc;
-
-               $this->forContent = $forContent;
-
-               $useCache = $wgLang->getCode() == $wgContLang->getCode();
-
-               if ( $useCache || $this->forContent ) {
-                       $cacheKey = wfMemcKey( $messageName, self::version );
-                       $nodes = $wgMemc->get( $cacheKey );
-               }
-
-               if ( empty( $nodes ) ) {
-                       if ( $this->forContent ) {
-                               $lines = explode( "\n", wfMessage( $messageName 
)->inContentLanguage()->text() );
-                       } else {
-                               $lines = explode( "\n", wfMessage( $messageName 
)->text() );
-                       }
-                       $nodes = $this->parseLines( $lines, $maxChildrenAtLevel 
);
-
-                       if ( $useCache || $this->forContent ) {
-                               $wgMemc->set( $cacheKey, $nodes, $duration );
-                       }
-               }
-
-               return $nodes;
-       }
-
-       /**
-        * Function used by parseMessage() above.
-        *
-        * @param $lines String: newline-separated lines from the supplied MW: 
msg
-        * @param $maxChildrenAtLevel Array:
-        * @return Array
-        */
-       private function parseLines( $lines, $maxChildrenAtLevel = array() ) {
-               $nodes = array();
-
-               if ( is_array( $lines ) && count( $lines ) > 0 ) {
-                       $lastDepth = 0;
-                       $i = 0;
-                       $lastSkip = null;
-
-                       foreach ( $lines as $line ) {
-                               // we are interested only in lines that are not 
empty and start with asterisk
-                               if ( trim( $line ) != '' && $line{0} == '*' ) {
-                                       $depth = strrpos( $line, '*' ) + 1;
-
-                                       if ( $lastSkip !== null && $depth >= 
$lastSkip ) {
-                                               continue;
-                                       } else {
-                                               $lastSkip = null;
-                                       }
-
-                                       if ( $depth == $lastDepth + 1 ) {
-                                               $parentIndex = $i;
-                                       } elseif ( $depth == $lastDepth ) {
-                                               $parentIndex = 
$nodes[$i]['parentIndex'];
-                                       } else {
-                                               for ( $x = $i; $x >= 0; $x-- ) {
-                                                       if ( $x == 0 ) {
-                                                               $parentIndex = 
0;
-                                                               break;
-                                                       }
-                                                       if ( 
$nodes[$x]['depth'] <= $depth - 1 ) {
-                                                               $parentIndex = 
$x;
-                                                               break;
-                                                       }
-                                               }
-                                       }
-
-                                       if ( isset( $maxChildrenAtLevel[$depth 
- 1] ) ) {
-                                               if ( isset( 
$nodes[$parentIndex]['children'] ) ) {
-                                                       if ( count( 
$nodes[$parentIndex]['children'] ) >= $maxChildrenAtLevel[$depth - 1] ) {
-                                                               $lastSkip = 
$depth;
-                                                               continue;
-                                                       }
-                                               }
-                                       }
-
-                                       $node = $this->parseOneLine( $line );
-                                       $node['parentIndex'] = $parentIndex;
-                                       $node['depth'] = $depth;
-
-                                       
$nodes[$node['parentIndex']]['children'][] = $i + 1;
-                                       $nodes[$i + 1] = $node;
-                                       $lastDepth = $node['depth'];
-                                       $i++;
-                               }
-                       }
-               }
-
-               return $nodes;
-       }
-
-       /**
-        * @param $line String: line to parse
-        * @return Array
-        */
-       private function parseOneLine( $line ) {
-               // trim spaces and asterisks from line and then split it to 
maximum two chunks
-               $lineArr = explode( '|', trim( $line, '* ' ), 2 );
-
-               // trim [ and ] from line to have just http://en.wikipedia.org 
instead of [http://en.wikipedia.org] for external links
-               $lineArr[0] = trim( $lineArr[0], '[]' );
-
-               if ( count( $lineArr ) == 2 && $lineArr[1] != '' ) {
-                       $link = trim( wfMessage( $lineArr[0] 
)->inContentLanguage()->text() );
-                       $desc = trim( $lineArr[1] );
-               } else {
-                       $link = $desc = trim( $lineArr[0] );
-               }
-
-               $text = $this->forContent ? wfMessage( $desc 
)->inContentLanguage() : wfMessage( $desc );
-               if ( $text->isDisabled() ) {
-                       $text = $desc;
-               }
-
-               if ( wfMessage( $lineArr[0] )->isDisabled() ) {
-                       $link = $lineArr[0];
-               }
-
-               if ( preg_match( '/^(?:' . wfUrlProtocols() . ')/', $link ) ) {
-                       $href = $link;
-               } else {
-                       if ( empty( $link ) ) {
-                               $href = '#';
-                       } elseif ( $link{0} == '#' ) {
-                               $href = '#';
-                       } else {
-                               $title = Title::newFromText( $link );
-                               if ( is_object( $title ) ) {
-                                       $href = 
$title->fixSpecialName()->getLocalURL();
-                               } else {
-                                       $href = '#';
-                               }
-                       }
-               }
-
-               return array(
-                       'original' => $lineArr[0],
-                       'text' => $text,
-                       'href' => $href
-               );
-       }
-
-} // end of the GamepressSkinNavigationService class
+}
\ No newline at end of file
diff --git a/includes/SkinGamepress.php b/includes/SkinGamepress.php
new file mode 100644
index 0000000..6ee3253
--- /dev/null
+++ b/includes/SkinGamepress.php
@@ -0,0 +1,42 @@
+<?php
+
+/**
+ * Inherit main code from SkinTemplate, set the CSS and template filter.
+ *
+ * @ingroup Skins
+ */
+class SkinGamepress extends SkinTemplate {
+       public $skinname = 'gamepress', $stylename = 'gamepress',
+               $template = 'GamepressTemplate', $useHeadElement = true;
+
+       /**
+        * Initializes OutputPage and sets up skin-specific parameters
+        *
+        * @param OutputPage $out
+        */
+       public function initPage( OutputPage $out ) {
+               parent::initPage( $out );
+
+               $out->addMeta( 'viewport', 'width=device-width;' );
+       }
+
+       /**
+        * @param $out OutputPage
+        */
+       function setupSkinUserCss( OutputPage $out ) {
+               parent::setupSkinUserCss( $out );
+
+               // Load CSS via ResourceLoader
+               $out->addModuleStyles( array(
+                       'mediawiki.skinning.interface',
+                       'mediawiki.skinning.content.externallinks',
+                       'skins.gamepress'
+               ) );
+
+               // CSS fixes for older Internet Explorers
+               $out->addStyle( 'Gamepress/resources/css/style_ie.css', 
'screen', 'IE' );
+
+               // And JS too!
+               $out->addModuleScripts( 'skins.gamepress' );
+       }
+}
diff --git a/skin.json b/skin.json
index b1027d8..32e713e 100644
--- a/skin.json
+++ b/skin.json
@@ -1,6 +1,6 @@
 {
        "name": "Gamepress",
-       "version": "1.2.0",
+       "version": "1.2.1",
        "author": [
                "[http://webtuts.pl/themes/ Aleksandra Łączek]",
                "Jack Phoenix",
@@ -23,9 +23,9 @@
                "gamepress": [ "blue", "green", "orange" ]
        },
        "AutoloadClasses": {
-               "SkinGamepress": "Gamepress.skin.php",
-               "GamepressTemplate": "Gamepress.skin.php",
-               "GamepressSkinNavigationService": "Gamepress.skin.php"
+               "SkinGamepress": "includes/SkinGamepress.php",
+               "GamepressTemplate": "includes/GamepressTemplate.php",
+               "GamepressSkinNavigationService": 
"includes/GamepressSkinNavigationService.php"
        },
        "ResourceFileModulePaths": {
                "localBasePath": "",

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I85bc4564081de310b443897bf97f6db017f834dd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/skins/Gamepress
Gerrit-Branch: master
Gerrit-Owner: SamanthaNguyen <samanthanguyen1...@gmail.com>

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

Reply via email to