Extension:Colorize

From MediaWiki.org

Jump to: navigation, search


What can this extension do?

           

Manual on MediaWiki Extensions
List of MediaWiki Extensions
Crystal Clear action run.png
Colorize

Release status: stable

Implementation  Tag
Description Makes text to appear more fun
Author(s)  Javier Valcarce García (javier.{NOSPAM}valcarce @gmail.com)
Last Version  0.1 (2007-03-21)
MediaWiki  1.5+
License No license specified
Download no link
Example  http://javiervalcarce.es/wiki/Colorize

check usage (experimental)

Colorize text between <colorize> and </colorize> tags to make it to appear more fun.


Installation

As usual. Copy PHP code into a file named Colorize.php and put it in your MW extensions directory then change LocalSettings.php

Changes to LocalSettings.php

require_once("$IP/extensions/Colorize.php");

Code

<?php
$wgExtensionFunctions[] = "wfColorizeSetup";
$wgExtensionCredits['parserhook'][] = array(
    'name' => 'Colorize',
    'url' => 'http://www.mediawiki.org/wiki/Extension:Colorize',
    'author' => 'Javier Valcarce Garcia',
    'description' => 'It 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);
}
?>
  • Tested on latest version and dont works. Please update it!. 62.128.226.242 08:24, 1 September 2007 (UTC) THIS DOESNT WORK ON 1.10!!!!!!
    • ¿? I tested it on MediaWiki 1.10 and 1.11 and works fine. What problem do you have?
      • Warning: Cannot modify header information - headers already sent by (output started at *****extensions/Colorize.php:1) in *****includes/WebResponse.php on line 10

php5 maybe? --Vev 10:42, 12 January 2008 (UTC)

Try removing the closing php tag (?>) - Worked for me! -- Martin 20:37, 10 March 2008 (UTC)

  • Yes, I think it's a problem with trailing spaces when copy&paste the code 88.8.121.66 16:24, 9 April 2008 (UTC)