return $body;
}
+function _mb_convert_kana__enable($str, $option) {
+ return mb_convert_kana($str, $option, SOURCE_ENCODING);
+}
+function _mb_convert_kana__none($str, $option) {
+ return $str;
+}
+
// Expand all search-words to regexes and push them into an array
function get_search_words($words = array(), $do_escape = FALSE)
{
if (! isset($init)) {
// function: mb_convert_kana() is for Japanese code only
if (LANG == 'ja' && function_exists('mb_convert_kana')) {
- $mb_convert_kana = create_function('$str, $option',
- 'return mb_convert_kana($str, $option, SOURCE_ENCODING);');
+ $mb_convert_kana = '_mb_convert_kana__enable';
} else {
- $mb_convert_kana = create_function('$str, $option',
- 'return $str;');
+ $mb_convert_kana = '_mb_convert_kana__none';
}
if (SOURCE_ENCODING == 'EUC-JP') {
// Perl memo - Correct pattern-matching with EUC-JP
arsort($keys, SORT_NUMERIC);
$keys = get_search_words(array_keys($keys), TRUE);
$id = 0;
+ $patterns = '';
foreach ($keys as $key=>$pattern) {
- $s_key = htmlsc($key);
- $pattern = '/' .
- '<textarea[^>]*>.*?<\/textarea>' . // Ignore textareas
- '|' . '<[^>]*>' . // Ignore tags
- '|' . '&[^;]+;' . // Ignore entities
- '|' . '(' . $pattern . ')' . // $matches[1]: Regex for a search word
- '/sS';
- $decorate_Nth_word = create_function(
- '$matches',
- 'return (isset($matches[1])) ? ' .
- '\'<strong class="word' .
- $id .
- '">\' . $matches[1] . \'</strong>\' : ' .
- '$matches[0];'
- );
- $body = preg_replace_callback($pattern, $decorate_Nth_word, $body);
- $notes = preg_replace_callback($pattern, $decorate_Nth_word, $notes);
- ++$id;
+ if (strlen($patterns) > 0) {
+ $patterns .= '|';
+ }
+ $patterns .= '(' . $pattern . ')';
}
+ $whole_pattern = '/' .
+ '<textarea[^>]*>.*?<\/textarea>' . // Ignore textareas
+ '|' . '<[^>]*>' . // Ignore tags
+ '|' . '&[^;]+;' . // Ignore entities
+ '|' . '(' . $patterns . ')' . // $matches[1]: Regex for a search word
+ '/sS';
+ $body = preg_replace_callback($whole_pattern, '_decorate_Nth_word', $body);
+ $notes = preg_replace_callback($whole_pattern, '_decorate_Nth_word', $notes);
}
-
// Embed Scripting data
$html_scripting_data = get_html_scripting_data();
require(SKIN_FILE);
}
+function _decorate_Nth_word($matches)
+{
+ // $matches[0]: including both words to skip and to decorate
+ // $matches[1]: word to decorate
+ // $matches[2+]: indicates which keyword to decorate
+ $index = -1;
+ for ($i = 2; $i < count($matches); $i++) {
+ if (isset($matches[$i]) && $matches[$i]) {
+ $index = $i - 2;
+ break;
+ }
+ }
+ if (isset($matches[1])) {
+ // wordN highlight class: N=0...n
+ return '<strong class="word' . $index . '">' .
+ $matches[0] . '</strong>';
+ }
+ return $matches[0];
+}
+
/**
* Get data used by JavaScript modules
*/
if ($digest === FALSE) $digest = md5(join('', get_source($page)));
$refer = $template = '';
-
+
// Add plugin
$addtag = $add_top = '';
if(isset($vars['add'])) {
return $retval;
}
+function _convert_line_rule_to_regex($a)
+{
+ return '/' . $a . '/';
+}
+
// User-defined rules (convert without replacing source)
function make_line_rules($str)
{
static $pattern, $replace;
if (! isset($pattern)) {
- $pattern = array_map(create_function('$a',
- 'return \'/\' . $a . \'/\';'), array_keys($line_rules));
+ $pattern = array_map('_convert_line_rule_to_regex', array_keys($line_rules));
$replace = array_values($line_rules);
unset($line_rules);
}
return $str;
}
}
+
class Tracker_field_format extends Tracker_field
{
var $sort_type = SORT_STRING;
foreach ($this->config->get($this->name) as $option)
{
- list($key,$style,$format) = array_pad(array_map(create_function('$a','return trim($a);'),$option),3,'');
+ list($key,$style,$format) = array_pad(array_map('trim',$option),3,'');
if ($style != '')
{
$this->styles[$key] = $style;
static $options = array();
if (!array_key_exists($this->name,$options))
{
- $options[$this->name] = array_flip(array_map(create_function('$arr','return $arr[0];'),$this->config->get($this->name)));
+ // 'reset' means function($arr) { return $arr[0]; }
+ $options[$this->name] = array_flip(array_map('reset',$this->config->get($this->name)));
}
return array_key_exists($value,$options[$this->name]) ? $options[$this->name][$value] : $value;
}