2012-03-26 19:56:44 +02:00
|
|
|
<div class="attributes form">
|
|
|
|
<?php echo $this->Form->create('Attribute');?>
|
2012-03-15 15:06:45 +01:00
|
|
|
<fieldset>
|
2012-03-21 21:25:16 +01:00
|
|
|
<legend><?php echo __('Edit Attribute'); ?></legend>
|
2012-03-15 15:06:45 +01:00
|
|
|
<?php
|
|
|
|
echo $this->Form->input('id');
|
2012-05-29 16:50:45 +02:00
|
|
|
echo $this->Form->input('category', array('between' => $this->Html->div('forminfo', '', array('id'=> 'AttributeCategoryDiv'))));
|
2012-03-23 20:04:22 +01:00
|
|
|
if($attachment) {
|
2012-05-29 16:50:45 +02:00
|
|
|
echo $this->Form->hidden('type', array('between' => $this->Html->div('forminfo', '', array('id'=> 'AttributeTypeDiv'))));
|
2012-04-01 18:41:47 +02:00
|
|
|
echo "<BR>Type: ".$this->Form->value('Attribute.type');
|
2012-03-23 20:04:22 +01:00
|
|
|
} else {
|
2012-05-29 16:50:45 +02:00
|
|
|
echo $this->Form->input('type', array('between' => $this->Html->div('forminfo', '', array('id'=> 'AttributeTypeDiv'))));
|
2012-03-23 20:04:22 +01:00
|
|
|
}
|
2012-04-01 18:41:47 +02:00
|
|
|
if ('true' == Configure::read('CyDefSIG.sync')) {
|
|
|
|
echo $this->Form->input('private', array(
|
2012-05-29 16:50:45 +02:00
|
|
|
'before' => $this->Html->div('forminfo', isset($attr_descriptions['private']['formdesc']) ? $attr_descriptions['private']['formdesc'] : $attr_descriptions['private']['desc']),
|
2012-04-01 18:41:47 +02:00
|
|
|
));
|
|
|
|
}
|
|
|
|
echo $this->Form->input('to_ids', array(
|
2012-05-29 16:50:45 +02:00
|
|
|
'before' => $this->Html->div('forminfo', isset($attr_descriptions['signature']['formdesc']) ? $attr_descriptions['private']['formdesc'] : $attr_descriptions['private']['desc']),
|
2012-04-01 18:41:47 +02:00
|
|
|
'label' => 'IDS Signature?'
|
|
|
|
));
|
|
|
|
if($attachment) {
|
|
|
|
echo $this->Form->hidden('value');
|
|
|
|
echo "<BR>Value: ".$this->Form->value('Attribute.value');
|
|
|
|
} else {
|
2012-04-26 11:15:12 +02:00
|
|
|
echo $this->Form->input('value', array(
|
|
|
|
'type' => 'textarea',
|
|
|
|
'error' => array('escape' => false),
|
|
|
|
));
|
2012-04-01 18:41:47 +02:00
|
|
|
}
|
2012-05-30 18:11:44 +02:00
|
|
|
$this->Js->get('#AttributeCategory')->event('change', 'formCategoryChanged("#AttributeCategory")');
|
2012-05-29 16:50:45 +02:00
|
|
|
$this->Js->get('#AttributeType')->event('change', 'showFormInfo("#AttributeType")');
|
2012-05-30 18:11:44 +02:00
|
|
|
|
2012-05-29 16:50:45 +02:00
|
|
|
?>
|
2012-03-15 15:06:45 +01:00
|
|
|
</fieldset>
|
|
|
|
<?php echo $this->Form->end(__('Submit'));?>
|
|
|
|
</div>
|
|
|
|
<div class="actions">
|
|
|
|
<ul>
|
2012-06-26 09:40:52 +02:00
|
|
|
<li><?php echo $this->Form->postLink(__('Delete'), array('action' => 'delete', $this->Form->value('Attribute.id')), null, __('Are you sure you want to delete # %s?', $this->Form->value('Attribute.id'))); ?></li>
|
2012-03-20 13:40:58 +01:00
|
|
|
<li> </li>
|
|
|
|
<?php echo $this->element('actions_menu'); ?>
|
2012-03-15 15:06:45 +01:00
|
|
|
</ul>
|
|
|
|
</div>
|
2012-03-20 13:40:58 +01:00
|
|
|
|
2012-05-29 16:50:45 +02:00
|
|
|
<script type="text/javascript">
|
2012-05-30 18:11:44 +02:00
|
|
|
//
|
|
|
|
//Generate Category / Type filtering array
|
|
|
|
//
|
|
|
|
var category_type_mapping = new Array();
|
|
|
|
<?php
|
|
|
|
foreach ($category_definitions 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";
|
|
|
|
}
|
|
|
|
?>
|
2012-05-29 16:50:45 +02:00
|
|
|
|
2012-05-30 18:11:44 +02:00
|
|
|
function formCategoryChanged(id) {
|
|
|
|
showFormInfo(id); // display the tooltip
|
|
|
|
// fill in the types
|
|
|
|
var options = $('#AttributeType').prop('options');
|
|
|
|
$('option', $('#AttributeType')).remove();
|
|
|
|
$.each(category_type_mapping[$('#AttributeCategory').val()], function(val, text) {
|
|
|
|
options[options.length] = new Option(text, val);
|
|
|
|
});
|
|
|
|
// enable the form element
|
|
|
|
$('#AttributeType').prop('disabled', false);
|
|
|
|
}
|
2012-05-29 16:50:45 +02:00
|
|
|
|
2012-05-30 10:24:57 +02:00
|
|
|
|
2012-05-30 18:11:44 +02:00
|
|
|
//
|
|
|
|
//Generate tooltip information
|
|
|
|
//
|
2012-05-29 16:50:45 +02:00
|
|
|
var formInfoValues = new Array();
|
2012-05-30 10:24:57 +02:00
|
|
|
<?php
|
2012-05-30 18:11:44 +02:00
|
|
|
foreach ($type_definitions as $type => $def) {
|
|
|
|
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
|
|
|
echo "formInfoValues['".addslashes($type)."'] = \"".addslashes($info)."\";\n"; // as we output JS code we need to add slashes
|
|
|
|
}
|
|
|
|
foreach ($category_definitions as $category => $def) {
|
|
|
|
$info = isset($def['formdesc']) ? $def['formdesc'] : $def['desc'];
|
|
|
|
echo "formInfoValues['".addslashes($category)."'] = \"".addslashes($info)."\";\n"; // as we output JS code we need to add slashes
|
|
|
|
}
|
2012-05-29 16:50:45 +02:00
|
|
|
?>
|
|
|
|
|
|
|
|
function showFormInfo(id) {
|
|
|
|
idDiv = id+'Div';
|
|
|
|
// 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');
|
|
|
|
}
|
|
|
|
|
2012-05-30 18:11:44 +02:00
|
|
|
//hide the formInfo things
|
2012-05-29 16:50:45 +02:00
|
|
|
$('#AttributeTypeDiv').hide();
|
|
|
|
$('#AttributeCategoryDiv').hide();
|
2012-05-30 18:11:44 +02:00
|
|
|
// fix the select box based on what was selected
|
|
|
|
var type_value = $('#AttributeType').val();
|
|
|
|
formCategoryChanged("#AttributeCategory");
|
|
|
|
$('#AttributeType').val(type_value);
|
2012-05-29 16:50:45 +02:00
|
|
|
|
|
|
|
</script>
|
|
|
|
<?php echo $this->Js->writeBuffer(); // Write cached scripts ?>
|