SluggedBehavior.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. <?php
  2. /**
  3. * Short description for slugged.php
  4. *
  5. * Part based/inspired by the sluggable behavior of Mariano Iglesias
  6. *
  7. * PHP version 5
  8. *
  9. * Copyright (c) 2008, Andy Dawson
  10. *
  11. * Licensed under The MIT License
  12. * Redistributions of files must retain the above copyright notice.
  13. *
  14. * @copyright Copyright (c) 2008, Andy Dawson
  15. * @link www.ad7six.com
  16. * @package mi
  17. * @subpackage mi.models.behaviors
  18. * @since v 1.0
  19. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  20. */
  21. /**
  22. * Ensure that mb_ functions exist
  23. */
  24. App::import('I18n', 'Multibyte');
  25. App::uses('ModelBehavior', 'Model');
  26. /**
  27. * SluggedBehavior class
  28. *
  29. * @uses ModelBehavior
  30. * @version 2.x
  31. * @modified Mark Scherer
  32. */
  33. class SluggedBehavior extends ModelBehavior {
  34. /**
  35. * defaultSettings property
  36. *
  37. * label
  38. * set to the name of a field to use for the slug, an array of fields to use as slugs or leave as null to rely
  39. * on the format returned by find('list') to determine the string to use for slugs
  40. * overwrite has 2 values
  41. * false - once the slug has been saved, do not change it (use if you are doing lookups based on slugs)
  42. * true - if the label field values change, regenerate the slug (use if you are the slug is just window-dressing)
  43. * unique has 2 values
  44. * false - will not enforce a unique slug, whatever the label is is direclty slugged without checking for duplicates
  45. * true - use if you are doing lookups based on slugs (see overwrite)
  46. * mode has the following values
  47. * ascii - retuns an ascii slug generated using the core Inflector::slug() function
  48. * display - a dummy mode which returns a slug legal for display - removes illegal (not unprintable) characters
  49. * url - returns a slug appropriate to put in a url
  50. * class - a dummy mode which returns a slug appropriate to put in a html class (there are no restrictions)
  51. * id - retuns a slug appropriate to use in a html id
  52. * case has the following values
  53. * null - don't change the case of the slug
  54. * low - force lower case. E.g. "this-is-the-slug"
  55. * up - force upper case E.g. "THIS-IS-THE-SLUG"
  56. * title - force title case. E.g. "This-Is-The-Slug"
  57. * camel - force CamelCase. E.g. "ThisIsTheSlug"
  58. *
  59. * @var array
  60. * @access protected
  61. */
  62. protected $_defaultSettings = array(
  63. 'label' => null,
  64. 'slugField' => 'slug',
  65. 'mode' => 'url',
  66. 'separator' => '-',
  67. 'defaultSuffix' => null,
  68. 'length' => 100,
  69. 'overwrite' => true,
  70. 'unique' => false,
  71. 'notices' => true,
  72. 'case' => null,
  73. 'replace' => array(
  74. '&' => 'and',
  75. '+' => 'and',
  76. '#' => 'hash',
  77. ),
  78. 'run' => 'beforeValidate',
  79. 'language' => null,
  80. 'encoding' => null,
  81. 'trigger' => false,
  82. 'scope' => array()
  83. );
  84. /**
  85. * stopWords property
  86. *
  87. * A (3 letter) language code indexed array of stop worlds
  88. *
  89. * @var array
  90. * @access public
  91. */
  92. public $stopWords = array();
  93. /**
  94. * setup method
  95. *
  96. * Use the model's label field as the default field on which to base the slug, the label can be made up of multiple
  97. * fields by specifying an array of fields
  98. *
  99. * @param mixed $Model
  100. * @param array $config
  101. * @access public
  102. * @return void
  103. */
  104. public function setup(Model $Model, $config = array()) {
  105. $this->_defaultSettings['notices'] = Configure::read('debug');
  106. $this->_defaultSettings['label'] = array($Model->displayField);
  107. $this->settings[$Model->alias] = Set::merge($this->_defaultSettings, $config);
  108. extract($this->settings[$Model->alias]);
  109. $label = $this->settings[$Model->alias]['label'] = (array)$label;
  110. if ($Model->Behaviors->attached('Translate')) {
  111. $notices = false;
  112. }
  113. if ($notices) {
  114. foreach ($label as $field) {
  115. $alias = $Model->alias;
  116. if (strpos($field, '.')) {
  117. list($alias, $field) = explode('.', $field);
  118. if (!$Model->$alias->hasField($field)) {
  119. trigger_error('(SluggedBehavior::setup) model ' . $Model->$alias->name . ' is missing the field ' . $field .
  120. ' (specified in the setup for model ' . $Model->name . ') ', E_USER_WARNING);
  121. $Model->Behaviors->disable($this->name);
  122. }
  123. } elseif (!$Model->hasField($field)) {
  124. trigger_error('(SluggedBehavior::setup) model ' . $Model->name . ' is missing the field ' . $field . ' specified in the setup.', E_USER_WARNING);
  125. $Model->Behaviors->disable($this->name);
  126. }
  127. }
  128. }
  129. }
  130. /**
  131. * beforeValidate method
  132. *
  133. * @param mixed $Model
  134. * @return void
  135. * @access public
  136. */
  137. public function beforeValidate(Model $Model) {
  138. extract($this->settings[$Model->alias]);
  139. if ($run !== 'beforeValidate') {
  140. return true;
  141. }
  142. if (is_string($this->settings[$Model->alias]['trigger'])) {
  143. if (!$Model->{$this->settings[$Model->alias]['trigger']}) {
  144. return true;
  145. }
  146. }
  147. return $this->generateSlug($Model);
  148. }
  149. /**
  150. * beforeSave method
  151. *
  152. * @param mixed $Model
  153. * @return void
  154. * @access public
  155. */
  156. public function beforeSave(Model $Model) {
  157. extract($this->settings[$Model->alias]);
  158. if ($run !== 'beforeSave') {
  159. return true;
  160. }
  161. if (is_string($this->settings[$Model->alias]['trigger'])) {
  162. if (!$Model->{$this->settings[$Model->alias]['trigger']}) {
  163. return true;
  164. }
  165. }
  166. return $this->generateSlug($Model);
  167. }
  168. /**
  169. * generate slug method
  170. *
  171. * if a new row, or overwrite is set to true, check for a change to a label field and add the slug to the data
  172. * to be saved
  173. * If no slug at all is returned (should not be permitted and prevented by validating the label fields) the model
  174. * alias will be used as a slug.
  175. * If unique is set to true, check for a unique slug and if unavailable suffix the slug with -1, -2, -3 etc.
  176. * until a unique slug is found
  177. *
  178. * @param mixed $Model
  179. * @access public
  180. * @return void
  181. */
  182. public function generateSlug(Model $Model) {
  183. extract($this->settings[$Model->alias]);
  184. if ($notices && !$Model->hasField($slugField)) {
  185. return true;
  186. }
  187. if ($overwrite || !$Model->id) {
  188. if ($label) {
  189. $somethingToDo = false;
  190. foreach ($label as $field) {
  191. $alias = $Model->alias;
  192. if (strpos($field, '.') !== false) {
  193. list($alias, $field) = explode('.', $field, 2);
  194. }
  195. if (isset($Model->data[$alias][$field])) {
  196. $somethingToDo = true;
  197. }
  198. }
  199. if (!$somethingToDo) {
  200. return true;
  201. }
  202. $slug = array();
  203. foreach ($label as $field) {
  204. $alias = $Model->alias;
  205. if (strpos($field, '.')) {
  206. list($alias, $field) = explode('.', $field);
  207. }
  208. if (isset($Model->data[$alias][$field])) {
  209. if (is_array($Model->data[$alias][$field])) {
  210. return $this->_multiSlug($Model);
  211. }
  212. $slug[] = $Model->data[$alias][$field];
  213. } elseif ($Model->id) {
  214. $slug[] = $Model->field($field);
  215. }
  216. }
  217. $slug = implode($slug, $separator);
  218. } else {
  219. $slug = $this->display($Model);
  220. }
  221. $slug = $Model->slug($slug);
  222. if (!$slug) {
  223. $slug = $Model->alias;
  224. }
  225. if ($unique) {
  226. $conditions = array($Model->alias . '.' . $slugField => $slug);
  227. $conditions = array_merge($conditions, $this->settings[$Model->alias]['scope']);
  228. if ($Model->id) {
  229. $conditions['NOT'][$Model->alias . '.' . $Model->primaryKey] = $Model->id;
  230. }
  231. $i = 0;
  232. $suffix = '';
  233. while ($Model->hasAny($conditions)) {
  234. $i++;
  235. $suffix = $separator . $i;
  236. if (strlen($slug . $suffix) > $length) {
  237. $slug = substr($slug, 0, $length - strlen($suffix));
  238. }
  239. $conditions[$Model->alias . '.' . $slugField] = $slug . $suffix;
  240. }
  241. if ($suffix) {
  242. $slug .= $suffix;
  243. }
  244. }
  245. $this->_addToWhitelist($Model, array($slugField));
  246. $Model->data[$Model->alias][$slugField] = $slug;
  247. }
  248. return true;
  249. }
  250. /**
  251. * removeStopWords from a string. if $splitOnStopWord is true, the following occurs:
  252. * input "apples bananas pears and red cars"
  253. * output array('apples bananas pears', 'red cars')
  254. *
  255. * If the passed string doesn't contain the separator, or after stripping out stop words there's
  256. * nothing left - the original input is returned (in the desired format)
  257. *
  258. * Therefore passing "contain" will return immediately array('contain')
  259. * Passing "contain this text" will return array('text')
  260. * both contain and this are stop words
  261. * Passing "contain this" will return array('contain this')
  262. *
  263. * @param mixed $Model
  264. * @param mixed $string string or array of words
  265. * @param array $params
  266. * @return mixed
  267. * @access public
  268. */
  269. public function removeStopWords(Model $Model, $string = '', $params = array()) {
  270. if (!$string) {
  271. return $string;
  272. }
  273. $separator = ' ';
  274. $splitOnStopWord = true;
  275. $return = 'array';
  276. $originalIfEmpty = true;
  277. extract($params);
  278. /*
  279. if (!class_exists('MiCache')) {
  280. App::import('Vendor', 'Mi.MiCache');
  281. }
  282. */
  283. if (!empty($this->settings[$Model->alias]['language'])) {
  284. $lang = $this->settings[$Model->alias]['language'];
  285. } else {
  286. $lang = Configure::read('Site.lang');
  287. if (!$lang) {
  288. $lang = 'eng';
  289. }
  290. $this->settings[$Model->alias]['language'] = $lang;
  291. }
  292. if (!array_key_exists($lang, $this->stopWords)) {
  293. ob_start();
  294. if (!App::import('Vendor', 'stop_words_' . $lang, array('file' => "stop_words".DS."$lang.txt"))) {
  295. $res = App::import('Vendor', 'Tools.stop_words_' . $lang, array('file' => "stop_words".DS."$lang.txt"));
  296. }
  297. $stopWords = preg_replace('@/\*.*\*/@', '', ob_get_clean());
  298. $this->stopWords[$lang] = array_filter(array_map('trim', explode("\n", $stopWords)));
  299. }
  300. if (is_array($string)) {
  301. $originalTerms = $terms = $string;
  302. foreach ($terms as $i => &$term) {
  303. $term = trim(preg_replace('@[^\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}]@u', $separator, $term), $separator);
  304. }
  305. $lTerms = array_map('mb_strtolower', $terms);
  306. $lTerms = array_diff($lTerms, $this->stopWords[$lang]);
  307. $terms = array_intersect_key($terms, $lTerms);
  308. } else {
  309. if (!strpos($string, $separator)) {
  310. if ($return === 'array') {
  311. return array($string);
  312. }
  313. return $string;
  314. }
  315. $string = preg_replace('@[^\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}]@u', $separator, $string);
  316. $originalTerms = $terms = array_filter(array_map('trim', explode($separator, $string)));
  317. if ($splitOnStopWord) {
  318. $terms = $chunk = array();
  319. $snippet = '';
  320. foreach ($originalTerms as $term) {
  321. $lterm = strtolower($term);
  322. if (in_array($lterm, $this->stopWords[$lang])) {
  323. if ($chunk) {
  324. $terms[] = $chunk;
  325. $chunk = array();
  326. }
  327. continue;
  328. }
  329. $chunk[] = $term;
  330. }
  331. if ($chunk) {
  332. $terms[] = $chunk;
  333. }
  334. foreach ($terms as &$phrase) {
  335. $phrase = implode(' ', $phrase);
  336. }
  337. } else {
  338. $lTerms = array_map('mb_strtolower', $terms);
  339. $lTerms = array_diff($lTerms, $this->stopWords[$lang]);
  340. $terms = array_intersect_key($terms, $lTerms);
  341. }
  342. }
  343. if (!$terms && $originalIfEmpty) {
  344. $terms = array(implode(' ', $originalTerms));
  345. }
  346. if ($return === 'array') {
  347. return array_values(array_unique($terms));
  348. }
  349. return implode($separator, $terms);
  350. }
  351. /**
  352. * slug method
  353. *
  354. * For the given string, generate a slug. The replacements used are based on the mode setting, If tidy is false
  355. * (only possible if directly called - primarily for tracing and testing) separators will not be cleaned up
  356. * and so slugs like "-----as---df-----" are possible, which by default would otherwise be returned as "as-df".
  357. * If the mode is "id" and the first charcter of the regex-ed slug is numeric, it will be prefixed with an x.
  358. *
  359. * @param mixed $Model
  360. * @param mixed $string
  361. * @param bool $tidy
  362. * @return string a slug
  363. * @access public
  364. */
  365. public function slug(Model $Model, $string, $tidy = true) {
  366. extract($this->settings[$Model->alias]);
  367. $this->_setEncoding($Model, $encoding, $string, !Configure::read('debug'));
  368. if ($replace) {
  369. $string = str_replace(array_keys($replace), array_values($replace), $string);
  370. }
  371. if ($mode === 'ascii') {
  372. $slug = Inflector::slug($string, $separator);
  373. } else {
  374. $regex = $this->__regex($mode);
  375. if ($regex) {
  376. $slug = $this->_pregReplace('@[' . $regex . ']@Su', $separator, $string, $encoding);
  377. } else {
  378. $slug = $string;
  379. }
  380. }
  381. if ($tidy) {
  382. $slug = $this->_pregReplace('/' . $separator . '+/', $separator, $slug, $encoding);
  383. $slug = trim($slug, $separator);
  384. if ($slug && $mode === 'id' && is_numeric($slug[0])) {
  385. $slug = 'x' . $slug;
  386. }
  387. }
  388. if (strlen($slug) > $length) {
  389. $slug = mb_substr ($slug, 0, $length);
  390. while ($slug && strlen($slug) > $length) {
  391. $slug = mb_substr ($slug, 0, mb_strlen($slug) - 1);
  392. }
  393. }
  394. if ($case) {
  395. if ($case === 'up') {
  396. $slug = mb_strtoupper($slug);
  397. } else {
  398. $slug = mb_strtolower($slug);
  399. }
  400. if (in_array($case, array('title', 'camel'))) {
  401. $words = explode($separator, $slug);
  402. foreach ($words as $i => &$word) {
  403. $firstChar = mb_substr($word, 0, 1);
  404. $rest = mb_substr($word, 1, mb_strlen($word) - 1);
  405. $firstCharUp = mb_strtoupper($firstChar);
  406. $word = $firstCharUp . $rest;
  407. }
  408. if ($case === 'title') {
  409. $slug = implode($words, $separator);
  410. } elseif ($case === 'camel') {
  411. $slug = implode($words);
  412. }
  413. }
  414. }
  415. return $slug;
  416. }
  417. /**
  418. * display method
  419. *
  420. * Cheat - use find('list') and assume it has been modified such that lists show in the desired format.
  421. * First check (since this method is called in beforeSave) if there is data to be saved, and use that
  422. * to get the display name
  423. * Otherwise, read from the database
  424. *
  425. * @param mixed $id
  426. * @return mixed string (the display name) or false
  427. * @access public
  428. */
  429. public function display(Model $Model, $id = null) {
  430. if (!$id) {
  431. if (!$Model->id) {
  432. return false;
  433. }
  434. $id = $Model->id;
  435. }
  436. $conditions = array_merge(array(
  437. $Model->alias . '.' . $Model->primaryKey => $id),
  438. $this->settings[$Model->alias]['scope']);
  439. return current($Model->find('list', array('conditions' => $conditions)));
  440. }
  441. /**
  442. * resetSlugs method
  443. *
  444. * Regenerate all slugs. On large dbs this can take more than 30 seconds - a time limit is set to allow a minimum
  445. * 100 updates per second as a preventative measure.
  446. *
  447. * @param AppModel $Model
  448. * @param array $conditions
  449. * @param int $recursive
  450. * @return bool true on success false otherwise
  451. * @access public
  452. */
  453. public function resetSlugs(Model $Model, $params = array()) {
  454. $recursive = -1;
  455. extract($this->settings[$Model->alias]);
  456. if ($notices && !$Model->hasField($slugField)) {
  457. return false;
  458. }
  459. $defaults = array(
  460. 'page' => 1,
  461. 'limit' => 100,
  462. 'fields' => array_merge(array($Model->primaryKey, $slugField), $label),
  463. 'order' => $Model->displayField . ' ASC',
  464. 'conditions' => $scope,
  465. 'recursive' => $recursive,
  466. );
  467. $params = array_merge($defaults, $params);
  468. $count = $Model->find('count', compact('conditions'));
  469. $max = ini_get('max_execution_time');
  470. if ($max) {
  471. set_time_limit (max($max, $count / 100));
  472. }
  473. while ($rows = $Model->find('all', $params)) {
  474. foreach ($rows as $row) {
  475. $Model->create();
  476. $Model->save($row, true, array($slugField));
  477. }
  478. $params['page']++;
  479. }
  480. return true;
  481. }
  482. /**
  483. * Multi slug method
  484. *
  485. * Handle both slug and lable fields using the translate behavior, and being edited
  486. * in multiple locales at once
  487. *
  488. * @param mixed $Model
  489. * @return void
  490. * @access protected
  491. */
  492. protected function _multiSlug(Model $Model) {
  493. extract($this->settings[$Model->alias]);
  494. $data = $Model->data;
  495. $field = current($label);
  496. foreach ($Model->data[$Model->alias][$field] as $locale => $_) {
  497. foreach ($label as $field) {
  498. if (is_array($data[$Model->alias][$field])) {
  499. $Model->data[$Model->alias][$field] = $data[$Model->alias][$field][$locale];
  500. }
  501. }
  502. $this->beforeValidate($Model);
  503. $data[$Model->alias][$slugField][$locale] = $Model->data[$Model->alias][$field];
  504. }
  505. $Model->data = $data;
  506. return true;
  507. }
  508. /**
  509. * Wrapper for preg replace taking care of encoding
  510. *
  511. * @param mixed $pattern
  512. * @param mixed $replace
  513. * @param mixed $string
  514. * @param string $encoding 'UTF-8'
  515. * @return void
  516. * @access protected
  517. */
  518. protected function _pregReplace($pattern, $replace, $string, $encoding = 'UTF-8') {
  519. if ($encoding && $encoding !== 'UTF-8') {
  520. $string = mb_convert_encoding($string, 'UTF-8', $encoding);
  521. }
  522. $return = preg_replace($pattern, $replace, $string);
  523. if ($encoding && $encoding !== 'UTF-8') {
  524. $return = mb_convert_encoding($return, $encoding, 'UTF-8');
  525. }
  526. return $return;
  527. }
  528. /**
  529. * setEncoding method
  530. *
  531. * @param mixed $Model
  532. * @param mixed $encoding null
  533. * @param mixed $string
  534. * @param mixed $reset null
  535. * @return void
  536. * @access protected
  537. */
  538. protected function _setEncoding(Model $Model, &$encoding = null, &$string, $reset = null) {
  539. if (function_exists('mb_internal_encoding')) {
  540. $aEncoding = Configure::read('App.encoding');
  541. if ($aEncoding) {
  542. if (!$encoding) {
  543. $encoding = $aEncoding;
  544. } elseif ($encoding !== $aEncoding) {
  545. $string = mb_convert_encoding($string, $encoding, $aEncoding);
  546. }
  547. } else {
  548. $encoding = $aEncoding;
  549. }
  550. if ($encoding) {
  551. mb_internal_encoding($encoding);
  552. }
  553. }
  554. }
  555. /**
  556. * regex method
  557. *
  558. * Based upon the mode return a partial regex to generate a valid string for the intended use. Note that you
  559. * can use almost litterally anything in a url - the limitation is only in what your own application
  560. * understands. See the test case for info on how these regex patterns were generated.
  561. *
  562. * @param string $mode
  563. * @return string a partial regex
  564. * @access private
  565. */
  566. protected function __regex($mode) {
  567. $return = '\x00-\x1f\x26\x3c\x7f-\x9f\x{d800}-\x{dfff}\x{fffe}-\x{ffff}';
  568. if ($mode === 'display') {
  569. return $return;
  570. }
  571. $return .= preg_quote(' \'"/?<>.$/:;?@=+&%\#', '@');
  572. if ($mode === 'url') {
  573. return $return;
  574. }
  575. $return .= '';
  576. if ($mode === 'class') {
  577. return $return;
  578. }
  579. if ($mode === 'id') {
  580. return '\x{0000}-\x{002f}\x{003a}-\x{0040}\x{005b}-\x{005e}\x{0060}\x{007b}-\x{007e}\x{00a0}-\x{00b6}' .
  581. '\x{00b8}-\x{00bf}\x{00d7}\x{00f7}\x{0132}-\x{0133}\x{013f}-\x{0140}\x{0149}\x{017f}\x{01c4}-\x{01cc}' .
  582. '\x{01f1}-\x{01f3}\x{01f6}-\x{01f9}\x{0218}-\x{024f}\x{02a9}-\x{02ba}\x{02c2}-\x{02cf}\x{02d2}-\x{02ff}' .
  583. '\x{0346}-\x{035f}\x{0362}-\x{0385}\x{038b}\x{038d}\x{03a2}\x{03cf}\x{03d7}-\x{03d9}\x{03db}\x{03dd}\x{03df}' .
  584. '\x{03e1}\x{03f4}-\x{0400}\x{040d}\x{0450}\x{045d}\x{0482}\x{0487}-\x{048f}\x{04c5}-\x{04c6}\x{04c9}-\x{04ca}' .
  585. '\x{04cd}-\x{04cf}\x{04ec}-\x{04ed}\x{04f6}-\x{04f7}\x{04fa}-\x{0530}\x{0557}-\x{0558}\x{055a}-\x{0560}' .
  586. '\x{0587}-\x{0590}\x{05a2}\x{05ba}\x{05be}\x{05c0}\x{05c3}\x{05c5}-\x{05cf}\x{05eb}-\x{05ef}\x{05f3}-\x{0620}' .
  587. '\x{063b}-\x{063f}\x{0653}-\x{065f}\x{066a}-\x{066f}\x{06b8}-\x{06b9}\x{06bf}\x{06cf}\x{06d4}\x{06e9}' .
  588. '\x{06ee}-\x{06ef}\x{06fa}-\x{0900}\x{0904}\x{093a}-\x{093b}\x{094e}-\x{0950}\x{0955}-\x{0957}' .
  589. '\x{0964}-\x{0965}\x{0970}-\x{0980}\x{0984}\x{098d}-\x{098e}\x{0991}-\x{0992}\x{09a9}\x{09b1}\x{09b3}-\x{09b5}' .
  590. '\x{09ba}-\x{09bb}\x{09bd}\x{09c5}-\x{09c6}\x{09c9}-\x{09ca}\x{09ce}-\x{09d6}\x{09d8}-\x{09db}\x{09de}' .
  591. '\x{09e4}-\x{09e5}\x{09f2}-\x{0a01}\x{0a03}-\x{0a04}\x{0a0b}-\x{0a0e}\x{0a11}-\x{0a12}\x{0a29}\x{0a31}\x{0a34}' .
  592. '\x{0a37}\x{0a3a}-\x{0a3b}\x{0a3d}\x{0a43}-\x{0a46}\x{0a49}-\x{0a4a}\x{0a4e}-\x{0a58}\x{0a5d}\x{0a5f}-\x{0a65}' .
  593. '\x{0a75}-\x{0a80}\x{0a84}\x{0a8c}\x{0a8e}\x{0a92}\x{0aa9}\x{0ab1}\x{0ab4}\x{0aba}-\x{0abb}\x{0ac6}\x{0aca}' .
  594. '\x{0ace}-\x{0adf}\x{0ae1}-\x{0ae5}\x{0af0}-\x{0b00}\x{0b04}\x{0b0d}-\x{0b0e}\x{0b11}-\x{0b12}\x{0b29}\x{0b31}' .
  595. '\x{0b34}-\x{0b35}\x{0b3a}-\x{0b3b}\x{0b44}-\x{0b46}\x{0b49}-\x{0b4a}\x{0b4e}-\x{0b55}\x{0b58}-\x{0b5b}\x{0b5e}' .
  596. '\x{0b62}-\x{0b65}\x{0b70}-\x{0b81}\x{0b84}\x{0b8b}-\x{0b8d}\x{0b91}\x{0b96}-\x{0b98}\x{0b9b}\x{0b9d}' .
  597. '\x{0ba0}-\x{0ba2}\x{0ba5}-\x{0ba7}\x{0bab}-\x{0bad}\x{0bb6}\x{0bba}-\x{0bbd}\x{0bc3}-\x{0bc5}\x{0bc9}' .
  598. '\x{0bce}-\x{0bd6}\x{0bd8}-\x{0be6}\x{0bf0}-\x{0c00}\x{0c04}\x{0c0d}\x{0c11}\x{0c29}\x{0c34}\x{0c3a}-\x{0c3d}' .
  599. '\x{0c45}\x{0c49}\x{0c4e}-\x{0c54}\x{0c57}-\x{0c5f}\x{0c62}-\x{0c65}\x{0c70}-\x{0c81}\x{0c84}\x{0c8d}\x{0c91}' .
  600. '\x{0ca9}\x{0cb4}\x{0cba}-\x{0cbd}\x{0cc5}\x{0cc9}\x{0cce}-\x{0cd4}\x{0cd7}-\x{0cdd}\x{0cdf}\x{0ce2}-\x{0ce5}' .
  601. '\x{0cf0}-\x{0d01}\x{0d04}\x{0d0d}\x{0d11}\x{0d29}\x{0d3a}-\x{0d3d}\x{0d44}-\x{0d45}\x{0d49}\x{0d4e}-\x{0d56}' .
  602. '\x{0d58}-\x{0d5f}\x{0d62}-\x{0d65}\x{0d70}-\x{0e00}\x{0e2f}\x{0e3b}-\x{0e3f}\x{0e4f}\x{0e5a}-\x{0e80}\x{0e83}' .
  603. '\x{0e85}-\x{0e86}\x{0e89}\x{0e8b}-\x{0e8c}\x{0e8e}-\x{0e93}\x{0e98}\x{0ea0}\x{0ea4}\x{0ea6}\x{0ea8}-\x{0ea9}' .
  604. '\x{0eac}\x{0eaf}\x{0eba}\x{0ebe}-\x{0ebf}\x{0ec5}\x{0ec7}\x{0ece}-\x{0ecf}\x{0eda}-\x{0f17}\x{0f1a}-\x{0f1f}' .
  605. '\x{0f2a}-\x{0f34}\x{0f36}\x{0f38}\x{0f3a}-\x{0f3d}\x{0f48}\x{0f6a}-\x{0f70}\x{0f85}\x{0f8c}-\x{0f8f}\x{0f96}' .
  606. '\x{0f98}\x{0fae}-\x{0fb0}\x{0fb8}\x{0fba}-\x{109f}\x{10c6}-\x{10cf}\x{10f7}-\x{10ff}\x{1101}\x{1104}\x{1108}' .
  607. '\x{110a}\x{110d}\x{1113}-\x{113b}\x{113d}\x{113f}\x{1141}-\x{114b}\x{114d}\x{114f}\x{1151}-\x{1153}' .
  608. '\x{1156}-\x{1158}\x{115a}-\x{115e}\x{1162}\x{1164}\x{1166}\x{1168}\x{116a}-\x{116c}\x{116f}-\x{1171}\x{1174}' .
  609. '\x{1176}-\x{119d}\x{119f}-\x{11a7}\x{11a9}-\x{11aa}\x{11ac}-\x{11ad}\x{11b0}-\x{11b6}\x{11b9}\x{11bb}' .
  610. '\x{11c3}-\x{11ea}\x{11ec}-\x{11ef}\x{11f1}-\x{11f8}\x{11fa}-\x{1dff}\x{1e9c}-\x{1e9f}\x{1efa}-\x{1eff}' .
  611. '\x{1f16}-\x{1f17}\x{1f1e}-\x{1f1f}\x{1f46}-\x{1f47}\x{1f4e}-\x{1f4f}\x{1f58}\x{1f5a}\x{1f5c}\x{1f5e}' .
  612. '\x{1f7e}-\x{1f7f}\x{1fb5}\x{1fbd}\x{1fbf}-\x{1fc1}\x{1fc5}\x{1fcd}-\x{1fcf}\x{1fd4}-\x{1fd5}\x{1fdc}-\x{1fdf}' .
  613. '\x{1fed}-\x{1ff1}\x{1ff5}\x{1ffd}-\x{20cf}\x{20dd}-\x{20e0}\x{20e2}-\x{2125}\x{2127}-\x{2129}' .
  614. '\x{212c}-\x{212d}\x{212f}-\x{217f}\x{2183}-\x{3004}\x{3006}\x{3008}-\x{3020}\x{3030}\x{3036}-\x{3040}' .
  615. '\x{3095}-\x{3098}\x{309b}-\x{309c}\x{309f}-\x{30a0}\x{30fb}\x{30ff}-\x{3104}\x{312d}-\x{4dff}' .
  616. '\x{9fa6}-\x{abff}\x{d7a4}-\x{d7ff}\x{e000}-\x{ffff}';
  617. }
  618. return false;
  619. }
  620. }