Colouring of search terms works in links

- links now have proper colouring to make the found terms more visible
pull/63/head
Andras Iklody 2013-03-04 18:05:17 +01:00
parent 036308bc0e
commit 4a368918eb
3 changed files with 1026 additions and 1025 deletions

View File

@ -820,9 +820,10 @@ class AttributesController extends AppController {
$attribute['Attribute']['value'] = str_replace('\n', chr(10), $attribute['Attribute']['value']);
foreach ($keywordArray as $keywordArrayElement) {
$keywordArrayElement = trim($keywordArrayElement);
if ($attribute['Attribute']['type'] != 'malware-sample' && $attribute['Attribute']['type'] != 'link' && $attribute['Attribute']['type'] != 'attachment') {
$attribute['Attribute']['value'] = preg_replace('%'.$keywordArrayElement.'%i', '<span style="color:red">'.$keywordArrayElement.'</span>', $attribute['Attribute']['value']);
if ($attribute['Attribute']['type'] == 'malware-sample' || $attribute['Attribute']['type'] == 'link' || $attribute['Attribute']['type'] == 'attachment') {
$attribute['Attribute']['valueNoScript'] = preg_replace('%'.$keywordArrayElement.'%i', $keywordArrayElement, $attribute['Attribute']['value']);
}
$attribute['Attribute']['value'] = preg_replace('%'.$keywordArrayElement.'%i', '<span style="color:red">'.$keywordArrayElement.'</span>', $attribute['Attribute']['value']);
}
}
$this->set('attributes', $attributes);

View File

@ -854,7 +854,7 @@ class Attribute extends AppModel {
if (PHP_OS == 'WINNT') {
$rootDir = APP . "files" . DS . $eventId;
} else {
$rootDir = APP . DS . "files" . DS . $eventId;
$rootDir = APP . "files" . DS . $eventId;
}
$dir = new Folder($rootDir, true);
// move the file to the correct location

View File

@ -56,9 +56,9 @@ foreach ($attributes as $attribute): ?>
<?php
$sigDisplay = nl2br(($attribute['Attribute']['value']));
if ('attachment' == $attribute['Attribute']['type'] || 'malware-sample' == $attribute['Attribute']['type']) {
echo $this->Html->link($sigDisplay, array('controller' => 'attributes', 'action' => 'download', $attribute['Attribute']['id']));
echo $this->Html->link($sigDisplay, array('controller' => 'attributes', 'action' => 'download', $attribute['Attribute']['id']), array('escape' => FALSE));
} elseif ('link' == $attribute['Attribute']['type']) {
echo $this->Html->link($sigDisplay, $sigDisplay);
echo $this->Html->link($sigDisplay, nl2br($attribute['Attribute']['valueNoScript']), array('escape' => FALSE));
} else {
echo $sigDisplay;
}