Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Cygnus
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Cygnus
Cygnus
Commits
539e4ae0
Commit
539e4ae0
authored
Mar 09, 2018
by
Luke081515
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'search' into 'master'
Search See merge request
!77
parents
0c3da563
9c921261
Pipeline
#1716
passed with stages
in 2 minutes and 38 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
0 deletions
+34
-0
BotCore.php
BotCore.php
+18
-0
Debug.php
Debug.php
+16
-0
No files found.
BotCore.php
View file @
539e4ae0
...
...
@@ -1222,6 +1222,24 @@ class Core extends Password {
$content
=
substr
(
$content
,
0
,
strpos
(
$content
,
"="
));
return
[
"title"
=>
$content
,
"level"
=>
$sectionlevel
,
];
}
/** search
* uses API fulltext search
* @author KPFC / Luke081515
* @param pattern - pattern to search
* @param ns - [default: 0] numbers of the namespaces to search in; seperate with "|"
* @param prop - [default: size|wordcount|timestamp|snippet] properties to return; seperate with "|" (size, wordcount, timestamp, snippet, titlesnippet, redirecttitle, redirectsnippet, sectiontitle, sectionsnippet, isfilematch, categorysnippet, extensiondata)
* @param limit - [default: 50] number of results to return; max 500 or 5000 for bots
* @param offset - [default: 0] show only the results from position on
* @param what - [default: text] what to search (title/text/nearmatch)
* @return result - array with the results
*/
public
function
search
(
$pattern
,
$ns
=
0
,
$prop
=
"size|wordcount|timestamp|snippet"
,
$limit
=
50
,
$offset
=
0
,
$what
=
"text"
)
{
$data
=
"action=query&format=json&assert="
.
$this
->
assert
.
"&maxlag="
.
$this
->
maxlag
.
"&list=search&srsearch="
.
urlencode
(
$pattern
)
.
"&srnamespace="
.
$ns
.
"&srprop="
.
$prop
.
"&srlimit="
.
$limit
.
"&sroffset="
.
$offset
.
"&srwhat="
.
$what
;
return
json_decode
(
$this
->
httpRequest
(
$data
,
$this
->
job
,
"GET"
),
true
);
}
/** getMaxlag
* @author Luke081515
* @return $this->maxlag
...
...
Debug.php
View file @
539e4ae0
...
...
@@ -528,6 +528,22 @@ class Debug extends Core {
$this
->
processError
(
$e
,
$starttime
,
$endtime
);
}
break
;
case
'search'
:
$required
=
array
(
"pattern"
);
$optional
=
array
(
"ns"
,
"prop"
,
"limit"
,
"offset"
,
"what"
);
$optvalues
=
array
(
0
,
"size|wordcount|timestamp|snippet"
,
50
,
0
,
"text"
);
$Param
=
$this
->
getParams
(
$required
,
$optional
,
$optvalues
);
$this
->
echoNotice
(
'Starting the function call of search...'
);
$starttime
=
microtime
(
true
);
try
{
$ret
=
$this
->
search
(
$Param
[
0
],
$Param
[
1
],
$Param
[
2
],
$Param
[
3
],
$Param
[
4
],
$Param
[
5
]);
$endtime
=
microtime
(
true
);
$this
->
processFunction
(
$ret
,
$starttime
,
$endtime
,
true
);
}
catch
(
Exception
$e
)
{
$endtime
=
microtime
(
true
);
$this
->
processError
(
$e
,
$starttime
,
$endtime
);
}
break
;
// Admin functions
case
'deletePage'
:
$required
=
array
(
"title"
,
"reason"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment