MISP/app/View/Attributes/search.ctp

199 lines
6.4 KiB
Plaintext
Raw Normal View History

2012-03-26 19:56:44 +02:00
<div class="attributes form">
<?php echo $this->Form->create('Attribute');?>
2011-11-26 10:45:31 +01:00
<fieldset>
2013-05-31 11:35:27 +02:00
<legend>Search Attribute</legend>
<?php
echo $this->Form->input('keyword', array('type' => 'textarea', 'label' => 'Containing the following expressions', 'div' => 'clear', 'class' => 'input-xxlarge'));
echo $this->Form->input('keyword2', array('type' => 'textarea', 'label' => 'Excluding the following events', 'div' => 'clear', 'class' => 'input-xxlarge'));
2013-05-31 11:35:27 +02:00
?>
<?php
if ('true' == Configure::read('CyDefSIG.showorg') || $isAdmin)
echo $this->Form->input('org', array(
'type' => 'text',
'label' => 'From the following organisation',
'div' => 'input clear'));
?>
<?php
echo $this->Form->input('type', array(
'div' => 'input clear',
'after' => $this->Html->div('forminfo', '', array('id' => 'AttributeTypeDiv'))
2013-05-31 11:35:27 +02:00
));
echo $this->Form->input('category', array('after' => $this->Html->div('forminfo', '', array('id' => 'AttributeCategoryDiv'))));
2013-05-31 11:35:27 +02:00
?>
2011-11-26 10:45:31 +01:00
</fieldset>
2013-05-31 11:35:27 +02:00
<?php
echo $this->Form->button('Search', array('class' => 'btn btn-primary'));
echo $this->Form->end();
?>
2013-05-30 11:40:07 +02:00
</div>
<script type="text/javascript">
//
//Generate Category / Type filtering array
//
var category_type_mapping = new Array();
<?php
// all types for Categorie ALL
echo "category_type_mapping['ALL'] = {";
$first = true;
foreach ($typeDefinitions as $type => $def) {
if ($first) $first = false;
else echo ', ';
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
}
echo "}; \n";
//all types for empty Categorie
echo "category_type_mapping[''] = {";
$first = true;
foreach ($typeDefinitions as $type => $def) {
if ($first) $first = false;
else echo ', ';
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
}
echo "}; \n";
// Types per Categorie
foreach ($categoryDefinitions as $category => $def) {
echo "category_type_mapping['" . addslashes($category) . "'] = {";
$first = true;
foreach ($def['types'] as $type) {
if ($first) $first = false;
else echo ', ';
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
}
echo "}; \n";
}
?>
//
//Generate Type / Category filtering array
//
var type_category_mapping = new Array();
<?php
// all categories for Type ALL
echo "type_category_mapping['ALL'] = {";
$first = true;
foreach ($categoryDefinitions as $type => $def) {
if ($first) $first = false;
else echo ', ';
echo "'" . addslashes($type) . "' : '" . addslashes($type) . "'";
}
echo "}; \n";
// Categories per Type
foreach ($typeDefinitions as $type => $def) {
echo "type_category_mapping['" . addslashes($type) . "'] = {";
$first = true;
foreach ($categoryDefinitions as $category => $def) {
if ( in_array ( $type , $def['types'])) {
if ($first) $first = false;
else echo ', ';
echo "'" . addslashes($category) . "' : '" . addslashes($category) . "'";
}
}
echo "}; \n";
}
?>
function formCategoryChanged(id) {
var alreadySelected = $('#AttributeType').val();
showFormInfo(id); // display the tooltip
// empty the types
document.getElementById("AttributeType").options.length = 1;
// add new items to options
var options = $('#AttributeType').prop('options');
$.each(category_type_mapping[$('#AttributeCategory').val()], function(val, text) {
options[options.length] = new Option(text, val);
if (val == alreadySelected) {
options[options.length-1].selected = true;
}
});
// enable the form element
$('#AttributeType').prop('disabled', false);
if ("ALL" == $('#AttributeCategory').val()) {
//alert($('#AttributeCategory').val());
$('#AttributeCategoryDiv').hide();
}
}
function formTypeChanged(id) {
var alreadySelected = $('#AttributeCategory').val();
showFormInfo(id); // display the tooltip
// empty the categories
document.getElementById("AttributeCategory").options.length = 2;
// add new items to options
var options = $('#AttributeCategory').prop('options');
$.each(type_category_mapping[$('#AttributeType').val()], function(val, text) {
options[options.length] = new Option(text, val);
if (val == alreadySelected) {
options[options.length-1].selected = true;
}
});
// enable the form element
$('#AttributeCategory').prop('disabled', false);
if ("ALL" == $('#AttributeType').val()) {
//alert($('#AttributeType').val());
$('#AttributeTypeDiv').hide();
}
}
var formInfoValues = new Array();
<?php
foreach ($typeDefinitions as $type => $def) {
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
echo "formInfoValues['$type'] = \"$info\";\n";
}
foreach ($categoryDefinitions as $category => $def) {
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
echo "formInfoValues['$category'] = \"$info\";\n";
}
$this->Js->get('#AttributeCategory')->event('change', 'formCategoryChanged("#AttributeCategory")');
$this->Js->get('#AttributeCategory')->event('change', 'showFormInfo("#AttributeCategory")');
$this->Js->get('#AttributeType')->event('change', 'formTypeChanged("#AttributeType")');
$this->Js->get('#AttributeType')->event('change', 'showFormInfo("#AttributeType")');
?>
formInfoValues['ALL'] = '';
formInfoValues[''] = '';
function showFormInfo(id) {
idDiv = id+'Div';
if (("ALL" != $(id).val()) && ("" != $(id).val())) {
// LATER use nice animations
//$(idDiv).hide('fast');
// change the content
var value = $(id).val(); // get the selected value
$(idDiv).html(formInfoValues[value]); // search in a lookup table
// show it again
$(idDiv).fadeIn('slow');
} else {
$(idDiv).hide();
}
}
// hide the formInfo things
$('#AttributeTypeDiv').hide();
$('#AttributeCategoryDiv').hide();
</script>
2013-05-31 11:35:27 +02:00
<?php echo $this->Js->writeBuffer(); // Write cached scripts ?>
<div class="actions">
<ul class="nav nav-list">
2013-06-01 08:46:21 +02:00
<li><?php echo $this->Html->link('List Events', array('controller' => 'events', 'action' => 'index')); ?></li>
<?php if ($isAclAdd): ?>
<li><?php echo $this->Html->link('Add Event', array('controller' => 'events', 'action' => 'add')); ?></li>
<?php endif; ?>
<li class="divider"></li>
<li><?php echo $this->Html->link('List Attributes', array('controller' => 'attributes', 'action' => 'index')); ?> </li>
<li class="active"><?php echo $this->Html->link('Search Attributes', array('controller' => 'attributes', 'action' => 'search')); ?> </li>
<li class="divider"></li>
<li><?php echo $this->Html->link('Export', array('controller' => 'events', 'action' => 'export')); ?> </li>
<?php if ($isAclAuth): ?>
<li><?php echo $this->Html->link('Automation', array('controller' => 'events', 'action' => 'automation')); ?></li>
<?php endif;?>
2013-05-31 11:35:27 +02:00
</ul>
</div>