Changeset 7088
- Timestamp:
- 11/26/08 03:04:01 (6 weeks ago)
- Files:
-
- 1 modified
-
trunk/plugins/FM_TTML/ttml.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/FM_TTML/ttml.php
r7047 r7088 26 26 } 27 27 return $content; 28 } 29 30 class FM_TTML_KeywordBinder { 31 var $_replaceOnce; 32 var $_binded = array(); 33 34 function FM_TTML_KeywordBinder($replaceOnce = true) { 35 $this->_replaceOnce = $replaceOnce; 36 } 37 38 function replace($matches) { 39 $keyword = $matches[0]; 40 if (!$this->_replaceOnce || !array_key_exists($keyword, $this->_binded)) { 41 $this->_binded[$keyword] = null; 42 $keyword = fireEvent('BindKeyword', $keyword); 43 } 44 return $keyword; 45 } 28 46 } 29 47 … … 57 75 foreach ($keywords as $keyword) 58 76 $pattern[] = preg_quote($keyword, '/'); 59 $pattern = '/(?<![a-zA-Z\x80-\xff])(?:'.implode('|',$pattern).')/ e'; // 대소문자 구별 및 키워드의 단어 첫머리 처리77 $pattern = '/(?<![a-zA-Z\x80-\xff])(?:'.implode('|',$pattern).')/'; // 대소문자 구별 및 키워드의 단어 첫머리 처리 60 78 61 79 // list of unbindable & (always) singleton elements … … 69 87 $i = 0; 70 88 $bindable = true; 89 $binder = new FM_TTML_KeywordBinder(); 71 90 while (true) { 72 91 if ($bindable) { 73 $buf .= preg_replace ($pattern, "fireEvent('BindKeyword', '\\0')", $result[$i]);92 $buf .= preg_replace_callback($pattern, array($binder, 'replace'), $result[$i]); 74 93 } else { 75 94 $buf .= $result[$i];
