Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1440

Přidáno uživatelem Ondřej Fibich před asi 12 roky(ů)

Upravy:
- moznost u kazde polozky sablony zarizeni pridavat jmeno (soucast #185)

Zobrazit rozdíly:

freenetis/branches/network/application/i18n/cs_CZ/texts.php
'name of interface' => 'Název rozhraní',
'name of the association' => 'Název sdružení',
'name of organization' => 'Název organizace',
'names' => 'Jména',
'native' => 'Nativní',
'near number %s wasnt found data for testing in group %s' => 'U čísla %s nebyly nalezena data pro kontrolu služeb ve skupině %s',
'near number %s differs from price of services: %s\ncalculated price: %s\ninvoiced price: %s' => 'Poblíž čísla %s se odlišují ceny služeb: %s\nVypočtená cena: %s\nFakturovaná cena: %s',
freenetis/branches/network/application/controllers/device_templates.php
*/
private function validate_form_value(&$vals)
{
$vals[Iface_Model::TYPE_WIRELESS]['name'] = htmlspecialchars($vals[Iface_Model::TYPE_WIRELESS]['name']);
$vals[Iface_Model::TYPE_WIRELESS]['type'] = Iface_Model::TYPE_WIRELESS;
$vals[Iface_Model::TYPE_WIRELESS]['has_ip'] = Iface_Model::type_has_ip_address(Iface_Model::TYPE_WIRELESS);
$vals[Iface_Model::TYPE_WIRELESS]['has_link'] = Iface_Model::type_has_link(Iface_Model::TYPE_WIRELESS);
......
{
$vals[Iface_Model::TYPE_WIRELESS]['items'] = array();
}
else
{
foreach ($vals[Iface_Model::TYPE_WIRELESS]['items'] as $k => $v)
{
$vals[Iface_Model::TYPE_WIRELESS]['items'][$k]['name'] = htmlspecialchars($v['name']);
}
}
$vals[Iface_Model::TYPE_ETHERNET]['name'] = htmlspecialchars($vals[Iface_Model::TYPE_ETHERNET]['name']);
$vals[Iface_Model::TYPE_ETHERNET]['type'] = Iface_Model::TYPE_ETHERNET;
$vals[Iface_Model::TYPE_ETHERNET]['has_ip'] = Iface_Model::type_has_ip_address(Iface_Model::TYPE_ETHERNET);
$vals[Iface_Model::TYPE_ETHERNET]['has_link'] = Iface_Model::type_has_link(Iface_Model::TYPE_ETHERNET);
$vals[Iface_Model::TYPE_ETHERNET]['has_mac'] = Iface_Model::type_has_mac_address(Iface_Model::TYPE_ETHERNET);
$vals[Iface_Model::TYPE_ETHERNET]['count'] = intval($vals[Iface_Model::TYPE_ETHERNET]['count']);
$vals[Iface_Model::TYPE_PORT]['name'] = htmlspecialchars($vals[Iface_Model::TYPE_PORT]['name']);
if (!isset($vals[Iface_Model::TYPE_ETHERNET]['items']))
{
$vals[Iface_Model::TYPE_ETHERNET]['items'] = array();
}
else
{
foreach ($vals[Iface_Model::TYPE_ETHERNET]['items'] as $k => $v)
{
$vals[Iface_Model::TYPE_ETHERNET]['items'][$k]['name'] = htmlspecialchars($v['name']);
}
}
$vals[Iface_Model::TYPE_PORT]['type'] = Iface_Model::TYPE_PORT;
$vals[Iface_Model::TYPE_PORT]['has_ip'] = Iface_Model::type_has_ip_address(Iface_Model::TYPE_PORT);
$vals[Iface_Model::TYPE_PORT]['has_link'] = Iface_Model::type_has_link(Iface_Model::TYPE_PORT);
......
foreach ($vals[Iface_Model::TYPE_PORT]['items'] as $k => $v)
{
$vals[Iface_Model::TYPE_PORT]['items'][$k]['number'] = intval($v['number']);
$vals[Iface_Model::TYPE_PORT]['items'][$k]['name'] = htmlspecialchars($v['name']);
}
}
$vals[Iface_Model::TYPE_INTERNAL]['name'] = htmlspecialchars($vals[Iface_Model::TYPE_INTERNAL]['name']);
$vals[Iface_Model::TYPE_INTERNAL]['type'] = Iface_Model::TYPE_INTERNAL;
$vals[Iface_Model::TYPE_INTERNAL]['has_ip'] = Iface_Model::type_has_ip_address(Iface_Model::TYPE_INTERNAL);
$vals[Iface_Model::TYPE_INTERNAL]['has_link'] = Iface_Model::type_has_link(Iface_Model::TYPE_INTERNAL);
......
$vals[Iface_Model::TYPE_INTERNAL]['min_count'] = intval(@$vals[Iface_Model::TYPE_INTERNAL]['min_count']);
$vals[Iface_Model::TYPE_INTERNAL]['max_count'] = intval(@$vals[Iface_Model::TYPE_INTERNAL]['max_count']);
if (!isset($vals[Iface_Model::TYPE_INTERNAL]['items']))
{
$vals[Iface_Model::TYPE_INTERNAL]['items'] = array();
}
else
{
foreach ($vals[Iface_Model::TYPE_INTERNAL]['items'] as $k => $v)
{
$vals[Iface_Model::TYPE_INTERNAL]['items'][$k]['name'] = htmlspecialchars($v['name']);
}
}
// check min and max
if ($vals[Iface_Model::TYPE_WIRELESS]['min_count'] > $vals[Iface_Model::TYPE_WIRELESS]['max_count'])
{
freenetis/branches/network/application/views/js/device_templates_add.php
var wiface_antenna_options = '<?php foreach (Iface_Model::get_wireless_antennas() as $k => $v): ?><option value="<?php echo $k ?>"<?php echo ($k == Iface_Model::WIRELESS_ANTENNA_SECTIONAL) ? ' selected="selected"' : '' ?>><?php echo $v ?></option><?php endforeach; ?>';
/**
* Makes ethernet inputs - enables to add ethrnet input name
*
* @param parent Parent object after which elements will be added
* @param count Count of ethernets
*/
function make_ethernet_inputs(parent, count)
{
var ename = 'values_ethernet_items';
// create root element
if (!$('#' + ename).length)
{
parent.after($('<tr>').append(
$('<td>').attr('colspan', '2').append(
$('<table>').attr('id', ename).css('margin', '4px 20px')
)
));
}
// limit
if (count > 99)
{
count = 99;
}
var e = $('#' + ename);
var ch_count = e.find('tr').length;
// inputs alread added but there is too much of them => drop some of them
if (ch_count > count)
{
for (var i = count; i < ch_count; i++)
{
e.find('#' + ename + '_id_' + i).remove();
}
}
// add missing items
else if (ch_count < count)
{
for (var i = ch_count; i < count; i++)
{
e.append($('<tr>').attr('id', ename + '_id_' + i).append(
$('<td>').html($('<label>').text('<?php echo __('Name') ?>:')).append(
$('<input>').attr({
'name' : 'values[<?php echo Iface_Model::TYPE_ETHERNET ?>][items][' + i + '][name]',
'class' : 'textbox',
'type' : 'text'
}).css('margin', '4px 15px')
)
));
}
}
}
/**
* Makes port inputs - enables to add port modes and numbers
*
* @param parent Parent object after which elements will be added
......
for (var i = ch_count; i < count; i++)
{
e.append($('<tr>').attr('id', ename + '_id_' + i).append(
$('<td>').html($('<label>').text('<?php echo __('Name') ?>:')).append(
$('<input>').attr({
'name' : 'values[<?php echo Iface_Model::TYPE_PORT ?>][items][' + i + '][name]',
'class' : 'textbox',
'type' : 'text'
}).css('margin', '4px 15px')
)
).append(
$('<td>').html($('<label>').text('<?php echo __('Port number') ?>:')).append(
$('<input>').attr({
'name' : 'values[<?php echo Iface_Model::TYPE_PORT ?>][items][' + i + '][number]',
......
for (var i = ch_count; i < count; i++)
{
e.append($('<tr>').attr('id', ename + '_id_' + i).append(
$('<td>').html($('<label>').text('<?php echo __('Name') ?>:')).append(
$('<input>').attr({
'name' : 'values[<?php echo Iface_Model::TYPE_WIRELESS ?>][items][' + i + '][name]',
'class' : 'textbox',
'type' : 'text'
}).html(wiface_mode_options).css('margin', '4px 15px')
)
).append(
$('<td>').html($('<label>').text('<?php echo __('Mode') ?>:')).append(
$('<select>').attr({
'name' : 'values[<?php echo Iface_Model::TYPE_WIRELESS ?>][items][' + i + '][wireless_mode]',
......
}
}
/**
* Makes internal ifaces inputs - enables to add name
*
* @param parent Parent object after which elements will be added
* @param count Max count of internal ifaces
*/
function make_internal_iface_inputs(parent, count)
{
var ename = 'values_internal_items';
// create root element
if (!$('#' + ename).length)
{
parent.after($('<tr>').append(
$('<td>').attr('colspan', '2').append(
$('<table>').attr('id', ename).css('margin', '4px 20px')
)
));
}
// limit
if (count > 99)
{
count = 99;
}
var e = $('#' + ename);
var ch_count = e.find('tr').length;
// inputs alread added but there is too much of them => drop some of them
if (ch_count > count)
{
for (var i = count; i < ch_count; i++)
{
e.find('#' + ename + '_id_' + i).remove();
}
}
// add missing items
else if (ch_count < count)
{
for (var i = ch_count; i < count; i++)
{
e.append($('<tr>').attr('id', ename + '_id_' + i).append(
$('<td>').html($('<label>').text('<?php echo __('Name') ?>:')).append(
$('<input>').attr({
'name' : 'values[<?php echo Iface_Model::TYPE_INTERNAL ?>][items][' + i + '][name]',
'class' : 'textbox',
'type' : 'text'
}).css('margin', '4px 15px')
)
));
}
}
}
/** Last value of wiface_min_max_keyup (cache) */
var wiface_min_max_keyup_cache = null;
......
}
}
/** Last value of internal internal_iface_min_max_keyup (cache) */
var internal_iface_min_max_keyup_cache = null;
/**
* Decrease or increase of value of given element
*
* @param e Element
* @param decrease boolean indicator of decrease [optional]
* Processes key events of inputs that allows to fill counts of internal ifaces
*
* @param e Elements who trigger event
*/
function element_decrease_increase(e, decrease)
function internal_iface_min_max_keyup(e)
{
var v = parseInt(e.val());
var emin_count = $('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][min_count]"]');
var emax_count = $('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][max_count]"]');
var min_count = emin_count.val();
var max_count = emax_count.val();
if (isNaN(v))
if (!max_count.length)
{
v = 0;
max_count = 0;
}
if (decrease != undefined && decrease)
else if (isNaN(max_count) || isNaN(min_count))
{
if (v > 0)
if (isNaN(max_count) && isNaN(min_count))
{
e.val(v - 1);
e.trigger('keyup');
return false;
}
else if (isNaN(max_count))
{
max_count = 0;
}
else if (isNaN(min_count))
{
min_count = 0;
}
}
else
min_count = parseInt(min_count);
max_count = parseInt(max_count);
if (max_count < min_count)
{
e.val(v + 1);
e.trigger('keyup');
max_count = min_count;
emax_count.val(max_count);
}
return false;
if (max_count != internal_iface_min_max_keyup_cache)
{
internal_iface_min_max_keyup_cache = max_count;
make_internal_iface_inputs(emax_count.parent().parent(), max_count);
}
}
/// triggers code //////////////////////////////////////////////////////////
......
var e_internal_min_count = $('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][min_count]"]');
var e_internal_max_count = $('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][max_count]"]');
// on change of ethernet count
e_ethernet_count.keyup(function ()
{
var count = $(this).val();
if (!count.length)
{
count = 0;
}
else if (isNaN(count))
{
return false;
}
make_ethernet_inputs($(this).parent().parent(), count);
});
// on change of port count
e_port_count.keyup(function ()
{
......
e_wireless_min_count.keyup(wiface_min_max_keyup);
// on change of max wireless ifaces count
e_wireless_max_count.keyup(wiface_min_max_keyup);
// on change of min wireless ifaces count
e_internal_max_count.keyup(internal_iface_min_max_keyup);
// on change of max wireless ifaces count
e_internal_max_count.keyup(internal_iface_min_max_keyup);
// add buttons for increasing, decreasing
input_add_increase_decrease_buttons(e_port_count, 0, 99);
......
/// edit functionality /////////////////////////////////////////////////////
e_ethernet_count.trigger('keyup');
e_port_count.trigger('keyup');
e_wireless_min_count.trigger('keyup');
e_wireless_max_count.trigger('keyup');
e_internal_min_count.trigger('keyup');
e_internal_max_count.trigger('keyup');
// set values of ethernet ifaces items
<?php $i = 0; foreach ($device_template_value[Iface_Model::TYPE_ETHERNET]['items'] as $item): ?>
$('input[name="values[<?php echo Iface_Model::TYPE_ETHERNET ?>][items][<?php echo $i++ ?>][name]"]').val('<?php echo $item['name'] ?>');
<?php endforeach; ?>
// set values of wireless ifaces items
<?php $i = 0; foreach ($device_template_value[Iface_Model::TYPE_WIRELESS]['items'] as $item): ?>
$('input[name="values[<?php echo Iface_Model::TYPE_WIRELESS ?>][items][<?php echo $i ?>][name]"]').val('<?php echo $item['name'] ?>');
$('select[name="values[<?php echo Iface_Model::TYPE_WIRELESS ?>][items][<?php echo $i ?>][wireless_mode]"]').val('<?php echo $item['wireless_mode'] ?>');
$('select[name="values[<?php echo Iface_Model::TYPE_WIRELESS ?>][items][<?php echo $i++ ?>][wireless_antenna]"]').val('<?php echo $item['wireless_antenna'] ?>');
<?php endforeach; ?>
// set values of port items
<?php $i = 0; foreach ($device_template_value[Iface_Model::TYPE_PORT]['items'] as $item): ?>
$('input[name="values[<?php echo Iface_Model::TYPE_PORT ?>][items][<?php echo $i ?>][name]"]').val('<?php echo $item['name'] ?>');
$('select[name="values[<?php echo Iface_Model::TYPE_PORT ?>][items][<?php echo $i ?>][port_mode]"]').val('<?php echo $item['port_mode'] ?>');
$('input[name="values[<?php echo Iface_Model::TYPE_PORT ?>][items][<?php echo $i++ ?>][number]"]').val('<?php echo $item['number'] ?>');
<?php endforeach; ?>
// set values of internal ifaces items
<?php $i = 0; foreach ($device_template_value[Iface_Model::TYPE_INTERNAL]['items'] as $item): ?>
$('input[name="values[<?php echo Iface_Model::TYPE_INTERNAL ?>][items][<?php echo $i++ ?>][name]"]').val('<?php echo $item['name'] ?>');
<?php endforeach; ?>
<?php endif; ?>
freenetis/branches/network/application/views/js/devices_add.php
$td.append(iface_hid).append($('<a>', {
href : '#',
click : add_detail_to_iface,
style : 'margin: 8px 3px',
style : 'margin: 4px',
title : '<?php echo __('Add details to interface') ?>'
}).html('<?php echo html::image(array('src' => 'media/images/icons/settings.gif')) ?>'));
......
}).addClass('ip_address')).append(ip_hiddden).append($('<a>', {
href : '#',
click : add_detail_to_ip,
style : 'margin: 8px 3px',
style : 'margin: 4px',
title : '<?php echo __('Add details to IP address') ?>'
}).html('<?php echo html::image(array('src' => 'media/images/icons/settings.gif')) ?>'))
).append(
......
}).bind('change', change_connected).html(arr_devices)).append($('<a>', {
href : '#',
click : select_device_using_map,
style : 'margin: 8px 3px',
style : 'margin: 4px',
title : '<?php echo __('Select device using device map') ?>'
}).html('<?php echo html::image(array('src' => 'media/images/icons/map_icon.gif')) ?>')).append(($('<select>', {
name : 'connected_iface[' + i + ']',
......
}))).append(link_hid).append($('<a>', {
href : '#',
click : add_detail_to_link,
style : 'margin: 8px 3px',
style : 'margin: 4px',
title : '<?php echo __('Add details to link') ?>'
}).html('<?php echo html::image(array('src' => 'media/images/icons/settings.gif')) ?>'))
);
freenetis/branches/network/application/views/device_templates/show.php
<h2><?php echo __('Device template') ?> - <?php echo $device_template->name ?></h2>
<?php if ($this->acl_check_edit('Devices_Controller', 'devices')):
echo html::anchor('device_templates/edit/' . $device_template->id, __('Edit'));
endif;
<?php
$arr_links = array();
if ($this->acl_check_edit('Devices_Controller', 'devices'))
$arr_links[] = html::anchor('device_templates/edit/' . $device_template->id, __('Edit'));
if ($this->acl_check_delete('Devices_Controller', 'devices'))
$arr_links[] = html::anchor('device_templates/delete/' . $device_template->id, __('Delete'), array('class' => 'delete_link'));
echo implode(' | ', $arr_links);
?>
<br /><br />
......
<th><?php echo __('Count') ?></th>
<td><?php echo $ivals[Iface_Model::TYPE_ETHERNET]['count'] ?></td>
</tr>
<tr>
<th><?php echo __('Names') ?></th>
<td><?php foreach ($ivals[Iface_Model::TYPE_ETHERNET]['items'] as $item) echo $item['name'] . ', ' ?></td>
</tr>
</table>
<br /><h3><?php echo __('Wireless interfaces') ?></h3>
......
<table class="extended" cellspacing="0">
<tr>
<th><?php echo __('Name') ?></th>
<th><?php echo __('Wireless mode') ?></th>
<th><?php echo __('Wireless antenna') ?></th>
</tr>
<?php foreach ($ivals[Iface_Model::TYPE_WIRELESS]['items'] as $item): ?>
<tr>
<td><?php echo $iface_model->get_wireless_mode($item['wireless_mode']) ?></td>
<td><?php echo $iface_model->get_wireless_antenna($item['wireless_antenna']) ?></td>
<td><?php echo $item['name'] ?></td>
<td><?php echo $iface_model->get_wireless_mode(@$item['wireless_mode']) ?></td>
<td><?php echo $iface_model->get_wireless_antenna(@$item['wireless_antenna']) ?></td>
</tr>
<?php endforeach; ?>
</table>
......
<table class="extended" cellspacing="0">
<tr>
<th><?php echo __('Name') ?></th>
<th><?php echo __('Port number') ?></th>
<th><?php echo __('Port mode') ?></th>
</tr>
<?php foreach ($ivals[Iface_Model::TYPE_PORT]['items'] as $item): ?>
<tr>
<td><?php echo $item['name'] ?></td>
<td><?php echo __('Port') ?> <?php echo $item['number'] ?></td>
<td><?php echo $iface_model->get_port_mode($item['port_mode']) ?></td>
</tr>
......
<th><?php echo __('Maximal count') ?></th>
<td><?php echo $ivals[Iface_Model::TYPE_INTERNAL]['max_count'] ?></td>
</tr>
<tr>
<th><?php echo __('Names') ?></th>
<td><?php foreach ($ivals[Iface_Model::TYPE_INTERNAL]['items'] as $item) echo $item['name'] . ', ' ?></td>
</tr>
</table>

Také k dispozici: Unified diff