Created
December 22, 2011 08:16
-
-
Save gzix/1509489 to your computer and use it in GitHub Desktop.
Drupal-7.10 core search patch for Thai language (temp dirty hack). แฮ็ก drupal core เพื่อให้ index และค้นหาคำภาษาไทยได้ (เอาไว้ใช้ชั่วคราว เพราะแฮ็กแบบนี้มันเห็นแก่ตัว ถ้าคนจีน ญี่ปุ่น เกาหลี มาเห็นคงโดนด่า เพราะขโมย unicode range ภาษาเค้าให้เป็นภาษาไทย
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/modules/search/search.module b/modules/search/search.module | |
index 518272a..c6c44d1 100644 | |
--- a/modules/search/search.module | |
+++ b/modules/search/search.module | |
@@ -54,11 +54,11 @@ define('PREG_CLASS_PUNCTUATION', | |
* | |
* @see search_expand_cjk() | |
*/ | |
-define('PREG_CLASS_CJK', '\x{1100}-\x{11FF}\x{3040}-\x{309F}\x{30A1}-\x{318E}' . | |
- '\x{31A0}-\x{31B7}\x{31F0}-\x{31FF}\x{3400}-\x{4DBF}\x{4E00}-\x{9FCF}' . | |
- '\x{A000}-\x{A48F}\x{A4D0}-\x{A4FD}\x{A960}-\x{A97F}\x{AC00}-\x{D7FF}' . | |
- '\x{F900}-\x{FAFF}\x{FF21}-\x{FF3A}\x{FF41}-\x{FF5A}\x{FF66}-\x{FFDC}' . | |
- '\x{20000}-\x{2FFFD}\x{30000}-\x{3FFFD}'); | |
+ | |
+/** | |
+ * Thai Unicode range 0E01-0E3A,0E3F-0E5B (hacked). | |
+ */ | |
+define('PREG_CLASS_CJK', '\x{0E01}-\x{0E3A}\x{0E3F}-\x{0E5B}'); | |
/** | |
* Implements hook_help(). | |
@@ -1188,7 +1188,7 @@ function search_excerpt($keys, $text) { | |
if (($s = strrpos($end, ' ')) !== FALSE) { | |
// Account for the added spaces. | |
$q = max($q - 1, 0); | |
- $s = min($s, drupal_strlen($end) - 1); | |
+ $s = min($s, strlen($end) - 1); | |
$ranges[$q] = $p + $s; | |
$length += $p + $s - $q; | |
$included[$key] = $p + 1; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment