Revision [12050]
This is an old revision of ColorAction made by NilsLindenberg on 2005-11-29 13:56:24.
Development page for the Color / Colour action
The color action, as of version 1.1.6.0, has some disadvantages:
- it does no verification if a color is actually given or if it is valid, therefore produces invalid html
- it causes two php-notices
- it has problems with some kinds of text
- it does not use the standard for action-params
the code below solves this issues and adds support for a background-color, too:
- <?php
- /**
- * Colors a given text.
- *
- * @package Actions
- * @name Color
- *
- * @author ?, probably Hendrik Mans
- * @author {@link http://wikka.jsnx.com/NilsLindenberg NilsLindenberg} (modifications)
- *
- * @input string $c/$color/$colour (mandatory): (html)name of the color for the text;
- * @input string $h/$hex (mandatory): color for the text as a hex-value;
- * @input string $b/$bg (mandatory): (html)name or hex-value for the backgroundcolor;
- * @output colored text
- *
- * @todo integrate it into the formatter
- */
- $html_color_names = array ('aqua', 'black', 'blue', 'fuchsia', 'gray', 'green', 'lime', 'maroon', 'navy', 'olive', 'purple', 'red', 'silver', 'teal', 'yellow', 'white');
- $hex_color_regexp = '/^\#[0-9A-F]{6}$/';
- foreach ($vars as $param => $value) {
- switch ($param)
- {
- case 'text':
- $mytext = $this->htmlspecialchars_ent($value);
- break;
- case 'c':
- case 'color':
- case 'colour':
- case 'h':
- case 'hex':
- break;
- case 'b':
- case 'bg':
- }
- }
- $style = '';
- }
- ?>