Attribute search now correctly searches attribute comments too for contained expressions, fixes #342

pull/375/head
iglocska 2014-12-05 10:13:07 +01:00
parent 2e28dd2dde
commit 2e1dfca943
3 changed files with 15 additions and 1 deletions

View File

@ -1179,6 +1179,11 @@ class AttributesController extends AppController {
}
}
}
if ($toInclude) {
array_push($temp, array('LOWER(Attribute.comment) LIKE' => '%' . $saveWord . '%'));
} else {
array_push($temp2, array('LOWER(Attribute.comment) NOT LIKE' => '%' . $saveWord . '%'));
}
}
if ($i == 1 && $saveWord != '') $keyWordText = $saveWord;
else if (($i > 1 && $i < 10) && $saveWord != '') $keyWordText = $keyWordText . ', ' . $saveWord;

View File

@ -170,6 +170,8 @@ class EventsController extends AppController {
}
$includeIDs = array_keys($includeIDs);
$excludeIDs = array_keys($excludeIDs);
// return -1 as the only value in includedIDs if both arrays are empty. This will mean that no events will be shown if there was no hit
if (empty($includeIDs) && empty($excludeIDs)) $includeIDs[] = -1;
return array($includeIDs, $excludeIDs);
}

View File

@ -102,7 +102,14 @@ foreach ($attributes as $attribute):
?>
</td>
<td onclick="document.location ='document.location ='/events/view/<?php echo $attribute['Event']['id'];?>';">
<?php echo h($attribute['Attribute']['comment']); ?>&nbsp;
<?php
$sigDisplay = nl2br(h($attribute['Attribute']['comment']));
if ($isSearch == 1 && !empty($replacePairs)) {
// highlight the keywords if there are any
$sigDisplay = $this->Highlight->highlighter($sigDisplay, $replacePairs);
}
echo $sigDisplay;
?>&nbsp;
</td>
<td class="short" onclick="document.location ='document.location ='/events/view/<?php echo $attribute['Event']['id'];?>';">
<?php echo $attribute['Attribute']['to_ids'] ? 'Yes' : 'No'; ?>&nbsp;