Difference between revisions of "Extension:Download"
m (New page: please see talk page) |
(make a start) |
||
Line 1: | Line 1: | ||
− | + | <?php | |
+ | /** | ||
+ | * Download extension - Provides a tag which renders a list of image titles as downloadable links | ||
+ | *{{Category:Extensions|Download}}{{php}}{{Category:Extensions created with Template:Extension}} | ||
+ | * See http://www.organicdesign.co.nz/Extension:Download for installation and usage details | ||
+ | * | ||
+ | * @package MediaWiki | ||
+ | * @subpackage Extensions | ||
+ | * @author [http://www.mediawiki.org/wiki/User:Nad User:Nad] | ||
+ | * @licence GNU General Public Licence 2.0 or later | ||
+ | */ | ||
+ | if (!defined('MEDIAWIKI')) die('Not an entry point.'); | ||
+ | |||
+ | define('DOWNLOAD_VERSION', '1.0.0, 2008-08-22'); | ||
+ | |||
+ | $egDownloadTag = "download"; | ||
+ | $egDownloadImages = dirname(__FILE__)."/images"; | ||
+ | $wgExtensionFunctions[] = 'efSetupDownload'; | ||
+ | |||
+ | $wgExtensionCredits['parserhook'][] = array( | ||
+ | 'name' => 'Download', | ||
+ | 'author' => '[http://www.mediawiki.org/wiki/User:Nad User:Nad]', | ||
+ | 'description' => 'Provides a tag which renders a list of image titles as downloadable links', | ||
+ | 'url' => 'http://www.organicdesign.co.nz/Extension:Download', | ||
+ | 'version' => DOWNLOAD_VERSION | ||
+ | ); | ||
+ | |||
+ | class Download { | ||
+ | |||
+ | function __construct() { | ||
+ | global $wgParser, $egDownloadTag; | ||
+ | $wgParser->setHook($egDownloadTag, array($this, 'tagDownload')); | ||
+ | } | ||
+ | |||
+ | function tagDownload($text,$argv,&$parser) { | ||
+ | global $egDownloadTag; | ||
+ | $args = ''; | ||
+ | foreach ($argv as $k => $v) { | ||
+ | $k = htmlspecialchars($k); | ||
+ | $v = htmlspecialchars($v); | ||
+ | $args .= "<li><b>$k:</b> <i>$v</i></li>\n"; | ||
+ | } | ||
+ | $text = htmlspecialchars($text); | ||
+ | return "<h3>Tag $egDownloadTag():</h3>\n<ul>$args<li>Content:</b>$text</ul>\n"; | ||
+ | } | ||
+ | } | ||
+ | |||
+ | function efSetupDownload() { | ||
+ | global $egDownload; | ||
+ | $egDownload = new Download(); | ||
+ | } |
Revision as of 21:31, 21 August 2008
<?php /**
* Download extension - Provides a tag which renders a list of image titles as downloadable links *
Template:PhpCategory:Extensions created with Template:Extension
* See http://www.organicdesign.co.nz/Extension:Download for installation and usage details * * @package MediaWiki * @subpackage Extensions * @author User:Nad * @licence GNU General Public Licence 2.0 or later */
if (!defined('MEDIAWIKI')) die('Not an entry point.');
define('DOWNLOAD_VERSION', '1.0.0, 2008-08-22');
$egDownloadTag = "download"; $egDownloadImages = dirname(__FILE__)."/images"; $wgExtensionFunctions[] = 'efSetupDownload';
$wgExtensionCredits['parserhook'][] = array( 'name' => 'Download', 'author' => 'User:Nad', 'description' => 'Provides a tag which renders a list of image titles as downloadable links', 'url' => 'http://www.organicdesign.co.nz/Extension:Download', 'version' => DOWNLOAD_VERSION );
class Download {
function __construct() { global $wgParser, $egDownloadTag;
$wgParser->setHook($egDownloadTag, array($this, 'tagDownload')); }
function tagDownload($text,$argv,&$parser) { global $egDownloadTag; $args = ; foreach ($argv as $k => $v) { $k = htmlspecialchars($k); $v = htmlspecialchars($v);
$args .= "
\n";
} $text = htmlspecialchars($text);
return "
Tag $egDownloadTag():
\n
- $args
- Content:$text
\n";
}
}
function efSetupDownload() { global $egDownload; $egDownload = new Download(); }