扩展:Colorize
此扩展在wiki页面上存储其源代码。 请注意此代码可能未审核,或被恶意修改。 其可能包含安全漏洞,不再兼容的过时界面等等。 注意: translatewiki.net 不提供此扩展的本地化更新。 |
此扩展目前不再活跃维护! 尽管它可能仍然工作,但任何错误报告或功能请求将很可能被忽略。 |
Colorize 发布状态: 未维护 |
|
---|---|
实现 | 标签 |
描述 | 使文字看起来更有趣 |
作者 | Javier Valcarce García (javier.{NOSPAM}valcarce @gmail.com) |
最新版本 | 0.2 (2013-04-05) |
MediaWiki | 1.15+ |
许可协议 | 未指定许可协议 |
下载 | 见下面的代码 |
Colorize扩展允许为<colorize>和</colorize>标签之间的文本着色,以使其看起来更有趣。
安装
- Copy the code below into a file called "Colorize.php"文件,并将其放置在您
extensions/
文件夹中的Colorize
目录内。 - 将下列代码放置在您的LocalSettings.php的底部:
require_once "$IP/extensions/Colorize/Colorize.php";
完成 – 在您的wiki上导航至Special:Version,以验证扩展已成功安装。
代码
- Colorize.php
<?php
$wgExtensionFunctions[] = "wfColorizeSetup";
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Colorize',
'url' => 'https://www.mediawiki.org/wiki/Extension:Colorize',
'author' => 'Javier Valcarce Garcia',
'version' => '0.2',
'description' => 'Makes text to appear more fun',
);
function wfColorizeSetup() {
global $wgParser;
$wgParser->setHook( "colorize", "wfColorizeRender" );
}
function wfColorizeRender( $input, $argv, $parser ) {
// Character styles
$input = utf8_decode($input);
$output = ""; // To stop the "Undefined Variable" errors in the webserver logfile
for ($i = 0; $i < strlen($input); $i++)
{
$s = rand(0, 9) * 8 + 150;
$w = rand(5, 9) * 100;
$r = rand(20, 220);
$g = rand(20, 220);
$b = rand(20, 220);
$output .=
'<span style="font-size: ' . strval($s) . '%; font-weight:'
. strval($w) . ';color: #' . dechex($r) . dechex($g) . dechex($b)
. ';">';
$output .= $input[$i];
$output .= '</span>';
}
return utf8_encode($output);
}