r24089 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24088‎ | r24089 | r24090 >
Date:18:22, 14 July 2007
Author:jeluf
Status:old
Tags:
Comment:
Support for METIS counting pixels
Modified paths:
  • /trunk/extensions/METIS (added) (history)
  • /trunk/extensions/METIS/METIS.php (added) (history)
  • /trunk/extensions/METIS/METIS.sql (added) (history)
  • /trunk/extensions/METIS/METIS_load.php (added) (history)
  • /trunk/extensions/METIS/README (added) (history)

Diff [purge]

Index: trunk/extensions/METIS/METIS.sql
@@ -0,0 +1,11 @@
 2+CREATE TABLE /*$wgDBprefix*/metis (
 3+ metis_id int unsigned NOT NULL auto_increment,
 4+
 5+ -- http://vg02.met.vgwort.de/na/d0a9f05e8f900e660f61
 6+ metis_pixel varchar(80) NOT NULL,
 7+ metis_author_pixel varchar(80),
 8+ PRIMARY KEY metis_id (metis_id)
 9+
 10+)
 11+
 12+
Index: trunk/extensions/METIS/METIS_load.php
@@ -0,0 +1,40 @@
 2+<?php
 3+# Copyright (C) 2007 Jens Frank <jeluf@gmx.de>
 4+#
 5+# This program is free software; you can redistribute it and/or modify
 6+# it under the terms of the GNU General Public License as published by
 7+# the Free Software Foundation; either version 2 of the License, or
 8+# (at your option) any later version.
 9+#
 10+# This program is distributed in the hope that it will be useful,
 11+# but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 13+# GNU General Public License for more details.
 14+#
 15+# You should have received a copy of the GNU General Public License along
 16+# with this program; if not, write to the Free Software Foundation, Inc.,
 17+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 18+# http://www.gnu.org/copyleft/gpl.html
 19+
 20+if( defined( 'MEDIAWIKI' ) ) {
 21+ die("This is the METIS extension");
 22+}
 23+
 24+require_once('commandLine.inc');
 25+
 26+echo "Importing METIS keys from <stdin>\n";
 27+$dbw = wfGetDB( DB_MASTER );
 28+
 29+$file = fopen( 'php://stdin', 'rt' );
 30+$n=0;
 31+
 32+while ( $line = fgets( $file ) ) {
 33+ $dbw->insert( 'metis', array( 'metis_pixel' => chop( $line ) ), 'METIS_load' );
 34+ $n++;
 35+ if ( $n % 500 == 0 ) {
 36+ echo "$n\n";
 37+ }
 38+}
 39+
 40+
 41+?>
Index: trunk/extensions/METIS/METIS.php
@@ -0,0 +1,49 @@
 2+<?php
 3+# Copyright (C) 2007 Jens Frank <jeluf@gmx.de>
 4+#
 5+# This program is free software; you can redistribute it and/or modify
 6+# it under the terms of the GNU General Public License as published by
 7+# the Free Software Foundation; either version 2 of the License, or
 8+# (at your option) any later version.
 9+#
 10+# This program is distributed in the hope that it will be useful,
 11+# but WITHOUT ANY WARRANTY; without even the implied warranty of
 12+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 13+# GNU General Public License for more details.
 14+#
 15+# You should have received a copy of the GNU General Public License along
 16+# with this program; if not, write to the Free Software Foundation, Inc.,
 17+# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 18+# http://www.gnu.org/copyleft/gpl.html
 19+
 20+if( !defined( 'MEDIAWIKI' ) ) {
 21+ die("This is the METIS extension");
 22+}
 23+
 24+$wgExtensionFunctions[] = 'efMetis';
 25+$wgExtensionCredits['other'][] = array( 'name' => 'METIS', 'author' => 'Jens Frank' );
 26+
 27+function efMetis() {
 28+ global $wgHooks;
 29+ #$wgHooks['BeforePageDisplay'][] = 'efMetisAddPixel';
 30+ $wgHooks['ArticleViewHeader'][] = 'efMetisAddPixel';
 31+}
 32+
 33+function efMetisAddPixel( &$article ) {
 34+ global $wgTitle, $wgOut;
 35+ /* Only show the pixel for articles in the main namespace */
 36+
 37+ if ( $wgTitle->getNamespace() == NS_MAIN ) {
 38+ $dbr = wfGetDB( DB_SLAVE );
 39+ $pixel = $dbr->selectField( 'metis', 'metis_pixel',
 40+ array( 'metis_id' => $wgTitle->getArticleID() ),
 41+ 'efMetisAddPixel' );
 42+ if ( !is_null( $pixel ) ) {
 43+ $wgOut->addHTML( '<img src="' . $pixel . '" width="1" height="1" alt="">' );
 44+ }
 45+
 46+ }
 47+ return true;
 48+}
 49+
 50+?>
Index: trunk/extensions/METIS/README
@@ -0,0 +1,31 @@
 2+== Introduction ==
 3+
 4+METIS is a project of the German collecting society (collecive rights manager)
 5+"VG Wort". Its purpose is to remunerate authors for the so called "Zweitnutzung",
 6+the printing and copying of texts which is allowed by the German copyright law
 7+for private use.
 8+
 9+See also http://www.vgwort.de/metis.php (German)
 10+
 11+This extension adds the "counting pixel" that's used by METIS to count how
 12+often an article has been read.
 13+
 14+== Installation ==
 15+1) Create the 'metis' table in your database using the metis.sql script in this
 16+ directory
 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
 21+ cat metispixels.txt | php METIS_load.php
 22+ You can repeat this step later to add more pixels.
 23+
 24+4) Add the following to your LocalSettings.php:
 25+
 26+ include( "extensions/METIS/METIS.php" );
 27+
 28+== Configuration ==
 29+There are no config options at the moment
 30+
 31+== Importing Pixels ==
 32+See steps 2) and 3) above.

Status & tagging log