2012-07-24 Sergio Martin <sergio.martin@artica.es>
* include/javascript/pandora_modules.js godmode/modules/manage_network_components_form.php godmode/modules/manage_network_components_form_plugin.php: Put back the dynamic macros to open version git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6804 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
28bca04079
commit
d796620e08
|
@ -1,3 +1,10 @@
|
|||
2012-07-24 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* include/javascript/pandora_modules.js
|
||||
godmode/modules/manage_network_components_form.php
|
||||
godmode/modules/manage_network_components_form_plugin.php: Put back the
|
||||
dynamic macros to open version
|
||||
|
||||
2012-07-24 Sergio Martin <sergio.martin@artica.es>
|
||||
|
||||
* extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql
|
||||
|
|
|
@ -169,7 +169,7 @@ else {
|
|||
echo '</div>';
|
||||
echo '</form>';
|
||||
|
||||
ui_require_javascript_file_enterprise('pandora_local_components');
|
||||
ui_require_javascript_file('pandora_modules');
|
||||
?>
|
||||
<script language="JavaScript" type="text/javascript">
|
||||
<!--
|
||||
|
|
|
@ -52,65 +52,63 @@ $data[3] = html_print_input_text ('post_process', $post_process, '', 12, 25, tru
|
|||
|
||||
push_table_row ($data, 'plugin_3');
|
||||
|
||||
// Dynamic macros for enterprise version
|
||||
if(enterprise_installed()) {
|
||||
$data = array ();
|
||||
$data[0] = __('Plugin macros');
|
||||
$data[0] .= ui_print_help_icon ('plugin', true);
|
||||
$data[1] = $data[2] = $data[3] = '';
|
||||
// Dynamic macros
|
||||
$data = array ();
|
||||
$data[0] = __('Plugin macros');
|
||||
$data[0] .= ui_print_help_icon ('plugin', true);
|
||||
$data[1] = $data[2] = $data[3] = '';
|
||||
|
||||
push_table_row ($data, 'plugin_4');
|
||||
push_table_row ($data, 'plugin_4');
|
||||
|
||||
$macros = json_decode($macros,true);
|
||||
// The next row number is plugin_5
|
||||
$next_name_number = 5;
|
||||
$i = 1;
|
||||
while(1) {
|
||||
// Always print at least one macro
|
||||
if((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) {
|
||||
break;
|
||||
}
|
||||
$macro_desc_name = 'field'.$i.'_desc';
|
||||
$macro_desc_value = '';
|
||||
$macro_help_name = 'field'.$i.'_help';
|
||||
$macro_help_value = '';
|
||||
$macro_value_name = 'field'.$i.'_value';
|
||||
$macro_value_value = '';
|
||||
$macro_name_name = 'field'.$i.'_macro';
|
||||
$macro_name = '_field'.$i.'_';
|
||||
|
||||
if(isset($macros[$i]['desc'])) {
|
||||
$macro_desc_value = $macros[$i]['desc'];
|
||||
}
|
||||
|
||||
if(isset($macros[$i]['help'])) {
|
||||
$macro_help_value = $macros[$i]['help'];
|
||||
}
|
||||
|
||||
if(isset($macros[$i]['value'])) {
|
||||
$macro_value_value = $macros[$i]['value'];
|
||||
}
|
||||
|
||||
$data = array ();
|
||||
$data[0] = sprintf(__('Macro %s description'),$macro_name);
|
||||
$data[0] .= html_print_input_hidden($macro_name_name, $macro_name, true);
|
||||
$data[1] = html_print_input_text ($macro_desc_name, $macro_desc_value, '', 30, 255, true);
|
||||
$data[2] = sprintf(__('Macro %s default value'),$macro_name);
|
||||
$data[3] = html_print_input_text ($macro_value_name, $macro_value_value, '', 30, 255, true);
|
||||
|
||||
push_table_row ($data, 'plugin_'.$next_name_number);
|
||||
$next_name_number++;
|
||||
|
||||
$table->colspan['plugin_'.$next_name_number][1] = 2;
|
||||
|
||||
$data = array ();
|
||||
$data[0] = sprintf(__('Macro %s help'),$macro_name);
|
||||
$data[1] = html_print_input_text ($macro_help_name, $macro_help_value, '', 100, 255, true);
|
||||
|
||||
push_table_row ($data, 'plugin_'.$next_name_number);
|
||||
$next_name_number++;
|
||||
$i++;
|
||||
$macros = json_decode($macros,true);
|
||||
// The next row number is plugin_5
|
||||
$next_name_number = 5;
|
||||
$i = 1;
|
||||
while(1) {
|
||||
// Always print at least one macro
|
||||
if((!isset($macros[$i]) || $macros[$i]['desc'] == '') && $i > 1) {
|
||||
break;
|
||||
}
|
||||
$macro_desc_name = 'field'.$i.'_desc';
|
||||
$macro_desc_value = '';
|
||||
$macro_help_name = 'field'.$i.'_help';
|
||||
$macro_help_value = '';
|
||||
$macro_value_name = 'field'.$i.'_value';
|
||||
$macro_value_value = '';
|
||||
$macro_name_name = 'field'.$i.'_macro';
|
||||
$macro_name = '_field'.$i.'_';
|
||||
|
||||
if(isset($macros[$i]['desc'])) {
|
||||
$macro_desc_value = $macros[$i]['desc'];
|
||||
}
|
||||
|
||||
if(isset($macros[$i]['help'])) {
|
||||
$macro_help_value = $macros[$i]['help'];
|
||||
}
|
||||
|
||||
if(isset($macros[$i]['value'])) {
|
||||
$macro_value_value = $macros[$i]['value'];
|
||||
}
|
||||
|
||||
$data = array ();
|
||||
$data[0] = sprintf(__('Macro %s description'),$macro_name);
|
||||
$data[0] .= html_print_input_hidden($macro_name_name, $macro_name, true);
|
||||
$data[1] = html_print_input_text ($macro_desc_name, $macro_desc_value, '', 30, 255, true);
|
||||
$data[2] = sprintf(__('Macro %s default value'),$macro_name);
|
||||
$data[3] = html_print_input_text ($macro_value_name, $macro_value_value, '', 30, 255, true);
|
||||
|
||||
push_table_row ($data, 'plugin_'.$next_name_number);
|
||||
$next_name_number++;
|
||||
|
||||
$table->colspan['plugin_'.$next_name_number][1] = 2;
|
||||
|
||||
$data = array ();
|
||||
$data[0] = sprintf(__('Macro %s help'),$macro_name);
|
||||
$data[1] = html_print_input_text ($macro_help_name, $macro_help_value, '', 100, 255, true);
|
||||
|
||||
push_table_row ($data, 'plugin_'.$next_name_number);
|
||||
$next_name_number++;
|
||||
$i++;
|
||||
|
||||
$table->colspan['plugin_n'][2] = 2;
|
||||
|
||||
|
|
|
@ -398,3 +398,104 @@ function configure_modules_form () {
|
|||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Functions to add and remove dynamic fields for macros
|
||||
function delete_macro(prefix) {
|
||||
var next_number = parseInt($('#next_macro').html());
|
||||
// Is not possible delete first macro
|
||||
if(next_number == 3) {
|
||||
$('#delete_macro_button').hide();
|
||||
}
|
||||
var next_row = parseInt($('#next_row').html());
|
||||
$('#next_macro').html(next_number-1);
|
||||
$('#next_row').html(next_row-2);
|
||||
|
||||
var nrow1 = next_row - 2;
|
||||
var nrow2 = next_row - 1;
|
||||
|
||||
var $row1 = $('#'+prefix+nrow1).remove();
|
||||
var $row2 = $('#'+prefix+nrow2).remove();
|
||||
}
|
||||
|
||||
function new_macro(prefix) {
|
||||
$('#delete_macro_button').show();
|
||||
|
||||
var next_row = parseInt($('#next_row').html());
|
||||
|
||||
$('#next_row').html(next_row+2);
|
||||
var nrow1 = next_row - 2;
|
||||
var nrow2 = next_row - 1;
|
||||
var nrow3 = next_row;
|
||||
var nrow4 = next_row + 1;
|
||||
|
||||
var next_number = parseInt($('#next_macro').html());
|
||||
$('#next_macro').html(next_number+1);
|
||||
var current_number = next_number - 1;
|
||||
|
||||
// Clone two last rows
|
||||
var $row1 = $('#'+prefix+nrow1).clone(true);
|
||||
var $row2 = $('#'+prefix+nrow2).clone(true);
|
||||
|
||||
// Change the tr ID
|
||||
$row1.attr('id',prefix+(nrow3));
|
||||
$row2.attr('id',prefix+(nrow4));
|
||||
// Change the td ID
|
||||
$row1.find('td').attr('id', changeTdId);
|
||||
$row2.find('td').attr('id', changeTdId);
|
||||
|
||||
// Insert after last field
|
||||
$row2.insertAfter('#'+prefix+nrow2);
|
||||
$row1.insertAfter('#'+prefix+nrow2);
|
||||
|
||||
// Change labels
|
||||
for(i=0;i<=3;i++) {
|
||||
var label1 = $("#"+prefix+nrow3+"-"+i).html();
|
||||
var exp_reg = new RegExp('field'+current_number, 'g');
|
||||
label1 = label1.replace(exp_reg,'field'+next_number);
|
||||
$("#"+prefix+nrow3+"-"+i).html(label1);
|
||||
}
|
||||
|
||||
for(i=0;i<=1;i++) {
|
||||
var label2 = $("#"+prefix+nrow4+"-"+i).html();
|
||||
var exp_reg = new RegExp('field'+current_number, 'g');
|
||||
label2 = label2.replace(exp_reg,'field'+next_number);
|
||||
$("#"+prefix+nrow4+"-"+i).html(label2);
|
||||
}
|
||||
|
||||
// Empty the text inputs
|
||||
$('#text-field'+next_number+'_desc').val('');
|
||||
$('#text-field'+next_number+'_help').val('');
|
||||
$('#text-field'+next_number+'_value').val('');
|
||||
|
||||
function changeTdId() {
|
||||
switch(this.id) {
|
||||
case prefix+(nrow1)+'-0':
|
||||
return prefix+(nrow3)+'-0';
|
||||
break;
|
||||
case prefix+(nrow1)+'-1':
|
||||
return prefix+(nrow3)+'-1';
|
||||
break;
|
||||
case prefix+(nrow1)+'-2':
|
||||
return prefix+(nrow3)+'-2';
|
||||
break;
|
||||
case prefix+(nrow1)+'-3':
|
||||
return prefix+(nrow3)+'-3';
|
||||
break;
|
||||
case prefix+(nrow2)+'-0':
|
||||
return prefix+(nrow4)+'-0';
|
||||
break;
|
||||
case prefix+(nrow2)+'-1':
|
||||
return prefix+(nrow4)+'-1';
|
||||
break;
|
||||
case prefix+(nrow2)+'-2':
|
||||
return prefix+(nrow4)+'-2';
|
||||
break;
|
||||
case prefix+(nrow2)+'-3':
|
||||
return prefix+(nrow4)+'-3';
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue