mirror of
https://github.com/devcode-it/openstamanager.git
synced 2025-06-05 22:09:38 +02:00
Commit iniziale (r1662)
Migrazione da SourceForge, partendo dal commit 1662 della carrtella trunk/openstamanager.
This commit is contained in:
52
modules/gestione_componenti/actions.php
Normal file
52
modules/gestione_componenti/actions.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$path = $docroot.'/files/my_impianti/';
|
||||
|
||||
switch (post('op')) {
|
||||
case 'update':
|
||||
$nomefile = post('nomefile');
|
||||
$contenuto = post('contenuto');
|
||||
|
||||
if (!file_put_contents($path.$nomefile, $contenuto)) {
|
||||
$_SESSION['errors'][] = _('Impossibile modificare il file!');
|
||||
} else {
|
||||
$_SESSION['infos'][] = _('Informazioni salvate correttamente!');
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
$nomefile = str_replace('.ini', '', post('nomefile')).'.ini';
|
||||
$contenuto = post('contenuto');
|
||||
|
||||
$cmp = \Util\Ini::getList($path);
|
||||
|
||||
$duplicato = false;
|
||||
for ($c = 0; $c < count($cmp); ++$c) {
|
||||
if ($nomefile == $cmp[$c][0]) {
|
||||
$duplicato = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($duplicato) {
|
||||
$_SESSION['errors'][] = str_replace('_FILE_', "'".$nomefile."'", _('Il file componente _FILE_ esiste già, nessun nuovo componente è stato creato!'));
|
||||
} elseif (!file_put_contents($path.$nomefile, $contenuto)) {
|
||||
$_SESSION['errors'][] = _('Impossibile creare il file!');
|
||||
} else {
|
||||
$_SESSION['infos'][] = str_replace('_FILE_', "'".$nomefile."'", _('Componente _FILE_ aggiunto correttamente!'));
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'delete':
|
||||
$nomefile = post('nomefile');
|
||||
|
||||
if (!empty($nomefile)) {
|
||||
unlink($path.$nomefile);
|
||||
$_SESSION['infos'][] = str_replace('_FILE_', "'".$nomefile."'", _('File _FILE_ rimosso correttamente!'));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
40
modules/gestione_componenti/add.php
Normal file
40
modules/gestione_componenti/add.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
?><form action="editor.php?id_module=$id_module$" method="post">
|
||||
<input type="hidden" name="op" value="add">
|
||||
<input type="hidden" name="backto" value="record-list">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "text", "label": "<?php echo _('Nome file'); ?>", "name": "nomefile", "required": 1, "value": "" ]}
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-md-12">
|
||||
<a href="#" class="pull-right" id="default">[Default]</a>
|
||||
{[ "type": "textarea", "label": "<?php echo _('Contenuto'); ?>", "name": "contenuto", "required": 1, "class": "autosize", "value": "", "extra": "rows='10'" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- PULSANTI -->
|
||||
<div class="row">
|
||||
<div class="col-md-12 text-right">
|
||||
<button type="submit" class="btn btn-primary"><i class="fa fa-plus"></i> <?php echo _('Aggiungi'); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready( function(){
|
||||
$('#default').click( function(){
|
||||
if (confirm ('Generare un componente di default?')){
|
||||
|
||||
var ini = '[Nome]\ntipo = span\nvalore = "Componente di esempio"\n\n[Marca]\ntipo = input\nvalore =\n\n[Tipo]\ntipo = select\nvalore =\nopzioni = "Tipo 1", "Tipo 2"\n\n[Data di installazione]\ntipo = date\nvalore =\n\n[Note]\ntipo = textarea\nvalore =\n';
|
||||
|
||||
$( "#contenuto" ).val(ini);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
68
modules/gestione_componenti/edit.php
Normal file
68
modules/gestione_componenti/edit.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
if (empty($id_record)) {
|
||||
echo '
|
||||
<table width="100%" class="datatables table table-striped table-hover table-condensed table-bordered">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="10%">'._('Numero').'</th>
|
||||
<th>'._('Nome del file').'</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>';
|
||||
|
||||
for ($c = 1; $c <= count($cmp); ++$c) {
|
||||
echo '
|
||||
<tr class="clickable" onclick="openLink(event, \''.$rootdir.'/editor.php?id_module='.$id_module.'&id_record='.$c.'\')">
|
||||
<td>'.$c.'</td>
|
||||
<td>'.$cmp[$c-1][0].'</td>
|
||||
</tr>';
|
||||
}
|
||||
echo '
|
||||
</tbody>
|
||||
</table>';
|
||||
} else {
|
||||
?>
|
||||
<form action="" method="post" role="form" enctype="multipart/form-data">
|
||||
<input type="hidden" name="backto" value="record-edit">
|
||||
<input type="hidden" name="op" value="update">
|
||||
|
||||
<!-- DATI ANAGRAFICI -->
|
||||
<div class="panel panel-primary">
|
||||
<div class="panel-heading">
|
||||
<h3 class="panel-title"><?php echo _('Componente'); ?></h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body">
|
||||
|
||||
<div class="pull-right">
|
||||
<button type="submit" class="btn btn-success"><i class="fa fa-check"></i> <?php echo _('Salva modifiche'); ?></button>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
{[ "type": "text", "label": "<?php echo _('Nome file'); ?>", "name": "nomefile", "required": 1, "value": "$nomefile$", "readonly": 1 ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
{[ "type": "textarea", "label": "<?php echo _('Contenuto'); ?>", "name": "contenuto", "required": 1, "class": "autosize", "value": "$contenuto$" ]}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<a class="btn btn-danger ask" data-backto="record-list" data-nomefile="<?php echo $records[0]['nomefile']; ?>">
|
||||
<i class="fa fa-trash"></i> <?php echo _('Elimina'); ?>
|
||||
</a>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
10
modules/gestione_componenti/init.php
Normal file
10
modules/gestione_componenti/init.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
include_once __DIR__.'/../../core.php';
|
||||
|
||||
$cmp = \Util\Ini::getList($docroot.'/files/my_impianti/');
|
||||
|
||||
if (!empty($id_record) && isset($cmp[$id_record - 1])) {
|
||||
$records[0]['nomefile'] = $cmp[$id_record - 1][0];
|
||||
$records[0]['contenuto'] = file_get_contents($docroot.'/files/my_impianti/'.$records[0]['nomefile']);
|
||||
}
|
||||
Reference in New Issue
Block a user