Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
d5a2a500
Commit
d5a2a500
authored
20 years ago
by
andi
Browse files
Options
Downloads
Patches
Plain Diff
utf8 compatible fulltext search
darcs-hash:20050123165100-9977f-697d62ef2daa33eaf167e59754bb6f9444a06135.gz
parent
7077c942
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
inc/html.php
+2
-2
2 additions, 2 deletions
inc/html.php
inc/search.php
+6
-4
6 additions, 4 deletions
inc/search.php
with
8 additions
and
6 deletions
inc/html.php
+
2
−
2
View file @
d5a2a500
...
...
@@ -536,7 +536,7 @@ function html_search(){
//do quick pagesearch
$data
=
array
();
search
(
$data
,
$conf
[
'datadir'
],
'search_pagename'
,
array
(
query
=>
$QUERY
));
search
(
$data
,
$conf
[
'datadir'
],
'search_pagename'
,
array
(
query
=>
cleanID
(
$QUERY
))
)
;
if
(
count
(
$data
)){
sort
(
$data
);
print
'<div class="search_quickresult">'
;
...
...
@@ -554,7 +554,7 @@ function html_search(){
//do fulltext search
$data
=
array
();
search
(
$data
,
$conf
[
'datadir'
],
'search_fulltext'
,
array
(
query
=>
$QUERY
));
search
(
$data
,
$conf
[
'datadir'
],
'search_fulltext'
,
array
(
query
=>
utf8_strtolower
(
$QUERY
))
)
;
if
(
count
(
$data
)){
usort
(
$data
,
'sort_search_fulltext'
);
foreach
(
$data
as
$row
){
...
...
This diff is collapsed.
Click to expand it.
inc/search.php
+
6
−
4
View file @
d5a2a500
...
...
@@ -269,6 +269,8 @@ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){
//get text
$text
=
io_readfile
(
$base
.
'/'
.
$file
);
//lowercase text (u modifier does not help with case)
$lctext
=
utf8_strtolower
(
$text
);
//create regexp from queries
$qpreg
=
preg_split
(
'/\s+/'
,
preg_quote
(
$opts
[
'query'
],
'#'
));
...
...
@@ -276,17 +278,17 @@ function search_fulltext(&$data,$base,$file,$type,$lvl,$opts){
//do the fulltext search
$matches
=
array
();
if
(
$cnt
=
preg_match_all
(
'#'
.
$qpreg
.
'#si'
,
$text
,
$matches
)){
if
(
$cnt
=
preg_match_all
(
'#'
.
$qpreg
.
'#
u
si'
,
$
lc
text
,
$matches
)){
//this is not the best way for snippet generation but the fastest I could find
//split query and only use the first token
$q
=
preg_split
(
'/\s+/'
,
$opts
[
'query'
],
2
);
$q
=
$q
[
0
];
$p
=
strpos
(
strtolower
(
$
text
)
,
$q
);
$p
=
utf8_
strpos
(
$lc
text
,
$q
);
$f
=
$p
-
100
;
$l
=
strlen
(
$q
)
+
200
;
$l
=
utf8_
strlen
(
$q
)
+
200
;
if
(
$f
<
0
)
$f
=
0
;
$snippet
=
'<span class="search_sep"> ... </span>'
.
htmlspecialchars
(
substr
(
$text
,
$f
,
$l
))
.
htmlspecialchars
(
utf8_
substr
(
$text
,
$f
,
$l
))
.
'<span class="search_sep"> ... </span>'
;
$snippet
=
preg_replace
(
'#'
.
$qpreg
.
'#si'
,
'<span class="search_hit">\\1</span>'
,
$snippet
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment