Index: trunk/extensions/METIS/METIS.sql |
— | — | @@ -6,6 +6,6 @@ |
7 | 7 | metis_author_pixel varchar(80), |
8 | 8 | PRIMARY KEY metis_id (metis_id) |
9 | 9 | |
10 | | -) |
| 10 | +); |
11 | 11 | |
12 | 12 | |
Index: trunk/extensions/METIS/METIS_load.php |
— | — | @@ -20,8 +20,12 @@ |
21 | 21 | die("This is the METIS extension"); |
22 | 22 | } |
23 | 23 | |
24 | | -require_once('commandLine.inc'); |
| 24 | +$IP = getenv( 'MW_INSTALL_PATH' ); |
| 25 | +if ( $IP === false ) |
| 26 | + $IP = dirname( __FILE__ ) . '/../..'; |
25 | 27 | |
| 28 | +require_once( "$IP/maintenance/commandLine.inc" ); |
| 29 | + |
26 | 30 | echo "Importing METIS keys from <stdin>\n"; |
27 | 31 | $dbw = wfGetDB( DB_MASTER ); |
28 | 32 | |
— | — | @@ -36,5 +40,3 @@ |
37 | 41 | } |
38 | 42 | } |
39 | 43 | |
40 | | - |
41 | | -?> |
Index: trunk/extensions/METIS/METIS.php |
— | — | @@ -20,24 +20,28 @@ |
21 | 21 | die("This is the METIS extension"); |
22 | 22 | } |
23 | 23 | |
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 | +); |
26 | 30 | |
27 | | -function efMetis() { |
28 | | - global $wgHooks; |
29 | | - #$wgHooks['BeforePageDisplay'][] = 'efMetisAddPixel'; |
30 | | - $wgHooks['ArticleViewHeader'][] = 'efMetisAddPixel'; |
31 | | -} |
| 31 | +#$wgHooks['BeforePageDisplay'][] = 'efMetisAddPixel'; |
| 32 | +$wgHooks['ArticleViewHeader'][] = 'efMetisAddPixel'; |
32 | 33 | |
| 34 | +$wgHooks['LoadExtensionSchemaUpdates'][] = 'efMetisSchemaUpdate'; |
| 35 | + |
33 | 36 | function efMetisAddPixel( &$article ) { |
34 | | - global $wgTitle, $wgOut; |
| 37 | + global $wgOut; |
35 | 38 | /* Only show the pixel for articles in the main namespace */ |
36 | 39 | |
37 | | - if ( $wgTitle->getNamespace() == NS_MAIN ) { |
| 40 | + $title = $article->getTitle(); |
| 41 | + if ( $title->getNamespace() == NS_MAIN ) { |
38 | 42 | $dbr = wfGetDB( DB_SLAVE ); |
39 | 43 | $pixel = $dbr->selectField( 'metis', 'metis_pixel', |
40 | | - array( 'metis_id' => $wgTitle->getArticleID() ), |
41 | | - 'efMetisAddPixel' ); |
| 44 | + array( 'metis_id' => $title->getArticleID() ), |
| 45 | + __FUNCTION__ ); |
42 | 46 | if ( !is_null( $pixel ) ) { |
43 | 47 | $wgOut->addHTML( '<img src="' . $pixel . '" width="1" height="1" alt="">' ); |
44 | 48 | } |
— | — | @@ -46,4 +50,13 @@ |
47 | 51 | return true; |
48 | 52 | } |
49 | 53 | |
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 @@ |
15 | 15 | 1) Create the 'metis' table in your database using the metis.sql script in this |
16 | 16 | directory |
17 | 17 | |
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 |
21 | 19 | cat metispixels.txt | php METIS_load.php |
22 | 20 | You can repeat this step later to add more pixels. |
23 | 21 | |
24 | | -4) Add the following to your LocalSettings.php: |
| 22 | +3) Add the following to your LocalSettings.php: |
25 | 23 | |
26 | 24 | include( "extensions/METIS/METIS.php" ); |
27 | 25 | |
— | — | @@ -28,4 +26,4 @@ |
29 | 27 | There are no config options at the moment |
30 | 28 | |
31 | 29 | == Importing Pixels == |
32 | | -See steps 2) and 3) above. |
| 30 | +See step 2) above. |