オープンソース・ソフトウェアの開発とダウンロード

CVS リポジトリの参照

Diff of /pukiwiki/pukiwiki/plugin/color.inc.php

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1 by panda, Mon Jan 27 05:38:44 2003 UTC revision 1.14 by henoheno, Sun Nov 21 13:32:30 2004 UTC
# Line 4  Line 4 
4  //  //
5  // $Id$  // $Id$
6  //  //
7    // Text color plugin
8    
9    // Allow CSS instead of font tag (XHTML 1.0 Transitional only)
10    define('PLUGIN_COLOR_ALLOW_CSS', TRUE); // TRUE, FALSE
11    
12    // ----
13    define('PLUGIN_COLOR_USAGE', '&color(foreground[,background]){text};');
14    define('PLUGIN_COLOR_REGEX', '/^(#[0-9a-f]{6}|[a-z-]+)$/i');
15  function plugin_color_inline()  function plugin_color_inline()
16  {  {
17          if (func_num_args() < 2) { return FALSE; }          global $html_transitional;
18    
19            $args = func_get_args();
20            $text = array_pop($args); // htmlspecialchars(text)
21    
22            list($color, $bgcolor) = array_pad($args, 2, '');
23            if ($text == '' && $bgcolor != '') {
24                    // Maybe the old style: '&color(foreground,text);'
25                    $text    = htmlspecialchars($bgcolor);
26                    $bgcolor = '';
27            }
28            if ($color == '' || $text == '' || func_num_args() > 3)
29                    return PLUGIN_COLOR_USAGE;
30    
31          list($color,$body) = func_get_args();          // Invalid color
32          if ($color == '' or $body == '') { return FALSE; }          foreach(array($color, $bgcolor) as $col){
33                    if ($col != '' && ! preg_match(PLUGIN_COLOR_REGEX, $col))
34                            return '&color():Invalid color: ' . htmlspecialchars($col) . ';';
35            }
36    
37          return "<span style=\"color:$color\">$body</span>";          if (PLUGIN_COLOR_ALLOW_CSS === TRUE && $html_transitional === FALSE) {
38                    if ($bgcolor != '') $bgcolor = ';background-color:' . $bgcolor;
39                    return '<span style="color:' . $color . $bgcolor . '">' . $text . '</span>';
40            } else {
41                    // NOTE: <font> tag become invalid from XHTML 1.1
42                    if ($bgcolor != '') return '&color(): bgcolor (with CSS) not allowd;';
43                    return '<font color="' . $color . '">' . $text . '</font>';
44            }
45  }  }
46  ?>  ?>

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.14

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26