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

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.14 by henoheno, Sun Nov 21 13:32:30 2004 UTC revision 1.21 by henoheno, Sat May 7 07:36:35 2005 UTC
# Line 1  Line 1 
1  <?php  <?php
 /////////////////////////////////////////////////  
2  // PukiWiki - Yet another WikiWikiWeb clone.  // PukiWiki - Yet another WikiWikiWeb clone.
 //  
3  // $Id$  // $Id$
4  //  //
5  // Text color plugin  // Text color plugin
6    
7  // Allow CSS instead of font tag (XHTML 1.0 Transitional only)  // Allow CSS instead of <font> tag
8    // NOTE: <font> tag become invalid from XHTML 1.1
9  define('PLUGIN_COLOR_ALLOW_CSS', TRUE); // TRUE, FALSE  define('PLUGIN_COLOR_ALLOW_CSS', TRUE); // TRUE, FALSE
10    
11  // ----  // ----
12  define('PLUGIN_COLOR_USAGE', '&color(foreground[,background]){text};');  define('PLUGIN_COLOR_USAGE', '&color(foreground[,background]){text};');
13  define('PLUGIN_COLOR_REGEX', '/^(#[0-9a-f]{6}|[a-z-]+)$/i');  define('PLUGIN_COLOR_REGEX', '/^(#[0-9a-f]{3}|#[0-9a-f]{6}|[a-z-]+)$/i');
14    
15  function plugin_color_inline()  function plugin_color_inline()
16  {  {
17          global $html_transitional;          global $pkwk_dtd;
18    
19          $args = func_get_args();          $args = func_get_args();
20          $text = array_pop($args); // htmlspecialchars(text)          $text = strip_htmltag(array_pop($args)); // htmlspecialchars(text)
21                    // strip_htmltag() is just for avoiding AutoLink insertion
22    
23          list($color, $bgcolor) = array_pad($args, 2, '');          list($color, $bgcolor) = array_pad($args, 2, '');
24          if ($text == '' && $bgcolor != '') {          if ($color != '' && $bgcolor != '' && $text == '') {
25                  // Maybe the old style: '&color(foreground,text);'                  // Maybe the old style: '&color(foreground,text);'
26                  $text    = htmlspecialchars($bgcolor);                  $text    = htmlspecialchars($bgcolor);
27                  $bgcolor = '';                  $bgcolor = '';
28          }          }
29          if ($color == '' || $text == '' || func_num_args() > 3)          if (($color == '' && $bgcolor == '') || $text == '' || func_num_args() > 3)
30                  return PLUGIN_COLOR_USAGE;                  return PLUGIN_COLOR_USAGE;
31    
32          // Invalid color          // Invalid color
# Line 34  function plugin_color_inline() Line 35  function plugin_color_inline()
35                          return '&color():Invalid color: ' . htmlspecialchars($col) . ';';                          return '&color():Invalid color: ' . htmlspecialchars($col) . ';';
36          }          }
37    
38          if (PLUGIN_COLOR_ALLOW_CSS === TRUE && $html_transitional === FALSE) {          if (PLUGIN_COLOR_ALLOW_CSS === TRUE || ! isset($pkwk_dtd) || $pkwk_dtd == PKWK_DTD_XHTML_1_1) {
39                  if ($bgcolor != '') $bgcolor = ';background-color:' . $bgcolor;                  $delimiter = '';
40                  return '<span style="color:' . $color . $bgcolor . '">' . $text . '</span>';                  if ($color != '' && $bgcolor != '') $delimiter = '; ';
41                    if ($color   != '') $color   = 'color:' . $color;
42                    if ($bgcolor != '') $bgcolor = 'background-color:' . $bgcolor;
43                    return '<span style="' . $color . $delimiter . $bgcolor . '">' .
44                            $text . '</span>';
45          } else {          } else {
46                  // NOTE: <font> tag become invalid from XHTML 1.1                  if ($bgcolor != '') return '&color(): bgcolor (with CSS) not allowed;';
                 if ($bgcolor != '') return '&color(): bgcolor (with CSS) not allowd;';  
47                  return '<font color="' . $color . '">' . $text . '</font>';                  return '<font color="' . $color . '">' . $text . '</font>';
48          }          }
49  }  }

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

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