Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clinicaltrials
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
david Chavalarias
clinicaltrials
Commits
5bca359d
Commit
5bca359d
authored
Apr 29, 2020
by
bligny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add and operator to search csv query.
parent
8f7100ca
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
97 additions
and
26 deletions
+97
-26
explorerjs.html
explorerjs.html
+21
-7
info_div.php
twbackends/phpAPI/info_div.php
+41
-5
twjs.css
twlibs/css/twjs.css
+17
-0
extras_explorerjs.js
twmain/extras_explorerjs.js
+8
-8
methods.js
twmain/methods.js
+10
-6
No files found.
explorerjs.html
View file @
5bca359d
...
...
@@ -304,13 +304,27 @@
<!-- checkbox -->
<li
class=
"navbar-lower"
>
<input
id=
"checkboxdiv"
onclick=
"alertCheckBox(this);"
title=
"Add next search results to current selection"
class=
"nav btn btn-info"
type=
"checkbox"
>
<span
style=
"position: relative; top: 4px;"
>
Add to selection
</span>
</li>
<table
id=
"search_table"
>
<tr><td>
<input
id=
"checkboxdiv"
onclick=
"alertCheckBox(this);"
title=
"Add next search results to current selection"
class=
"nav btn btn-info"
type=
"checkbox"
>
<!--span style="position: relative; top: 4px;">Add to selection</span-->
<span>
Add to selection
</span>
</td></tr>
<tr><td>
<input
type=
"radio"
id=
"orop"
name=
"search_operator"
value=
"or"
checked
>
<label
for=
"orop"
>
OR
</label>
<input
type=
"radio"
id=
"andop"
name=
"search_operator"
value=
"and"
unchecked
>
<label
for=
"andop"
>
AND
</label>
</td></tr>
</table>
</li>
</ul>
...
...
twbackends/phpAPI/info_div.php
View file @
5bca359d
...
...
@@ -109,15 +109,51 @@ else {
// Search $base cols using preg_match_all : see regex, PCRE mask¶
// 1) Format input query into search string
// get search operator if provided. Default is 'or'
$searchop
=
"or"
;
$queryop_key
=
"queryOp"
;
if
(
array_key_exists
(
$queryop_key
,
$_GET
)){
$searchop
=
strtolower
(
$_GET
[
$queryop_key
]);
if
(
!
(
in_array
(
$searchop
,
array
(
'and'
,
'or'
)))){
echo
"<br> Erreur : queryOp must be 'and' or 'or' <br>"
;
return
;
}
}
//echodump("searchOp :", $searchop);
// get and format input query string
// ex input query string:
// [\"medical device\"] or [\"anti-inflammatory\",\"non-specific anti-inflammatory\"]
$searchinput
=
$_GET
[
"query"
];
//echodump("Query :", $searchinput);
// replace " [ and ] characters by empty string
$searchinput
=
str_replace
(
array
(
"
\"
"
,
"["
,
"]"
),
""
,
$searchinput
);
// replace ',' by '|' (eq or for regex)
$searchinput
=
str_replace
(
","
,
"|"
,
$searchinput
);
$searchpattern
=
"/"
.
$searchinput
.
"/i"
;
// ex "/medical device/i"
// remove '"' around inner terms, and leading and trailing []
$searchinput
=
str_replace
(
"
\"
"
,
""
,
$searchinput
);
$searchinput
=
trim
(
$searchinput
,
"[]"
);
//echodump("Query :", $searchinput);
// some checks : no <>(){}[]:=\/$*?+^| characters
$regex_char
=
"<>(){}[]:=\/$*.?+^|"
;
// Leave the '.' : eq to any char
$check_pattern
=
'/['
.
preg_quote
(
$regex_char
,
'/'
)
.
']/'
;
// escape all
if
(
preg_match
(
$check_pattern
,
$searchinput
)){
echo
'<br> info_div.php (csv mode): The input query contains a forbidden character <br>'
;
echodump
(
"Query :"
,
$searchinput
);
return
;
}
// build regex pattern see https://www.php.net/manual/fr/book.pcre.php
// PCRE for Perl Compatible Regular Expression
// le and est plus compliqué que le et. Ci dessous, ça a l'air de marcher
//$pattern="/(?=.*ceci)(?=.*test)/i"; $pattern="/(?=.*est)(?=.*ceci est un)/i";
// "/(?=.*nutrition)(?=.*oral nutrition supplement)/i"
if
(
$searchop
===
'and'
){
// (?=.*ceci)(?=.*test)
$searchpattern
=
str_replace
(
","
,
")(?=.*"
,
$searchinput
);
$searchpattern
=
"(?=.*"
.
$searchpattern
.
")"
;
}
else
{
$searchpattern
=
str_replace
(
","
,
"|"
,
$searchinput
);
}
$searchpattern
=
"/"
.
$searchpattern
.
"/i"
;
// ex "/medical device/i"
//echodump("Search pattern :", $searchpattern);
// Search $searchpattern in $base. Update $sims if found.
...
...
twlibs/css/twjs.css
View file @
5bca359d
...
...
@@ -405,3 +405,20 @@ ul.infoitems {
background-color
:
#EEEEEE
;
color
:
#999999
;
text-align
:
right
;
}
/* Add AND/OR search operator*/
#search_table
td
input
[
type
=
checkbox
]
{
vertical-align
:
middle
;
margin-top
:
0px
;
margin-bottom
:
4px
;
}
#search_table
td
input
[
type
=
radio
]
{
margin-top
:
4px
;
margin-bottom
:
0px
;
}
#search_table
td
label
{
font-weight
:
normal
;
}
twmain/extras_explorerjs.js
View file @
5bca359d
...
...
@@ -433,7 +433,7 @@ function queryForType(ntypeId){
// - nodetypeId: the queried nodetype
// - chosenAPI: the API "switch" dbtype ('twitter'||'csv'||'CortextDB')
// - tgtDivId: the div #id to update
function
getTopPapers
(
qWords
,
nodetypeId
,
chosenAPI
,
tgtDivId
)
{
function
getTopPapers
(
qWords
,
nodetypeId
,
chosenAPI
,
tgtDivId
,
searchOperator
)
{
// waiting image
let
image
=
'<img style="display:block; margin: 0px auto;" src="twlibs/img/loader.gif"></img>'
;
...
...
@@ -452,9 +452,9 @@ function getTopPapers(qWords, nodetypeId, chosenAPI, tgtDivId) {
let
cbDisplay
=
function
(
jsonData
,
nhits
=
null
,
nTotal
=
null
)
{
// console.log("cbDisplay", jsonData)
// debug, chercher $("#read-sameside-neighs").html(sameNodesDIV)
// Show the number of docs found and displayed in the left panel
// this will not properly work if there is more than one doc db. In this case,
// this will not properly work if there is more than one doc db. In this case,
// need to also update methods.js and inscrement nhits and nTotal for all the bases
// Note ex tgtDivId : id=rd-0-csv
// The label we want to update is "csv (sem)" in :
...
...
@@ -463,7 +463,7 @@ function getTopPapers(qWords, nodetypeId, chosenAPI, tgtDivId) {
let
label
=
nhits
+
" doc displayed / "
+
nTotal
;
$
(
"#reldocs-tabs"
).
find
(
"a"
).
html
(
label
);
}
return
displayTopPapers
(
jsonData
,
nodetypeId
,
chosenAPI
,
tgtDivId
)
}
...
...
@@ -500,7 +500,7 @@ function getTopPapers(qWords, nodetypeId, chosenAPI, tgtDivId) {
});
}
else
{
let
thisRelDocsConf
=
TW
.
currentRelDocsDBs
[
nodetypeId
][
chosenAPI
]
// /!\ documentation and specification needed for the php use cases /!\
let
joinedQ
=
JSON
.
stringify
(
qWords
).
split
(
'&'
).
join
(
'__and__'
);
...
...
@@ -510,10 +510,10 @@ function getTopPapers(qWords, nodetypeId, chosenAPI, tgtDivId) {
// (we send it as param because phpAPI supports different dbtypes)
// POSS object + join.map(join)
let
urlParams
=
"ndtype="
+
nodetypeId
+
"&dbtype="
+
chosenAPI
+
"&query="
+
joinedQ
+
"&gexf="
+
TW
.
File
+
"&n="
+
TW
.
conf
.
relatedDocsMax
;
let
urlParams
=
"ndtype="
+
nodetypeId
+
"&dbtype="
+
chosenAPI
+
"&query="
+
joinedQ
+
"&
queryOp="
+
searchOperator
+
"&
gexf="
+
TW
.
File
+
"&n="
+
TW
.
conf
.
relatedDocsMax
;
// debug (does not work with safari)
console
.
log
(
apiurl
+
'/info_div.php?'
+
urlParams
)
$
.
ajax
({
type
:
'GET'
,
url
:
apiurl
+
'/info_div.php'
,
...
...
@@ -530,7 +530,7 @@ function getTopPapers(qWords, nodetypeId, chosenAPI, tgtDivId) {
cbDisplay
([{
"error"
:
stockErrMsg
}])
}
});
}
}
...
...
twmain/methods.js
View file @
5bca359d
...
...
@@ -635,22 +635,26 @@ function updateRelatedNodesPanel( sels , same, oppos ) {
if
(
TW
.
conf
.
getRelatedDocs
)
{
let
rdTabCount
=
0
// get search_operator : 'or' or 'and'
let
searchOperator
=
$
(
"input[name='search_operator']:checked"
).
val
();
// update all related docs tabs
for
(
let
ntId
in
TW
.
SystemState
().
activetypes
)
{
if
(
TW
.
SystemState
().
activetypes
[
ntId
])
{
let
qWords
=
queryForType
(
ntId
)
// console.log("available topPapers tabs:", TW.gui.reldocTabs[ntId])
let
qWords
=
queryForType
(
ntId
);
// a string array
//console.log("strings to search :", qWords);
//console.log("available topPapers tabs:", TW.gui.reldocTabs[ntId]);
for
(
let
relDbType
in
TW
.
gui
.
reldocTabs
[
ntId
])
{
let
tabId
=
`rd-
${
ntId
}
-
${
relDbType
}
`
rdTabCount
++
let
tabId
=
`rd-
${
ntId
}
-
${
relDbType
}
`
;
rdTabCount
++
;
// if not already done
if
(
!
TW
.
lastRelDocQueries
[
tabId
]
||
TW
.
lastRelDocQueries
[
tabId
]
!=
qWords
)
{
getTopPapers
(
qWords
,
ntId
,
relDbType
,
tabId
)
getTopPapers
(
qWords
,
ntId
,
relDbType
,
tabId
,
searchOperator
);
// memoize
TW
.
lastRelDocQueries
[
tabId
]
=
qWords
TW
.
lastRelDocQueries
[
tabId
]
=
qWords
;
}
}
}
...
...
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