Extensions PayPal

From Triangle Wiki

Jump to: navigation, search

Contents

Introduction

This extension can be used to create a PayPal Donation button within your Wiki articles. It will create a PayPal button, which takes users to the PayPal Donation Site. Example:

Usage

Make the PayPal donation button visible by adding the following Tags to your Wiki article.

<paypal></paypal>

Installation

Create a new file in your extensions folder, called "PayPalDonation.php" with the following content:

PayPalDonation.php Source Code


<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */

/**
 * PayPal Donation WikiMedia extension.
 *
 * Firstly create a file called PayPalDonation.php and
 * place this in the extensions directory - copy all this
 * code to that file. To activate the extension, include
 * it from your LocalSettings.php with:
 * require_once 'extensions/PayPalDonation.php';
 *
 * PHP versions 5
 *
 * LICENSE: This source file is subject to version 3.0 of the
 * PHP license that is available through the world-wide-web at
 * the following URI: http://www.php.net/license/3_0.txt.
 * If you did not receive a copy of the PHP License and are
 * unable to obtain it through the web, please send a note to
 * license@php.net so we can mail you a copy immediately.
 *
 * @category   Wiki
 * @package    payPalDonation
 * @author     Ian Warner
 * @copyright  2006 Triangle Solutions Ltd
 * @license    http://www.php.net/license/3_0.txt PHP License 3.0
 * @version    SVN: $Id: $
 * @link       http://www.triangle-solutions.com/
 */

/*
 * @todo Document
 */
$wgExtensionFunctions[] = 'wfPayPalDonation';

/*
 * Extension credits
 */
$wgExtensionCredits['parserhook'][] = array(
  'name' => 'PayPal Donation',
  'description' => 'PayPal Donation Extension',
  'url' =>
   'http://wiki.triangle-solutions.com/index.php/Extensions',
  'author' => 'Triangle Solutions Ltd',
  'version' => '1.0.1');

/**
 * @todo Document
 */
function wfPayPalDonation()
{
    global $wgParser;
    $wgParser->setHook('paypal', 'renderPayPalDonation');
}

/**
 * The callback function for converting the input to HTML output
 *
 * @param string $input
 */
function renderPayPalDonation($input = null)
{
    $output  = '<br />' . $input;
    $output .= '<form action="https://www.paypal.com/cgi-bin/webscr"
                method="post">';
    $output .= '<input type="hidden" name="cmd"
      value="_xclick" />';
    $output .= '<input type="hidden" name="business"
      value="iwarner@triangle-solutions.com" />';
    $output .= '<input type="hidden" name="item_name"
      value="wikiTriangleSolutions" />';
    $output .= '<input type="hidden" name="item_number"
      value="wiki101" />';
    $output .= '<input type="hidden" name="no_shipping"
      value="1" />';
    $output .= '<input type="hidden" name="currency_code"
      value="GBP" />';
    $output .= '<input type="hidden" name="tax"
      value="0" />';
    $output .= '<input type="hidden" name="bn"
      value="PP-DonationsBF" />';
    $output .= '<input type="image"
      src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif"
      border="0" name="submit" alt="PayPal Donation" />';
    $output .= '<img alt="" border="0"
      src="https://www.paypal.com/en_GB/i/scr/pixel.gif"
      width="1" height="1" />';
    $output .= '</form>';
    return $output;
}
?>

External Links


Personal tools