PageRenderTime 62ms CodeModel.GetById 33ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_jfusionplugins/dokuwiki/doku_search.php

http://jfusion.googlecode.com/
PHP | 589 lines | 471 code | 3 blank | 115 comment | 132 complexity | 5c0f79f7d1447e9672fa07f4fcd233a7 MD5 | raw file
Possible License(s): Apache-2.0
  1. <?php
  2. /**
  3. * @package JFusion_dokuwiki
  4. * @subpackage dokuwiki
  5. * @author Andreas Gohr <andi@splitbrain.org>
  6. * @author JFusion development team
  7. * @copyright Copyright (C) 2008 JFusion. All rights reserved.
  8. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  9. */
  10. function ft_pageSearch($query, &$highlight) {
  11. $q = ft_queryParser($query);
  12. $highlight = array();
  13. // remember for hilighting later
  14. foreach ($q['words'] as $wrd) {
  15. $highlight[] = str_replace('*', '', $wrd);
  16. }
  17. // lookup all words found in the query
  18. $words = array_merge($q['and'], $q['not']);
  19. if (!count($words)) return array();
  20. $result = idx_lookup($words);
  21. if (!count($result)) return array();
  22. // merge search results with query
  23. foreach ($q['and'] as $pos => $w) {
  24. $q['and'][$pos] = $result[$w];
  25. }
  26. // create a list of unwanted docs
  27. $not = array();
  28. foreach ($q['not'] as $pos => $w) {
  29. $not = array_merge($not, array_keys($result[$w]));
  30. }
  31. // combine and-words
  32. if (count($q['and']) > 1) {
  33. $docs = ft_resultCombine($q['and']);
  34. } else {
  35. $docs = $q['and'][0];
  36. }
  37. if (!count($docs)) return array();
  38. // create a list of hidden pages in the result
  39. $hidden = array();
  40. $hidden = array_filter(array_keys($docs), 'isHiddenPage');
  41. $not = array_merge($not, $hidden);
  42. // filter unmatched namespaces
  43. if (!empty($q['ns'])) {
  44. $pattern = implode('|^', $q['ns']);
  45. foreach ($docs as $key => $val) {
  46. if (!preg_match('/^' . $pattern . '/', $key)) {
  47. unset($docs[$key]);
  48. }
  49. }
  50. }
  51. // remove negative matches
  52. foreach ($not as $n) {
  53. unset($docs[$n]);
  54. }
  55. if (!count($docs)) return array();
  56. // handle phrases
  57. if (count($q['phrases'])) {
  58. $q['phrases'] = array_map('utf8_strtolower', $q['phrases']);
  59. // use this for higlighting later:
  60. $highlight = array_merge($highlight, $q['phrases']);
  61. $q['phrases'] = array_map('preg_quote_cb', $q['phrases']);
  62. // check the source of all documents for the exact phrases
  63. foreach (array_keys($docs) as $id) {
  64. $text = utf8_strtolower(rawWiki($id));
  65. foreach ($q['phrases'] as $phrase) {
  66. if (!preg_match('/' . $phrase . '/usi', $text)) {
  67. unset($docs[$id]); // no hit - remove
  68. break;
  69. }
  70. }
  71. }
  72. }
  73. if (!count($docs)) return array();
  74. // check ACL permissions
  75. /*
  76. foreach (array_keys($docs) as $doc)
  77. {
  78. if (auth_quickaclcheck($doc) < AUTH_READ)
  79. {
  80. unset($docs[$doc]);
  81. }
  82. }
  83. */
  84. if (!count($docs)) return array();
  85. // if there are any hits left, sort them by count
  86. arsort($docs);
  87. return $docs;
  88. }
  89. /**
  90. * Returns the backlinks for a given page
  91. *
  92. * Does a quick lookup with the fulltext index, then
  93. * evaluates the instructions of the found pages
  94. */
  95. function ft_backlinks($id) {
  96. global $conf;
  97. $swfile = DOKU_INC . 'inc/lang/' . $conf['lang'] . '/stopwords.txt';
  98. $stopwords = @file_exists($swfile) ? file($swfile) : array();
  99. $result = array();
  100. // quick lookup of the pagename
  101. $page = noNS($id);
  102. $matches = idx_lookup(idx_tokenizer($page, $stopwords)); // pagename may contain specials (_ or .)
  103. $docs = array_keys(ft_resultCombine(array_values($matches)));
  104. $docs = array_filter($docs, 'isVisiblePage'); // discard hidden pages
  105. if (!count($docs)) return $result;
  106. require_once DOKU_INC . 'inc/parserutils.php';
  107. // check metadata for matching links
  108. foreach ($docs as $match) {
  109. // metadata relation reference links are already resolved
  110. $links = p_get_metadata($match, 'relation references');
  111. if (isset($links[$id])) $result[] = $match;
  112. }
  113. if (!count($result)) return $result;
  114. // check ACL permissions
  115. foreach (array_keys($result) as $idx) {
  116. if (auth_quickaclcheck($result[$idx]) < AUTH_READ) {
  117. unset($result[$idx]);
  118. }
  119. }
  120. sort($result);
  121. return $result;
  122. }
  123. /**
  124. * Returns the pages that use a given media file
  125. *
  126. * Does a quick lookup with the fulltext index, then
  127. * evaluates the instructions of the found pages
  128. *
  129. * Aborts after $max found results
  130. */
  131. function ft_mediause($id, $max) {
  132. global $conf;
  133. $swfile = DOKU_INC . 'inc/lang/' . $conf['lang'] . '/stopwords.txt';
  134. $stopwords = @file_exists($swfile) ? file($swfile) : array();
  135. if (!$max) $max = 1; // need to find at least one
  136. $result = array();
  137. // quick lookup of the mediafile
  138. $media = noNS($id);
  139. $matches = idx_lookup(idx_tokenizer($media, $stopwords));
  140. $docs = array_keys(ft_resultCombine(array_values($matches)));
  141. if (!count($docs)) return $result;
  142. // go through all found pages
  143. $found = 0;
  144. $pcre = preg_quote($media, '/');
  145. foreach ($docs as $doc) {
  146. $ns = getNS($doc);
  147. preg_match_all('/\{\{([^|}]*' . $pcre . '[^|}]*)(|[^}]+)?\}\}/i', rawWiki($doc), $matches);
  148. foreach ($matches[1] as $img) {
  149. $img = trim($img);
  150. if (preg_match('/^https?:\/\//i', $img)) continue; // skip external images
  151. list($img) = explode('?', $img); // remove any parameters
  152. resolve_mediaid($ns, $img, $exists); // resolve the possibly relative img
  153. if ($img == $id) { // we have a match
  154. $result[] = $doc;
  155. $found++;
  156. break;
  157. }
  158. }
  159. if ($found >= $max) break;
  160. }
  161. sort($result);
  162. return $result;
  163. }
  164. /**
  165. * Quicksearch for pagenames
  166. *
  167. * By default it only matches the pagename and ignores the
  168. * namespace. This can be changed with the second parameter
  169. *
  170. * @author Andreas Gohr <andi@splitbrain.org>
  171. */
  172. function ft_pageLookup($id, $pageonly = true) {
  173. global $conf, $rootFolder;
  174. $id = preg_quote($id, '/');
  175. $pages = file($rootFolder . '/data/index' . '/page.idx');
  176. if ($id) $pages = array_values(preg_grep('/' . $id . '/', $pages));
  177. $cnt = count($pages);
  178. for ($i = 0;$i < $cnt;$i++) {
  179. if ($pageonly) {
  180. if (!preg_match('/' . $id . '/', noNS($pages[$i]))) {
  181. unset($pages[$i]);
  182. continue;
  183. }
  184. }
  185. if (!page_exists($pages[$i])) {
  186. unset($pages[$i]);
  187. continue;
  188. }
  189. }
  190. $pages = array_filter($pages, 'isVisiblePage'); // discard hidden pages
  191. if (!count($pages)) return array();
  192. // check ACL permissions
  193. foreach (array_keys($pages) as $idx) {
  194. if (auth_quickaclcheck($pages[$idx]) < AUTH_READ) {
  195. unset($pages[$idx]);
  196. }
  197. }
  198. $pages = array_map('trim', $pages);
  199. sort($pages);
  200. return $pages;
  201. }
  202. /**
  203. * Creates a snippet extract
  204. *
  205. * @author Andreas Gohr <andi@splitbrain.org>
  206. */
  207. function ft_snippet($id, $highlight) {
  208. $text = rawWiki($id);
  209. $match = array();
  210. $snippets = array();
  211. $utf8_offset = $offset = $end = 0;
  212. $len = utf8_strlen($text);
  213. // build a regexp from the phrases to highlight
  214. $re = join('|', array_map('preg_quote_cb', array_filter((array)$highlight)));
  215. for ($cnt = 3;$cnt--;) {
  216. if (!preg_match('#(' . $re . ')#iu', $text, $match, PREG_OFFSET_CAPTURE, $offset)) break;
  217. list($str, $idx) = $match[0];
  218. // convert $idx (a byte offset) into a utf8 character offset
  219. $utf8_idx = utf8_strlen(substr($text, 0, $idx));
  220. $utf8_len = utf8_strlen($str);
  221. // establish context, 100 bytes surrounding the match string
  222. // first look to see if we can go 100 either side,
  223. // then drop to 50 adding any excess if the other side can't go to 50,
  224. $pre = min($utf8_idx - $utf8_offset, 100);
  225. $post = min($len - $utf8_idx - $utf8_len, 100);
  226. if ($pre > 50 && $post > 50) {
  227. $pre = $post = 50;
  228. } else if ($pre > 50) {
  229. $pre = min($pre, 100 - $post);
  230. } else if ($post > 50) {
  231. $post = min($post, 100 - $pre);
  232. } else {
  233. // both are less than 50, means the context is the whole string
  234. // make it so and break out of this loop - there is no need for the
  235. // complex snippet calculations
  236. $snippets = array($text);
  237. break;
  238. }
  239. // establish context start and end points, try to append to previous
  240. // context if possible
  241. $start = $utf8_idx - $pre;
  242. $append = ($start < $end) ? $end : false; // still the end of the previous context snippet
  243. $end = $utf8_idx + $utf8_len + $post; // now set it to the end of this context
  244. if ($append) {
  245. $snippets[count($snippets) - 1].= utf8_substr($text, $append, $end - $append);
  246. } else {
  247. $snippets[] = utf8_substr($text, $start, $end - $start);
  248. }
  249. // set $offset for next match attempt
  250. // substract strlen to avoid splitting a potential search success,
  251. // this is an approximation as the search pattern may match strings
  252. // of varying length and it will fail if the context snippet
  253. // boundary breaks a matching string longer than the current match
  254. $utf8_offset = $utf8_idx + $post;
  255. $offset = $idx + strlen(utf8_substr($text, $utf8_idx, $post));
  256. $offset = utf8_correctIdx($text, $offset);
  257. }
  258. $m = "\1";
  259. $snippets = preg_replace('#(' . $re . ')#iu', $m . '$1' . $m, $snippets);
  260. $snippet = preg_replace('#' . $m . '([^' . $m . ']*?)' . $m . '#iu', '<strong class="search_hit">$1</strong>', hsc(join('... ', $snippets)));
  261. return $snippet;
  262. }
  263. /**
  264. * Combine found documents and sum up their scores
  265. *
  266. * This function is used to combine searched words with a logical
  267. * AND. Only documents available in all arrays are returned.
  268. *
  269. * based upon PEAR's PHP_Compat function for array_intersect_key()
  270. *
  271. * @param array $args An array of page arrays
  272. */
  273. function ft_resultCombine($args) {
  274. $array_count = count($args);
  275. if ($array_count == 1) {
  276. return $args[0];
  277. }
  278. $result = array();
  279. if ($array_count > 1) {
  280. foreach ($args[0] as $key => $value) {
  281. $result[$key] = $value;
  282. for ($i = 1;$i !== $array_count;$i++) {
  283. if (!isset($args[$i][$key])) {
  284. unset($result[$key]);
  285. break;
  286. }
  287. $result[$key]+= $args[$i][$key];
  288. }
  289. }
  290. }
  291. return $result;
  292. }
  293. /**
  294. * Builds an array of search words from a query
  295. *
  296. * @todo support OR and parenthesises?
  297. */
  298. function ft_queryParser($query) {
  299. global $conf;
  300. $swfile = DOKU_INC . 'inc/lang/' . $conf['lang'] . '/stopwords.txt';
  301. if (@file_exists($swfile)) {
  302. $stopwords = file($swfile);
  303. } else {
  304. $stopwords = array();
  305. }
  306. $q = array();
  307. $q['query'] = $query;
  308. $q['ns'] = array();
  309. $q['phrases'] = array();
  310. $q['words'] = array();
  311. $q['and'] = array();
  312. $q['not'] = array();
  313. // strip namespace from query
  314. if (preg_match('/([^@]*)@(.*)/', $query, $match)) {
  315. $query = $match[1];
  316. $q['ns'] = explode('@', preg_replace("/ /", '', $match[2]));
  317. }
  318. // handle phrase searches
  319. while (preg_match('/"(.*?)"/', $query, $match)) {
  320. $q['phrases'][] = $match[1];
  321. $q['and'] = array_merge($q['and'], idx_tokenizer($match[0], $stopwords));
  322. $query = preg_replace('/"(.*?)"/', '', $query, 1);
  323. }
  324. $words = explode(' ', $query);
  325. foreach ($words as $w) {
  326. if ($w{0} == '-') {
  327. $token = idx_tokenizer($w, $stopwords, true);
  328. if (count($token)) $q['not'] = array_merge($q['not'], $token);
  329. } else {
  330. // asian "words" need to be searched as phrases
  331. if (@preg_match_all('/((' . IDX_ASIAN . ')+)/u', $w, $matches)) {
  332. $q['phrases'] = array_merge($q['phrases'], $matches[1]);
  333. }
  334. $token = idx_tokenizer($w, $stopwords, true);
  335. if (count($token)) {
  336. $q['and'] = array_merge($q['and'], $token);
  337. $q['words'] = array_merge($q['words'], $token);
  338. }
  339. }
  340. }
  341. return $q;
  342. }
  343. function idx_tokenizer($string, &$stopwords, $wc = false) {
  344. $words = array();
  345. $wc = ($wc) ? '' : $wc = '\*';
  346. if (preg_match('/[^0-9A-Za-z]/u', $string)) {
  347. // handle asian chars as single words (may fail on older PHP version)
  348. $asia = @preg_replace('/(' . IDX_ASIAN . ')/u', ' \1 ', $string);
  349. if (!is_null($asia)) $string = $asia; //recover from regexp failure
  350. $arr = explode(' ', utf8_stripspecials($string, ' ', '\._\-:' . $wc));
  351. foreach ($arr as $w) {
  352. if (!is_numeric($w) && strlen($w) < 3) continue;
  353. $w = utf8_strtolower($w);
  354. if ($stopwords && is_int(array_search("$w\n", $stopwords))) continue;
  355. $words[] = $w;
  356. }
  357. } else {
  358. $w = $string;
  359. if (!is_numeric($w) && strlen($w) < 3) return $words;
  360. $w = strtolower($w);
  361. if (is_int(array_search("$w\n", $stopwords))) return $words;
  362. $words[] = $w;
  363. }
  364. return $words;
  365. }
  366. function idx_lookup($words) {
  367. global $conf;
  368. $result = array();
  369. $wids = idx_getIndexWordsSorted($words, $result);
  370. if (empty($wids)) return array();
  371. // load known words and documents
  372. $page_idx = idx_getIndex('page', '');
  373. $docs = array(); // hold docs found
  374. foreach (array_keys($wids) as $wlen) {
  375. $wids[$wlen] = array_unique($wids[$wlen]);
  376. $index = idx_getIndex('i', $wlen);
  377. foreach ($wids[$wlen] as $ixid) {
  378. if ($ixid < count($index)) $docs["$wlen*$ixid"] = idx_parseIndexLine($page_idx, $index[$ixid]);
  379. }
  380. }
  381. // merge found pages into final result array
  382. $final = array();
  383. foreach (array_keys($result) as $word) {
  384. $final[$word] = array();
  385. foreach ($result[$word] as $wid) {
  386. $hits = & $docs[$wid];
  387. foreach ($hits as $hitkey => $hitcnt) {
  388. if (isset($final[$word][$hitkey])) {
  389. $final[$word][$hitkey] = $hitcnt + $final[$word][$hitkey];
  390. }
  391. }
  392. }
  393. }
  394. return $final;
  395. }
  396. function idx_getIndexWordsSorted($words, &$result) {
  397. // parse and sort tokens
  398. $tokens = array();
  399. $tokenlength = array();
  400. $tokenwild = array();
  401. foreach ($words as $word) {
  402. $result[$word] = array();
  403. $wild = 0;
  404. $xword = $word;
  405. $wlen = wordlen($word);
  406. // check for wildcards
  407. if (substr($xword, 0, 1) == '*') {
  408. $xword = substr($xword, 1);
  409. $wild|= 1;
  410. $wlen-= 1;
  411. }
  412. if (substr($xword, -1, 1) == '*') {
  413. $xword = substr($xword, 0, -1);
  414. $wild|= 2;
  415. $wlen-= 1;
  416. }
  417. if ($wlen < 3 && $wild == 0 && !is_numeric($xword)) continue;
  418. if (!isset($tokens[$xword])) {
  419. $tokenlength[$wlen][] = $xword;
  420. }
  421. if ($wild) {
  422. $ptn = preg_quote($xword, '/');
  423. if (($wild & 1) == 0) $ptn = '^' . $ptn;
  424. if (($wild & 2) == 0) $ptn = $ptn . '$';
  425. $tokens[$xword][] = array($word, '/' . $ptn . '/');
  426. if (!isset($tokenwild[$xword])) $tokenwild[$xword] = $wlen;
  427. } else $tokens[$xword][] = array($word, null);
  428. }
  429. asort($tokenwild);
  430. // $tokens = array( base word => array( [ query word , grep pattern ] ... ) ... )
  431. // $tokenlength = array( base word length => base word ... )
  432. // $tokenwild = array( base word => base word length ... )
  433. $length_filter = empty($tokenwild) ? $tokenlength : min(array_keys($tokenlength));
  434. $indexes_known = idx_indexLengths($length_filter);
  435. if (!empty($tokenwild)) sort($indexes_known);
  436. // get word IDs
  437. $wids = array();
  438. foreach ($indexes_known as $ixlen) {
  439. $word_idx = idx_getIndex('w', $ixlen);
  440. // handle exact search
  441. if (isset($tokenlength[$ixlen])) {
  442. foreach ($tokenlength[$ixlen] as $xword) {
  443. $wid = array_search("$xword\n", $word_idx);
  444. if (is_int($wid)) {
  445. $wids[$ixlen][] = $wid;
  446. foreach ($tokens[$xword] as $w) $result[$w[0]][] = "$ixlen*$wid";
  447. }
  448. }
  449. }
  450. // handle wildcard search
  451. foreach ($tokenwild as $xword => $wlen) {
  452. if ($wlen >= $ixlen) break;
  453. foreach ($tokens[$xword] as $w) {
  454. if (is_null($w[1])) continue;
  455. foreach (array_keys(preg_grep($w[1], $word_idx)) as $wid) {
  456. $wids[$ixlen][] = $wid;
  457. $result[$w[0]][] = "$ixlen*$wid";
  458. }
  459. }
  460. }
  461. }
  462. return $wids;
  463. }
  464. function wordlen($w) {
  465. defined('IDX_ASIAN2') OR define('IDX_ASIAN2','['.
  466. '\x{2E80}-\x{3040}'. // CJK -> Hangul
  467. '\x{309D}-\x{30A0}'.
  468. '\x{30FD}-\x{31EF}\x{3200}-\x{D7AF}'.
  469. '\x{F900}-\x{FAFF}'. // CJK Compatibility Ideographs
  470. '\x{FE30}-\x{FE4F}'. // CJK Compatibility Forms
  471. ']');
  472. $l = strlen($w);
  473. // If left alone, all chinese "words" will get put into w3.idx
  474. // So the "length" of a "word" is faked
  475. if (preg_match('/' . IDX_ASIAN2 . '/u', $w)) $l+= ord($w) - 0xE1; // Lead bytes from 0xE2-0xEF
  476. return $l;
  477. }
  478. function idx_indexLengths(&$filter) {
  479. global $conf, $rootFolder;
  480. $dir = @opendir($rootFolder . '/data/index');
  481. if ($dir === false) return array();
  482. $idx = array();
  483. if (is_array($filter)) {
  484. while (($f = readdir($dir)) !== false) {
  485. if (substr($f, 0, 1) == 'i' && substr($f, -4) == '.idx') {
  486. $i = substr($f, 1, -4);
  487. if (is_numeric($i) && isset($filter[(int)$i])) $idx[] = (int)$i;
  488. }
  489. }
  490. } else {
  491. // Exact match first.
  492. if (@file_exists($rootFolder . '/data/index' . "/i$filter.idx")) $idx[] = $filter;
  493. while (($f = readdir($dir)) !== false) {
  494. if (substr($f, 0, 1) == 'i' && substr($f, -4) == '.idx') {
  495. $i = substr($f, 1, -4);
  496. if (is_numeric($i) && $i > $filter) $idx[] = (int)$i;
  497. }
  498. }
  499. }
  500. closedir($dir);
  501. return $idx;
  502. }
  503. function utf8_stripspecials($string, $repl = '', $additional = '') {
  504. global $UTF8_SPECIAL_CHARS;
  505. global $UTF8_SPECIAL_CHARS2;
  506. static $specials = null;
  507. if (is_null($specials)) {
  508. # $specials = preg_quote(unicode_to_utf8($UTF8_SPECIAL_CHARS), '/');
  509. $specials = preg_quote($UTF8_SPECIAL_CHARS2, '/');
  510. }
  511. return preg_replace('/[' . $additional . '\x00-\x19' . $specials . ']/u', $repl, $string);
  512. }
  513. function idx_getIndex($pre, $wlen) {
  514. global $conf, $rootFolder;
  515. $fn = $rootFolder . '/data/index' . '/' . $pre . $wlen . '.idx';
  516. if (!@file_exists($fn)) return array();
  517. return file($fn);
  518. }
  519. function idx_parseIndexLine(&$page_idx, $line) {
  520. $result = array();
  521. $line = trim($line);
  522. if ($line == '') return $result;
  523. $parts = explode(':', $line);
  524. foreach ($parts as $part) {
  525. if ($part == '') continue;
  526. list($doc, $cnt) = explode('*', $part);
  527. if (!$cnt) continue;
  528. $doc = trim($page_idx[$doc]);
  529. if (!$doc) continue;
  530. // make sure the document still exists
  531. if (!page_exists($doc, '', false)) continue;
  532. $result[$doc] = $cnt;
  533. }
  534. return $result;
  535. }
  536. function page_exists($id, $rev = '', $clean = true) {
  537. return @file_exists(wikiFN($id, $rev, $clean));
  538. }
  539. function wikiFN($raw_id, $rev = '', $clean = true) {
  540. global $conf, $rootFolder;
  541. global $cache_wikifn;
  542. $cache = & $cache_wikifn;
  543. if (isset($cache[$raw_id]) && isset($cache[$raw_id][$rev])) {
  544. return $cache[$raw_id][$rev];
  545. }
  546. $id = $raw_id;
  547. if ($clean) $id = cleanID($id);
  548. $id = str_replace(':', '/', $id);
  549. if (empty($rev)) {
  550. $fn = $rootFolder . '/data/pages' . '/' . utf8_encodeFN($id) . '.txt';
  551. } else {
  552. $fn = $conf['olddir'] . '/' . utf8_encodeFN($id) . '.' . $rev . '.txt';
  553. if ($conf['compression']) {
  554. //test for extensions here, we want to read both compressions
  555. if (@file_exists($fn . '.gz')) {
  556. $fn.= '.gz';
  557. } else if (@file_exists($fn . '.bz2')) {
  558. $fn.= '.bz2';
  559. } else {
  560. //file doesnt exist yet, so we take the configured extension
  561. $fn.= '.' . $conf['compression'];
  562. }
  563. }
  564. }
  565. if (!isset($cache[$raw_id])) {
  566. $cache[$raw_id] = array();
  567. }
  568. $cache[$raw_id][$rev] = $fn;
  569. return $fn;
  570. }
  571. function utf8_encodeFN($file, $safe = true) {
  572. if ($safe && preg_match('#^[a-zA-Z0-9/_\-.%]+$#', $file)) {
  573. return $file;
  574. }
  575. $file = urlencode($file);
  576. $file = str_replace('%2F', '/', $file);
  577. return $file;
  578. }
  579. function isHiddenPage($id) {
  580. global $conf;
  581. if (empty($conf['hidepages'])) return false;
  582. if (preg_match('/' . $conf['hidepages'] . '/ui', ':' . $id)) {
  583. return true;
  584. }
  585. return false;
  586. }