Extension:AmazonAssociates
From MediaWiki.org
| The author of this extension is no longer maintaining it! Meaning any reports for additional features and/or bugfixes will more than likely be ignored. Volunteers are encouraged to take on the task of developing and maintaining it. As a courtesy, you may want to contact the author. You should also remove this template and list yourself as maintaining the extension in the page's {{extension}} infobox. |
| This extension stores its source code on a wiki page. Please be aware that this code may be unreviewed or maliciously altered. They may contain security holes, outdated interfaces that are no longer compatible etc. Note: No localisation updates are provided for this extension by translatewiki.net. |
|
AmazonAssociates Release status: experimental |
|
|---|---|
| Implementation | Tag |
| Description | Allows to display Amazon books using a combination of the Amazon web service and the Amazon Associates program. |
| Author(s) | Bradford Knowlton (Bradmkjrtalk) |
| Database changes | no |
| License | GPL v2+ |
| Download | see below |
| Check usage and version matrix | |
AmazonAssociates is a simple extension to display amazon books using a combination of the Amazon web service and the Amazon Associates program. This is a simple tool developed by User:Bradmkjr for his wiki and he decided to share, use it as a concept and develop it to suit your needs.
Here is the PHP code:
<?php
$wgExtensionFunctions[] = "AmazonAssociates";
// Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
'name' => 'AmazonAssociates',
'author' => 'Bradford Knowlton',
'url' => 'http://www.mediawiki.org/wiki/Extension:AmazonAssociates',
'description' => 'Display Amazon books using a combination of the Amazon web service and the Amazon Associates program.'
);
function AmazonAssociates() {
global $wgParser;
$wgParser->setHook('amazon', 'AmazonAssociate');
}
function AmazonAssociate($input, $argv, $parser) {
global $wgParser;
$wgParser->disableCache(); //ATTENTION; DISABLE THIS LINE IF YOU ARE ON HIGH LOAD!
$isbn = substr($argv['src'],0,strpos($argv['src'],'.'));
$src = $argv['src'];
return "<a href='<nowiki>http://www.amazon.com/gp/redirect.html%3FASIN=$isbn%26tag=<!! AMAZON PARTNER CODE !!>%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/$isbn%253FSubscriptionId=0EMV44A9A5YT1RVDGZ82</nowiki>'
title='View product details at Amazon'><img src='<nowiki>http://ec1.images-amazon.com/images/P/$src</nowiki>' alt='$input' />$input</a>";
}
$wgExtensionFunctions[] = "AmazonAssociates";
// Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
'name' => 'AmazonAssociates',
'author' => 'Bradford Knowlton',
'url' => 'http://www.mediawiki.org/wiki/Extension:AmazonAssociates',
'description' => 'Display Amazon books using a combination of the Amazon web service and the Amazon Associates program.'
);
function AmazonAssociates() {
global $wgParser;
$wgParser->setHook('amazon', 'AmazonAssociate');
}
function AmazonAssociate($input, $argv, $parser) {
global $wgParser;
$wgParser->disableCache(); //ATTENTION; DISABLE THIS LINE IF YOU ARE ON HIGH LOAD!
$isbn = substr($argv['src'],0,strpos($argv['src'],'.'));
$src = $argv['src'];
return "<a href='<nowiki>http://www.amazon.com/gp/redirect.html%3FASIN=$isbn%26tag=<!! AMAZON PARTNER CODE !!>%26lcode=xm2%26cID=2025%26ccmID=165953%26location=/o/ASIN/$isbn%253FSubscriptionId=0EMV44A9A5YT1RVDGZ82</nowiki>'
title='View product details at Amazon'><img src='<nowiki>http://ec1.images-amazon.com/images/P/$src</nowiki>' alt='$input' />$input</a>";
}
Installation [edit]
Save the code as AmazonAssociates.php and upload it into your extension folder.
Then add the following code to your LocalSettings.php
require_once("extensions/AmazonAssociates.php");
Usage [edit]
<amazon src='Image file name'>Book Title</amazon>
For example
<amazon src='0517226952.01._SCTHUMBZZZ_V1108549558_.jpg'>The Ultimate Hitchhiker's Guide (Deluxe Edition)</amazon>
Problems? [edit]
This code is very simple, and really doesn't do much other than output some html, shorten a string, and make it look fancy.