17 include_once (
"FDL/Class.SearchDoc.php");
18 include_once (
"FDL/Class.DocSearch.php");
20 include_once (
"FDL/freedom_util.php");
41 $this->limit = $limit;
45 $s9 = utf8_decode(
$s);
46 $s9 = strtr($s9, utf8_decode($c1) , utf8_decode($c2));
47 return utf8_encode($s9);
61 $out = preg_replace(
"/($k)/iu", $replace, str_replace(array(
70 $begin = strpos(
$out, $this->beginTag);
71 $end = strpos(
$out, $this->endTag);
72 if ($begin ===
false) {
75 $begin = strpos(
$out,
" ", max(0, $begin - $offsetStart));
76 if ($begin ===
false) {
79 $end = strpos(
$out,
" ", $end + $offsetStart);
84 $out = substr(
$out, $begin, $end - $begin);
100 $h = str_replace(
'£',
' - ', substr(
$s, 0, 100));
101 $pos1 = mb_strpos($h,
' ');
102 $pos2 = mb_strrpos($h,
' ');
103 $headline = substr($h, $pos1, ($pos2 - $pos1));
104 }
else if ((strlen(
$s) / 1024) > $this->limit) {
105 $headline = sprintf(_(
"document too big (%dKo): no highlight") , (strlen(
$s) / 1024));
108 $k = preg_replace(
'/\s+/u',
'&',
unaccent($k));
111 $s = preg_replace(
'/[ ]+ /u',
' ',
$s);
112 $s = str_replace(array(
122 $s = preg_replace(
'/<[a-z][^>]+>/i',
'',
$s);
123 $s = preg_replace(
'/<\/[a-z]+\s*>/i',
'',
$s);
124 $s = preg_replace(
'/<[a-z]+\/>/i',
'',
$s);
125 $s = preg_replace(
'/«/u',
'"',
$s);
126 $s = preg_replace(
'/»/u',
'"',
$s);
127 $s = preg_replace(
'/\p{C}/u',
'',
$s);
128 $s = preg_replace(
'/\p{S}/u',
'',
$s);
133 $q = sprintf(
"select ts_headline('french','%s',to_tsquery('french','%s'),'MaxFragments=1,StartSel=%s, StopSel=%s')", pg_escape_string($us) , pg_escape_string($k) , pg_escape_string($this->beginTag) , pg_escape_string($this->endTag));
134 $result = pg_query($this->dbid,
$q);
135 if (pg_numrows($result) > 0) {
136 $arr = pg_fetch_array($result, 0, PGSQL_ASSOC);
137 $headline = $arr[
"ts_headline"];
142 $pos = mb_strpos($headline, $this->beginTag);
143 if ($pos !==
false) {
144 $sw = (str_replace(array(
152 $offset = mb_strpos($us, $sw);
154 if ($offset ===
false)
return $headline;
155 $nh = mb_substr(
$s, $offset, mb_strlen($sw));
159 $bo = mb_strpos($headline, $this->beginTag, 0);
160 while ($bo !==
false) {
161 $nh = mb_substr($nh, 0, $bo) . $this->beginTag . mb_substr($nh, $bo);
162 $bo = mb_strpos($headline, $this->endTag, $bo);
164 $nh = mb_substr($nh, 0, $bo) . $this->endTag . mb_substr($nh, $bo);
165 $bo = mb_strpos($headline, $this->beginTag, $bo);
static strtr8($s, $c1, $c2)