r60560 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60559‎ | r60560 | r60561 >
Date:15:22, 2 January 2010
Author:ialex
Status:deferred
Tags:
Comment:
* removed ?>
* added 'path' and 'description' items to extension's credits
* apply schema change in update.php (only tested with mysql)
* allow METIS_load.php to work without having to be copied to the maintenance directory
* use $article->getTitle() rather than $wgTitle in efMetisAddPixel()
Modified paths:
  • /trunk/extensions/METIS/METIS.php (modified) (history)
  • /trunk/extensions/METIS/METIS.sql (modified) (history)
  • /trunk/extensions/METIS/METIS_load.php (modified) (history)
  • /trunk/extensions/METIS/README (modified) (history)

Diff [purge]

Index: trunk/extensions/METIS/METIS.sql
@@ -6,6 +6,6 @@
77 metis_author_pixel varchar(80),
88 PRIMARY KEY metis_id (metis_id)
99
10 -)
 10+);
1111
1212
Index: trunk/extensions/METIS/METIS_load.php
@@ -20,8 +20,12 @@
2121 die("This is the METIS extension");
2222 }
2323
24 -require_once('commandLine.inc');
 24+$IP = getenv( 'MW_INSTALL_PATH' );
 25+if ( $IP === false )
 26+ $IP = dirname( __FILE__ ) . '/../..';
2527
 28+require_once( "$IP/maintenance/commandLine.inc" );
 29+
2630 echo "Importing METIS keys from <stdin>\n";
2731 $dbw = wfGetDB( DB_MASTER );
2832
@@ -36,5 +40,3 @@
3741 }
3842 }
3943
40 -
41 -?>
Index: trunk/extensions/METIS/METIS.php
@@ -20,24 +20,28 @@
2121 die("This is the METIS extension");
2222 }
2323
24 -$wgExtensionFunctions[] = 'efMetis';
25 -$wgExtensionCredits['other'][] = array( 'name' => 'METIS', 'author' => 'Jens Frank' );
 24+$wgExtensionCredits['other'][] = array(
 25+ 'name' => 'METIS',
 26+ 'path' => __FILE__,
 27+ 'author' => 'Jens Frank',
 28+ 'description' => 'Add support for METIS counting pixels',
 29+);
2630
27 -function efMetis() {
28 - global $wgHooks;
29 - #$wgHooks['BeforePageDisplay'][] = 'efMetisAddPixel';
30 - $wgHooks['ArticleViewHeader'][] = 'efMetisAddPixel';
31 -}
 31+#$wgHooks['BeforePageDisplay'][] = 'efMetisAddPixel';
 32+$wgHooks['ArticleViewHeader'][] = 'efMetisAddPixel';
3233
 34+$wgHooks['LoadExtensionSchemaUpdates'][] = 'efMetisSchemaUpdate';
 35+
3336 function efMetisAddPixel( &$article ) {
34 - global $wgTitle, $wgOut;
 37+ global $wgOut;
3538 /* Only show the pixel for articles in the main namespace */
3639
37 - if ( $wgTitle->getNamespace() == NS_MAIN ) {
 40+ $title = $article->getTitle();
 41+ if ( $title->getNamespace() == NS_MAIN ) {
3842 $dbr = wfGetDB( DB_SLAVE );
3943 $pixel = $dbr->selectField( 'metis', 'metis_pixel',
40 - array( 'metis_id' => $wgTitle->getArticleID() ),
41 - 'efMetisAddPixel' );
 44+ array( 'metis_id' => $title->getArticleID() ),
 45+ __FUNCTION__ );
4246 if ( !is_null( $pixel ) ) {
4347 $wgOut->addHTML( '<img src="' . $pixel . '" width="1" height="1" alt="">' );
4448 }
@@ -46,4 +50,13 @@
4751 return true;
4852 }
4953
50 -?>
 54+function efMetisSchemaUpdate() {
 55+ global $wgDBtype, $wgExtNewTables;
 56+
 57+ if ( $wgDBtype == 'mysql' ) {
 58+ $wgExtNewTables[] = array( 'metis', dirname( __FILE__ ) . '/METIS.sql' );
 59+ } elseif( $wgDBtype == 'postgres' ) {
 60+ $wgExtNewTables[] = array( 'metis', dirname( __FILE__ ) . '/METIS.pg.sql' );
 61+ }
 62+ return true;
 63+}
Index: trunk/extensions/METIS/README
@@ -14,13 +14,11 @@
1515 1) Create the 'metis' table in your database using the metis.sql script in this
1616 directory
1717
18 -2) Copy the script METIS_load.php to MediaWiki's 'maintenance' directory
19 -
20 -3) Load METIS pixels into your database, e.g. by using
 18+2) Load METIS pixels into your database, e.g. by using
2119 cat metispixels.txt | php METIS_load.php
2220 You can repeat this step later to add more pixels.
2321
24 -4) Add the following to your LocalSettings.php:
 22+3) Add the following to your LocalSettings.php:
2523
2624 include( "extensions/METIS/METIS.php" );
2725
@@ -28,4 +26,4 @@
2927 There are no config options at the moment
3028
3129 == Importing Pixels ==
32 -See steps 2) and 3) above.
 30+See step 2) above.

Status & tagging log