[MediaWiki-commits] [Gerrit] Version 0.6.1 from ShoutWiki - change (mediawiki...SoftwareVersion)
Jack Phoenix has submitted this change and it was merged. Change subject: Version 0.6.1 from ShoutWiki .. Version 0.6.1 from ShoutWiki The PHP entry point is no more, use wfLoadExtension( 'SoftwareVersion' ) instead Change-Id: I1fad3a8586e7506e649c73a5490eaad3c5082581 --- A ShoutWikiSoftwareVersion.class.php D SoftwareVersion.php A extension.json 3 files changed, 81 insertions(+), 70 deletions(-) Approvals: Jack Phoenix: Verified; Looks good to me, approved diff --git a/ShoutWikiSoftwareVersion.class.php b/ShoutWikiSoftwareVersion.class.php new file mode 100644 index 000..60a6c90 --- /dev/null +++ b/ShoutWikiSoftwareVersion.class.php @@ -0,0 +1,61 @@ + + * @copyright Copyright © 2009-2016 Jack Phoenix + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +class ShoutWikiSoftwareVersion { + + /** +* Adds ShoutWiki component into Special:Version and sets MW's version to $wgVersion +* +* @param array $software Array of software information +* @return bool +*/ + public static function addShoutWikiInfo( &$software ) { + global $wgVersion, $IP; + + // Set MW version to $wgVersion + $software['[https://www.mediawiki.org/ MediaWiki]'] = $wgVersion; + + // This is ugly, or at least uglier than in the past, because it wouldn't + // work anymore on my local machine. + // First, we do a "svn info $IP", then JSON-encode the result, and explode + // along newlines and use PHP's array access to access the revision number + // and last changed date, which will be added to the version table. + // + // Why is this so ugly? Because svn info returns a string, instead of a + // sane array that we could easily manipulate. + // + // We also strip out the English words from the svn info output, so the + // final output that an end-user viewing Special:Version sees is something + // like "r1811 (2012-05-16 00:31:45 +0300)". + if ( !wfIsWindows() ) { + $svnInfo = wfShellExec( '/usr/bin/svn info ' . $IP, $error ); + $newline = "\n"; + } else { + // why yes, I'm hardcoding my TortoiseSVN's installation path here + $svnInfo = wfShellExec( '"C:\Program Files\TortoiseSVN\bin\svn.exe" info ' . $IP, $error ); + $newline = "\r\n"; + } + + $json = json_encode( $svnInfo ); + $exploded = explode( $newline, $svnInfo ); + + // Add ShoutWiki component (revision number and last changed date) + $software['[http://www.shoutwiki.com/ ShoutWiki]'] = + str_replace( 'Revision: ', 'r', $exploded[6] ) /* Revision */ . + ' (' . + str_replace( 'Last Changed Date: ', '', preg_replace( '/ \(.*\)/', '', $exploded[11] ) ) ./* Last Changed Date */ + ')'; + + return true; + } + +} \ No newline at end of file diff --git a/SoftwareVersion.php b/SoftwareVersion.php deleted file mode 100644 index 6e21fbb..000 --- a/SoftwareVersion.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Copyright © 2009-2010 Jack Phoenix - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later - */ - -if ( !defined( 'MEDIAWIKI' ) ) { - die( "This is not a valid entry point.\n" ); -} - -// Extension credits that will show up on Special:Version -$wgExtensionCredits['other'][] = array( - 'name' => 'SoftwareVersion', - 'author' => 'Jack Phoenix', - 'version' => '0.4', - 'url' => 'https://www.mediawiki.org/wiki/Extension:SoftwareVersion', - 'description' => 'Customizes [[Special:Version]] for ShoutWiki', -); - -// Our hooked function -$wgHooks['SoftwareInfo'][] = 'efAddShoutWikiInfo'; - -/** - * Adds ShoutWiki component into Special:Version and sets MW's version to $wgVersion - * - * @param $software Array: array of software information - * @return Boolean: true - */ -function efAddShoutWikiInfo( &$software ) { - global $wgVersion, $IP; - - // Set MW version to $wgVersion - $software['[http://www.mediawiki.org/ MediaWiki]'] = $wgVersion; - - // Add ShoutWiki component (release branch name) and its revision number - $software['[http://www.shoutwiki.com/ ShoutWiki]'] = efGetSvnURL( $IP ) . ' (r' . SpecialVersion::getSvnRevision( $IP ) . ')'; - - return true; -} - -// Gets the name of the release for Special:Version's "ShoutWiki" column -// Copied from Wikia's SpecialVersion.php and modified -function efGetSvnURL( $dir ) { - //
[MediaWiki-commits] [Gerrit] Version 0.6.1 from ShoutWiki - change (mediawiki...SoftwareVersion)
Jack Phoenix has uploaded a new change for review. https://gerrit.wikimedia.org/r/295371 Change subject: Version 0.6.1 from ShoutWiki .. Version 0.6.1 from ShoutWiki The PHP entry point is no more, use wfLoadExtension( 'SoftwareVersion' ) instead Change-Id: I1fad3a8586e7506e649c73a5490eaad3c5082581 --- A ShoutWikiSoftwareVersion.class.php D SoftwareVersion.php A extension.json 3 files changed, 81 insertions(+), 70 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SoftwareVersion refs/changes/71/295371/1 diff --git a/ShoutWikiSoftwareVersion.class.php b/ShoutWikiSoftwareVersion.class.php new file mode 100644 index 000..60a6c90 --- /dev/null +++ b/ShoutWikiSoftwareVersion.class.php @@ -0,0 +1,61 @@ + + * @copyright Copyright © 2009-2016 Jack Phoenix + * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later + */ + +class ShoutWikiSoftwareVersion { + + /** +* Adds ShoutWiki component into Special:Version and sets MW's version to $wgVersion +* +* @param array $software Array of software information +* @return bool +*/ + public static function addShoutWikiInfo( &$software ) { + global $wgVersion, $IP; + + // Set MW version to $wgVersion + $software['[https://www.mediawiki.org/ MediaWiki]'] = $wgVersion; + + // This is ugly, or at least uglier than in the past, because it wouldn't + // work anymore on my local machine. + // First, we do a "svn info $IP", then JSON-encode the result, and explode + // along newlines and use PHP's array access to access the revision number + // and last changed date, which will be added to the version table. + // + // Why is this so ugly? Because svn info returns a string, instead of a + // sane array that we could easily manipulate. + // + // We also strip out the English words from the svn info output, so the + // final output that an end-user viewing Special:Version sees is something + // like "r1811 (2012-05-16 00:31:45 +0300)". + if ( !wfIsWindows() ) { + $svnInfo = wfShellExec( '/usr/bin/svn info ' . $IP, $error ); + $newline = "\n"; + } else { + // why yes, I'm hardcoding my TortoiseSVN's installation path here + $svnInfo = wfShellExec( '"C:\Program Files\TortoiseSVN\bin\svn.exe" info ' . $IP, $error ); + $newline = "\r\n"; + } + + $json = json_encode( $svnInfo ); + $exploded = explode( $newline, $svnInfo ); + + // Add ShoutWiki component (revision number and last changed date) + $software['[http://www.shoutwiki.com/ ShoutWiki]'] = + str_replace( 'Revision: ', 'r', $exploded[6] ) /* Revision */ . + ' (' . + str_replace( 'Last Changed Date: ', '', preg_replace( '/ \(.*\)/', '', $exploded[11] ) ) ./* Last Changed Date */ + ')'; + + return true; + } + +} \ No newline at end of file diff --git a/SoftwareVersion.php b/SoftwareVersion.php deleted file mode 100644 index 6e21fbb..000 --- a/SoftwareVersion.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @copyright Copyright © 2009-2010 Jack Phoenix - * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later - */ - -if ( !defined( 'MEDIAWIKI' ) ) { - die( "This is not a valid entry point.\n" ); -} - -// Extension credits that will show up on Special:Version -$wgExtensionCredits['other'][] = array( - 'name' => 'SoftwareVersion', - 'author' => 'Jack Phoenix', - 'version' => '0.4', - 'url' => 'https://www.mediawiki.org/wiki/Extension:SoftwareVersion', - 'description' => 'Customizes [[Special:Version]] for ShoutWiki', -); - -// Our hooked function -$wgHooks['SoftwareInfo'][] = 'efAddShoutWikiInfo'; - -/** - * Adds ShoutWiki component into Special:Version and sets MW's version to $wgVersion - * - * @param $software Array: array of software information - * @return Boolean: true - */ -function efAddShoutWikiInfo( &$software ) { - global $wgVersion, $IP; - - // Set MW version to $wgVersion - $software['[http://www.mediawiki.org/ MediaWiki]'] = $wgVersion; - - // Add ShoutWiki component (release branch name) and its revision number - $software['[http://www.shoutwiki.com/ ShoutWiki]'] = efGetSvnURL( $IP ) . ' (r' . SpecialVersion::getSvnRevision( $IP ) . ')'; - - return true; -} - -// Gets the name of the release for Special:Version's "ShoutWiki" column -// Copied from Wikia's SpecialVersion.php and modified -function