https://opentutorial.com/api.php?action=feedcontributions&user=Ipbwiki&feedformat=atomOpenTutorial - User contributions [en]2024-03-29T09:20:09ZUser contributionsMediaWiki 1.32.0https://opentutorial.com/index.php?title=Create_paypal_buttons_for_mediawiki&diff=2330Create paypal buttons for mediawiki2006-06-03T15:34:17Z<p>Ipbwiki: fixing link</p>
<hr />
<div>= How to Create a PayPal Buttons Extension for Mediawiki = <br />
<br />
IpbWiki Paypal is a Mediawiki Extension which adds a new <nowiki><paypal></nowiki> tag which allows you to add a paypal button to your wiki pages.<br />
<br />
= Download Extension =<br />
<br />
[http://www.ipbwiki.com/forums/index.php?download=1 Download the file IpbWiki_Paypal.php] (Click on the download button on the bottom of the next screen)<br />
<br />
= Code for file IpbWiki_Paypal.php =<br />
<br />
If you have problems downloading the above file, then alternatively you can just copy and paste the below code and place it in a file named "IpbWiki_Paypal.php".<br />
<pre><br />
<nowiki><br />
<?php<br />
/* IpbWiki Paypal WikiMedia extension <br />
** IpbWiki (c) 2006<br />
** Installation Instructions: http://www.ipbwiki.com/IpbWiki_Paypal_Extension<br />
*/<br />
<br />
$wgExtensionFunctions[] = "wfPayPalExtension";<br />
<br />
function wfPayPalExtension() {<br />
global $wgParser;<br />
global $ipbwiki_paypal;<br />
# register the extension with the WikiText parser<br />
$wgParser->setHook( "paypal", "renderPayPal" );<br />
<br />
$ipbwiki_paypal = array();<br />
# CHANGE THE LINES BELOW TO REFLECT TO YOUR PAYPAL BUTTONS!!! (there's no limit on the number of buttons you define)<br />
$ipbwiki_paypal[1] = '<form action="https://www.paypal.com/cgi-bin/webscr" method="post"><input type="hidden" name="cmd" value="_xclick"><input type="hidden" name="business" value="ipbwiki@gmail.com"><input type="hidden" name="item_name" value="IpbWiki PayPal"><input type="hidden" name="no_shipping" value="1"><input type="hidden" name="cn" value="Optional Comments"><input type="hidden" name="currency_code" value="EUR"><input type="hidden" name="tax" value="0"><input type="hidden" name="bn" value="PP-DonationsBF"><input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it\'s fast, free and secure!"></form>';<br />
$ipbwiki_paypal[2] = '<form action="https://... - it\'s fast, free and secure!"></form>'<br />
}<br />
<br />
# The callback function for converting the input text to HTML output<br />
function renderPayPal( $input, $argv ) {<br />
global $ipbwiki_paypal;<br />
global $wgAuth;<br />
$pos_space=strpos($input,' ');<br />
if (!$pos_space) {<br />
if (is_numeric($input)) { // format <paypal>number</paypal><br />
$part1 = $input;<br />
$part2 = '';<br />
if (!$ipbwiki_paypal[$part1]) {<br />
print_r ('warning, specified paypal button not found, defaulting to button 1');<br />
$part1 = 1;<br />
$part2 = $input;<br />
}<br />
} else { // format <paypal>text</paypal> & format <paypal></paypal><br />
$part1 = 1;<br />
$part2 = $input;<br />
}<br />
} else { // format <paypal>number text</paypal><br />
$part1=substr($input,0,$pos_space);<br />
$part2=substr($input,$pos_space+1);<br />
if (is_numeric($part1)) {<br />
if (!$ipbwiki_paypal[$part1]) {<br />
print_r ('warning, specified paypal button not found, defaulting to button 1');<br />
$part1 = 1;<br />
}<br />
} else { // format <paypal>text</paypal><br />
$part1 = 1;<br />
$part2 = $input;<br />
}<br />
}<br />
$form=$ipbwiki_paypal[$part1];<br />
// if the ipbwiki interface is available, then use the clean function which is defined there, otherwise just clean the necessities...<br />
if (class_exists ('ipbwiki')) {<br />
$input = $wgAuth->ipbwiki->ipbwiki->clean_value ($part2);<br />
} else { <br />
$part2 = str_replace( ">" , "&gt;" , $part2 );<br />
$part2 = str_replace( "<" , "&lt;" , $part2 );<br />
$part2 = str_replace( "\"" , "&quot;" , $part2 );<br />
$part2 = str_replace( "!" , "&#33;" , $part2 );<br />
$part2 = str_replace( "'" , "&#39;" , $part2 ); <br />
$input = $part2; <br />
}<br />
$output = '<table border=0><tr><td>'.$form.'</td><td valign=center>'.$input.'</td></tr></table>';<br />
return $output;<br />
}<br />
?><br />
<br />
</nowiki><br />
</pre><br />
<br />
{{adsense2}}<br />
<br />
= !!WARNING!! =<br />
If the text that you place between the single quotes in the $ipbwiki_paypal[1] variable has any single quotes in it then you mist escape them otherwise IT WILL NOT WORK.<br />
<br />
Example:<br />
*<pre>$ipbwiki_paypal[2] = '<form action="https://... - it\'s fast, free and secure!"></form>'</pre><br />
** works just fine<br />
*<pre>$ipbwiki_paypal[2] = '<form action="https://... - it's fast, free and secure!"></form>'</pre><br />
** will crash your wiki<br />
<br />
<br />
<br />
= Installation =<br />
* create a directory ipbwiki in the extensions directory<br />
* place IpbWiki_PayPal.php in the extensions/ipbwiki directory (see code below)<br />
* open the file LocalSettings.php, search for:<br />
?><br />
and change this to:<br />
require_once('extensions/ipbwiki/IpbWiki_PayPal.php'); // IpbWiki PayPal Extension<br><br />
?><br />
* in the function wfPayPalExtension, place the code for your paypal-buttons in the variable $ipbwiki_paypal.<br />
<br />
= Usage =<br />
* the tag <nowiki><paypal></nowiki> is translated to the button defined in $ipbwiki_paypal[1].<br />
* the tag <nowiki><paypal>2</paypal></nowiki> is translated to the button defined in $ipbwiki_paypal[2].<br />
* the tag <nowiki><paypal>2 description</paypal></nowiki> is translated to the button defined in $ipbwiki_paypal[2], additionaly the text 'description' is placed next to the paypal button.<br />
* the tag <nowiki><paypal>description</paypal></nowiki> is translated to the button defined in $ipbwiki_paypal[1], additionaly the text 'description' is placed next to the paypal button.<br />
<br />
= Donate =<br />
<table><br />
<tr><br />
<td>If you find this extension usefull, then perhaps you can donate a few bucks? ;)</td><br />
<td>Donate to the original author [http://www.ipbwiki.com/IpbWiki_Paypal_Extension here]</td><br />
</tr><br />
</table><br />
<br />
<br />
{{origin|originurl=http://www.ipbwiki.com/IpbWiki_Paypal_Extension}}<br />
<br />
[[category:software]]<br />
[[category:mediawiki]]</div>Ipbwiki