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
80423ab6
Commit
80423ab6
authored
14 years ago
by
Adrian Lang
Browse files
Options
Downloads
Patches
Plain Diff
Perform quick search in title as well
parent
78280773
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
inc/fulltext.php
+28
-27
28 additions, 27 deletions
inc/fulltext.php
inc/indexer.php
+2
-0
2 additions, 0 deletions
inc/indexer.php
lib/exe/ajax.php
+14
-13
14 additions, 13 deletions
lib/exe/ajax.php
with
44 additions
and
40 deletions
inc/fulltext.php
+
28
−
27
View file @
80423ab6
...
...
@@ -213,54 +213,55 @@ function ft_mediause($id,$max){
* Quicksearch for pagenames
*
* By default it only matches the pagename and ignores the
* namespace. This can be changed with the second parameter
* namespace. This can be changed with the second parameter.
* The third parameter allows to search in titles as well.
* If the function should search in titles as well, the return array
* has the ids as key and the titles as value.
*
* refactored into ft_pageLookup(), _ft_pageLookup() and trigger_event()
*
* @author Andreas Gohr <andi@splitbrain.org>
*/
function
ft_pageLookup
(
$id
,
$pageonly
=
true
){
$data
=
array
(
'id'
=>
$id
,
'pageonly'
=>
$pageonly
);
return
trigger_event
(
'SEARCH_QUERY_PAGELOOKUP'
,
$data
,
'_ft_pageLookup'
);
function
ft_pageLookup
(
$id
,
$not_in_ns
=
true
,
$not_in_title
=
true
){
$data
=
compact
(
'id'
,
'not_in_ns'
,
'not_in_title'
);
return
trigger_event
(
'SEARCH_QUERY_PAGELOOKUP'
,
$data
,
'_ft_pageLookup'
);
}
function
_ft_pageLookup
(
&
$data
){
// split out original parameter
r
s
// split out original parameters
$id
=
$data
[
'id'
];
$pageonly
=
$data
[
'pageonly'
];
$in_ns
=
!
$data
[
'not_in_ns'
];
$in_title
=
!
$data
[
'not_in_title'
];
global
$conf
;
$id
=
preg_quote
(
$id
,
'/'
);
$pages
=
file
(
$conf
[
'indexdir'
]
.
'/page.idx'
);
if
(
$id
)
$pages
=
array_values
(
preg_grep
(
'/'
.
$id
.
'/'
,
$pages
));
$cnt
=
count
(
$pages
);
for
(
$i
=
0
;
$i
<
$cnt
;
$i
++
){
if
(
$pageonly
){
if
(
!
preg_match
(
'/'
.
$id
.
'/'
,
noNS
(
$pages
[
$i
]))){
unset
(
$pages
[
$i
]);
continue
;
$pages
=
array_map
(
'rtrim'
,
file
(
$conf
[
'indexdir'
]
.
'/page.idx'
));
$titles
=
array_map
(
'rtrim'
,
file
(
$conf
[
'indexdir'
]
.
'/title.idx'
));
$pages
=
array_combine
(
$pages
,
$titles
);
if
(
$id
!==
''
&&
cleanID
(
$id
)
!==
''
)
{
$cleaned
=
cleanID
(
$id
);
$matched_pages
=
array
();
foreach
(
$pages
as
$p_id
=>
$p_title
)
{
if
((
strpos
(
$in_ns
?
$p_id
:
noNS
(
$p_id
),
$cleaned
)
!==
false
)
||
(
$in_title
&&
stripos
(
$p_title
,
$id
)
!==
false
))
{
$matched_pages
[
$p_id
]
=
$p_title
;
}
}
if
(
!
page_exists
(
$pages
[
$i
])){
unset
(
$pages
[
$i
]);
continue
;
}
$pages
=
$matched_pages
;
}
$pages
=
array_filter
(
$pages
,
'isVisiblePage'
);
// discard hidden pages
if
(
!
count
(
$pages
))
return
array
();
// discard hidden pages
// discard nonexistent pages
// check ACL permissions
foreach
(
array_keys
(
$pages
)
as
$idx
){
if
(
auth_quickaclcheck
(
trim
(
$pages
[
$idx
]))
<
AUTH_READ
){
if
(
!
isVisiblePage
(
$idx
)
||
!
page_exists
(
$idx
)
||
auth_quickaclcheck
(
$idx
)
<
AUTH_READ
)
{
unset
(
$pages
[
$idx
]);
}
}
$pages
=
array_map
(
'trim'
,
$pages
);
usort
(
$pages
,
'ft_pagesorter'
);
return
$pages
;
uasort
(
$pages
,
'ft_pagesorter'
);
return
$in_title
?
$pages
:
array_keys
(
$pages
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
inc/indexer.php
+
2
−
0
View file @
80423ab6
...
...
@@ -305,6 +305,8 @@ function idx_addPage($page){
}
unset
(
$page_idx
);
// free memory
idx_saveIndexLine
(
'title'
,
''
,
$pid
,
p_get_first_heading
(
$page
,
false
));
$pagewords
=
array
();
// get word usage in page
$words
=
idx_getPageWords
(
$page
);
...
...
This diff is collapsed.
Click to expand it.
lib/exe/ajax.php
+
14
−
13
View file @
80423ab6
...
...
@@ -50,27 +50,28 @@ function ajax_qsearch(){
global
$conf
;
global
$lang
;
$query
=
cleanID
(
$_POST
[
'q'
]
)
;
if
(
empty
(
$query
))
$query
=
cleanID
(
$_GET
[
'q'
]
)
;
$query
=
$_POST
[
'q'
];
if
(
empty
(
$query
))
$query
=
$_GET
[
'q'
];
if
(
empty
(
$query
))
return
;
$data
=
array
();
$data
=
ft_pageLookup
(
$query
);
$data
=
ft_pageLookup
(
$query
,
true
,
false
);
if
(
!
count
(
$data
))
return
;
print
'<strong>'
.
$lang
[
'quickhits'
]
.
'</strong>'
;
print
'<ul>'
;
foreach
(
$data
as
$id
){
print
'<li>'
;
$ns
=
getNS
(
$id
);
if
(
$ns
){
$name
=
shorten
(
noNS
(
$id
),
' ('
.
$ns
.
')'
,
30
);
}
else
{
$name
=
$id
;
foreach
(
$data
as
$id
=>
$title
){
if
(
useHeading
(
'navigation'
))
{
$name
=
$title
;
}
else
{
$ns
=
getNS
(
$id
);
if
(
$ns
){
$name
=
shorten
(
noNS
(
$id
),
' ('
.
$ns
.
')'
,
30
);
}
else
{
$name
=
$id
;
}
}
print
html_wikilink
(
':'
.
$id
,
$name
);
print
'</li>'
;
echo
'<li>'
.
html_wikilink
(
':'
.
$id
,
$name
)
.
'</li>'
;
}
print
'</ul>'
;
}
...
...
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