Commit 2038fabb authored by Romain Loth's avatar Romain Loth

refine/extract: LIKE disjunctions also fixed now for directory view

parent b1754f13
...@@ -103,6 +103,12 @@ $query_details='<ul>'; ...@@ -103,6 +103,12 @@ $query_details='<ul>';
$f = "";// requête $f = "";// requête
$labfilter=''; $labfilter='';
// NB hashtags and keywords were additionally split on ',' before being transformed into constraints... we keep this mechanism here but fixed (in legacy version the $i used only in inner loop so 'OR' was missing)
// (1st array level: several inputs)
// (2nd array level: several words in one input)
// constraints <=> each elt of the 2nd level
if ($tags) { if ($tags) {
// debug // debug
// echo '<p style="color:white">MATCHING ON tags<p>'; // echo '<p style="color:white">MATCHING ON tags<p>';
...@@ -110,46 +116,59 @@ if ($tags) { ...@@ -110,46 +116,59 @@ if ($tags) {
if (sizeof($tags) > 0) { if (sizeof($tags) > 0) {
$f .= 'AND ('; $f .= 'AND (';
} }
$query_details.='<li><strong>Community tags: </strong>'; $query_details.='<li><strong>Community tags: </strong>';
foreach ($tags as $kw) {
$words = explode(',', $kw); $exploded_hts = [];
$i = 0; foreach ($tags as $ht) {
foreach ($words as $word) { $subwords = explode(',', $ht);
$word = sanitize_input(trim(strtolower($word))); foreach ($subwords as $subword) {
if ($word == "") continue; $subword = sanitize_input(trim(strtolower($subword)));
if ($i > 0) if ($subword == "") continue;
$f .= " OR "; else array_push($exploded_hts, $subword);
$f .= 'hashtags_list LIKE "%' . $word . '%" ';
$query_details.=$word.', ';
$i++;
} }
} }
$f .= ") ";
$i = 0;
foreach($exploded_hts as $clean_subword) {
$query_details.=$clean_subword.', ';
if ($i > 0)
$f .= " OR ";
$f .= 'hashtags_list LIKE "%' . $clean_subword . '%" ';
$i++;
}
$f .= ") ";
} }
if ($keywords) { if ($keywords) {
// debug // debug
// echo '<p style="color:white">MATCHING ON keywords<p>'; // echo '<p style="color:white">MATCHING ON keywords<p>';
if (sizeof($keywords) > 0) { if (sizeof($keywords) > 0) {
$f .= 'AND ('; $f .= 'AND (';
} }
$query_details.='<li><strong>Working on: </strong>'; $query_details.='<li><strong>Working on: </strong>';
$exploded_kws = [];
foreach ($keywords as $kw) { foreach ($keywords as $kw) {
$words = explode(',', $kw); $subwords = explode(',', $kw);
$i = 0; foreach ($subwords as $subword) {
foreach ($words as $word) { $subword = sanitize_input(trim(strtolower($subword)));
$word = sanitize_input(trim(strtolower($word))); if ($subword == "") continue;
if ($word == "") continue; else array_push($exploded_kws, $subword);
$query_details.=$word.', ';
if ($i > 0)
$f .= " OR ";
$f .= 'keywords_list LIKE "%' . $word . '%" ';
$i++;
} }
} }
$i = 0;
foreach($exploded_kws as $clean_subword) {
$query_details.=$clean_subword.', ';
if ($i > 0)
$f .= " OR ";
$f .= 'keywords_list LIKE "%' . $clean_subword . '%" ';
$i++;
}
$f .= ") "; $f .= ") ";
} }
if ($countries) { if ($countries) {
// debug // debug
// echo '<p style="color:white">MATCHING ON countries<p>'; // echo '<p style="color:white">MATCHING ON countries<p>';
...@@ -171,6 +190,8 @@ if ($countries) { ...@@ -171,6 +190,8 @@ if ($countries) {
} }
$f .= ") "; $f .= ") ";
} }
if ($laboratories) { if ($laboratories) {
// debug // debug
// echo '<p style="color:white">MATCHING ON labs<p>'; // echo '<p style="color:white">MATCHING ON labs<p>';
...@@ -232,6 +253,8 @@ $imsize = 150; ...@@ -232,6 +253,8 @@ $imsize = 150;
$content=''; $content='';
error_log("=======> WHERE filters {$f}");
// filtered query // filtered query
if (strlen($f)>0) { if (strlen($f)>0) {
$filter = "WHERE {$f}"; $filter = "WHERE {$f}";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment