Fix upload page

This commit is contained in:
Romain Neutron
2011-12-21 17:50:17 +01:00
parent e1626b20ad
commit c7be5710a6

View File

@@ -26,7 +26,6 @@ function filize($x)
return '*.' . $x; return '*.' . $x;
} }
User_Adapter::updateClientInfos(8); User_Adapter::updateClientInfos(8);
phrasea::headers(); phrasea::headers();
@@ -41,7 +40,7 @@ if (count($avBases) == 0)
{ {
header("Content-Type: text/html; charset=UTF-8"); header("Content-Type: text/html; charset=UTF-8");
?> ?>
<html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $session->get_I18n(); ?>"> <html xmlns="http://www.w3.org/1999/xhtml" lang="<?php echo $session->get_I18n(); ?>">
<head> <head>
@@ -61,279 +60,281 @@ if (count($avBases) == 0)
color:white; color:white;
} }
</style> </style>
<script type="text/javascript" src="/include/jslibs/jquery-1.5.2.js"></script> <script type="text/javascript" src="/include/jslibs/jquery-1.5.2.js"></script>
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.12/js/jquery-ui-1.8.12.custom.min.js"></script> <script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.12/js/jquery-ui-1.8.12.custom.min.js"></script>
<script type="text/javascript" src="/include/minify/g=upload"></script> <script type="text/javascript" src="/include/minify/g=upload"></script>
</head> </head>
<body> <body>
<?php <?php
$twig = new supertwig(); $twig = new supertwig();
$twig->display('common/menubar.twig', array('module' => 'upload')); $twig->display('common/menubar.twig', array('module' => 'upload'));
?> ?>
<div id="content"> <div id="content">
<?php echo _('upload:You do not have right to upload datas'); ?> <?php echo _('upload:You do not have right to upload datas'); ?>
</div> </div>
</body> </body>
</html> </html>
<?php <?php
die(); die();
}
$colls = '';
$datasSB = array();
$dstatus = databox_status::getDisplayStatus();
foreach ($appbox->get_databoxes() as $databox)
{
$groupopen = false;
$sbas_id = $databox->get_sbas_id();
foreach ($databox->get_collections() as $collection)
{
if (in_array($collection->get_base_id(), $avBases))
{
if (!$groupopen)
{
$colls .= '<optgroup label="' . phrasea::sbas_names($sbas_id) . '">';
$groupopen = true;
}
$colls .= '<option value="' . $collection->get_base_id() . '">' . $collection->get_name() . '</option>';
} }
$colls = ''; if (in_array($collection->get_base_id(), $avStatus))
$datasSB = array();
$dstatus = databox_status::getDisplayStatus();
foreach ($appbox->get_databoxes() as $databox)
{ {
$groupopen = false; $status = '0000000000000000000000000000000000000000000000000000000000000000';
$sbas_id = $databox->get_sbas_id(); if ($sxe = simplexml_load_string($collection->get_prefs()))
foreach ($databox->get_collections() as $collection)
{ {
if (in_array($collection->get_base_id(), $avBases)) if ($sxe->status)
{ {
if (!$groupopen) $status = databox_status::hex2bin((string) ($sxe->status));
{
$colls .= '<optgroup label="' . phrasea::sbas_names($sbas_id) . '">';
$groupopen = true;
}
$colls .= '<option value="' . $collection->get_base_id() . '">' . $collection->get_name() . '</option>';
}
if (in_array($collection->get_base_id(), $avStatus)) while (strlen($status) < 64)
{ $status = '0' . $status;
$status = '0000000000000000000000000000000000000000000000000000000000000000';
if ($sxe = simplexml_load_string($collection->get_prefs()))
{
if ($sxe->status)
{
$status = databox_status::hex2bin((string) ($sxe->status));
while (strlen($status) < 64)
$status = '0' . $status;
}
}
$datasSB[$collection->get_base_id()] = '<div style="display:none;" class="status_box" id="status_' . $collection->get_base_id() . '"><table>';
$currentdatasSB = '';
if (isset($dstatus[$sbas_id]))
{
foreach ($dstatus[$sbas_id] as $n => $statbit)
{
$imgoff = '';
$imgon = '';
if ($statbit['img_off'])
$imgoff = '<img src="' . $statbit['img_off'] . '" title="' . $statbit['labeloff'] . '" style="width:16px;height:16px;vertical-align:bottom" />';
if ($statbit['img_on'])
$imgon = '<img src="' . $statbit['img_on'] . '" title="' . $statbit['labelon'] . '" style="width:16px;height:16px;vertical-align:bottom" />';
$datasSB[$collection->get_base_id()] .= '
<tr style="height: 24px;">
<td id="status_off_' . $collection->get_base_id() . '_' . $n . '" class="status_off ' . (($status[63 - (int) $n] == '0') ? 'active' : '') . '">' .
$imgoff . ' ' . $statbit['labeloff'] .
'</td>
<td> <div style="width:50px;margin:0 20px;" class="slider_status"></div></td>
<td class="status_on ' . (($status[63 - (int) $n] == '1') ? 'active' : '') . '" id="status_on_' . $collection->get_base_id() . '_' . $n . '">' .
$imgon . ' ' . $statbit['labelon'] . '</td>
</tr>';
}
}
$datasSB[$collection->get_base_id()] .= '</table></div>';
} }
} }
if ($groupopen)
$colls .= '</optgroup>'; $datasSB[$collection->get_base_id()] = '<div style="display:none;" class="status_box" id="status_' . $collection->get_base_id() . '"><table>';
$currentdatasSB = '';
if (isset($dstatus[$sbas_id]))
{
foreach ($dstatus[$sbas_id] as $n => $statbit)
{
$imgoff = '';
$imgon = '';
if ($statbit['img_off'])
$imgoff = '<img src="' . $statbit['img_off'] . '" title="' . $statbit['labeloff'] . '" style="width:16px;height:16px;vertical-align:bottom" />';
if ($statbit['img_on'])
$imgon = '<img src="' . $statbit['img_on'] . '" title="' . $statbit['labelon'] . '" style="width:16px;height:16px;vertical-align:bottom" />';
$datasSB[$collection->get_base_id()] .= '
<tr style="height: 24px;">
<td id="status_off_' . $collection->get_base_id() . '_' . $n . '" class="status_off ' . (($status[63 - (int) $n] == '0') ? 'active' : '') . '">' .
$imgoff . ' ' . $statbit['labeloff'] .
'</td>
<td> <div style="width:50px;margin:0 20px;" class="slider_status"></div></td>
<td class="status_on ' . (($status[63 - (int) $n] == '1') ? 'active' : '') . '" id="status_on_' . $collection->get_base_id() . '_' . $n . '">' .
$imgon . ' ' . $statbit['labelon'] . '</td>
</tr>';
}
}
$datasSB[$collection->get_base_id()] .= '</table></div>';
} }
}
if ($groupopen)
$colls .= '</optgroup>';
}
$maxVolume = min((int) get_cfg_var('upload_max_filesize'), (int) get_cfg_var('post_max_size')); $maxVolume = min((int) get_cfg_var('upload_max_filesize'), (int) get_cfg_var('post_max_size'));
header("Content-Type: text/html; charset=UTF-8"); header("Content-Type: text/html; charset=UTF-8");
?> ?>
<html xmlns="http://www.w3.org/1999/xhtml" > <html xmlns="http://www.w3.org/1999/xhtml" >
<head> <head>
<title><?php echo $registry->get('GV_homeTitle'), ' ', _('admin::monitor: module upload'); ?></title> <title><?php echo $registry->get('GV_homeTitle'), ' ', _('admin::monitor: module upload'); ?></title>
<link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" />
<link type="text/css" rel="stylesheet" href="/include/minify/f=skins/common/main.css,include/jslibs/jquery.contextmenu.css" /> <link type="text/css" rel="stylesheet" href="/include/minify/f=skins/common/main.css,include/jslibs/jquery.contextmenu.css" />
<link href="css/jquery-ui-1.8.5.custom.css" rel="stylesheet" type="text/css" /> <link href="css/jquery-ui-1.8.5.custom.css" rel="stylesheet" type="text/css" />
<link href="css/default.css" rel="stylesheet" type="text/css" /> <link href="css/default.css" rel="stylesheet" type="text/css" />
<style type="text/css"> <style type="text/css">
<?php <?php
$theFont = '.theFont {font-weight:bold;color:#73B304;font-size: 14px;font-family:Arial }'; $theFont = '.theFont {font-weight:bold;color:#73B304;font-size: 14px;font-family:Arial }';
echo $theFont; echo $theFont;
?> ?>
</style> </style>
<script type="text/javascript" src="/include/jslibs/jquery-1.5.2.js"></script> <script type="text/javascript" src="/include/jslibs/jquery-1.5.2.js"></script>
<script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.12/js/jquery-ui-1.8.12.custom.min.js"></script> <script type="text/javascript" src="/include/jslibs/jquery-ui-1.8.12/js/jquery-ui-1.8.12.custom.min.js"></script>
<script type="text/javascript" src="/include/minify/g=upload"></script> <script type="text/javascript" src="/include/minify/g=upload"></script>
<script type="text/javascript"> <script type="text/javascript">
var p4 = {}; var p4 = {};
var language = { var language = {
'ok':'<?php echo str_replace("'", "\'", _('boutton::valider')) ?>', 'ok':'<?php echo str_replace("'", "\'", _('boutton::valider')) ?>',
'annuler':'<?php echo str_replace("'", "\'", _('boutton::annuler')) ?>', 'annuler':'<?php echo str_replace("'", "\'", _('boutton::annuler')) ?>',
'pleaseselect':'<?php echo str_replace("'", "\'", 'pleaseselect':'<?php echo str_replace("'", "\'", _('Selectionner une action')) ?>',
_('Selectionner une action')) ?>', 'norecordselected':'<?php echo str_replace("'", "\'", _('Aucune enregistrement selectionne')) ?>',
'norecordselected':'<?php echo str_replace("'", "\'", 'transfert_active':'<?php echo str_replace("'", "\'", _('Transfert en court, vous devez attendre la fin du transfert')) ?>',
_('Aucune enregistrement selectionne')) ?>', 'queue_not_empty' : '<?php echo str_replace("'", "\'", _('File d\'attente n\'est pas vide, souhaitez vous supprimer ces elements ?')) ?>'
'transfert_active':'<?php echo str_replace("'", "\'", _('Transfert en court, vous devez attendre la fin du transfert')) ?>', };
'queue_not_empty' : '<?php echo str_replace("'", "\'", _('File d\'attente n\'est pas vide, souhaitez vous supprimer ces elements ?')) ?>'
};
function sessionactive(){ function sessionactive(){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/include/updses.php", url: "/include/updses.php",
dataType: 'json', dataType: 'json',
data: { data: {
app : 8, app : 8,
usr : <?php echo $usr_id ?> usr : <?php echo $usr_id ?>
}, },
error: function(){ error: function(){
window.setTimeout("sessionactive();", 10000); window.setTimeout("sessionactive();", 10000);
}, },
timeout: function(){ timeout: function(){
window.setTimeout("sessionactive();", 10000); window.setTimeout("sessionactive();", 10000);
}, },
success: function(data){ success: function(data){
if(data) if(data)
manageSession(data); manageSession(data);
var t = 120000; var t = 120000;
if(data.apps && parseInt(data.apps)>1) if(data.apps && parseInt(data.apps)>1)
t = Math.round((Math.sqrt(parseInt(data.apps)-1) * 1.3 * 120000)); t = Math.round((Math.sqrt(parseInt(data.apps)-1) * 1.3 * 120000));
window.setTimeout("sessionactive();", t); window.setTimeout("sessionactive();", t);
return; return;
}
})
};
sessionactive();
window.onbeforeunload = function()
{
var xhr_object = null;
if(window.XMLHttpRequest) // Firefox
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // Internet Explorer
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else // XMLHttpRequest non supporte par le navigateur
return;
url= "../include/delses.php?app=8&t="+Math.random();
xhr_object.open("GET", url, false);
xhr_object.send(null);
};
//This event comes from the Queue Plugin
function queueComplete(numFilesUploaded) {
var status = document.getElementById("divStatus");
if(numFilesUploaded>1)
status.innerHTML = $.sprintf("<?php echo str_replace('"', '&quot;', _('upload:: %d fichiers uploades')); ?>",numFilesUploaded);
else
status.innerHTML = $.sprintf("<?php echo str_replace('"', '&quot;', _('upload:: %d fichier uploade')); ?>",numFilesUploaded);
var n_quarantine = $('#QUEUE li.progressWrapper.done .progressContainer.orange.quarantine').size();
if(n_quarantine > 0)
alert('<?php echo str_replace("'", "\'", _('Certains elements uploades sont passes en quarantaine')); ?>');
$('#QUEUE li.done .quarantine').removeClass('quarantine');
checkQuarantineSize();
} }
})
};
sessionactive();
$(document).ready(function() { window.onbeforeunload = function()
var settings = { {
flash_url : "swfupload/swfupload.swf", var xhr_object = null;
upload_url: "upload.php", if(window.XMLHttpRequest) // Firefox
post_params: {"session" : "<?php echo session_id(); ?>"}, xhr_object = new XMLHttpRequest();
file_size_limit : "<?php echo $maxVolume . ' MB'; ?>", else if(window.ActiveXObject) // Internet Explorer
file_types : "<?php echo implode(';', array_map("filize", explode(',', $registry->get('GV_appletAllowedFileExt')))) ?>", xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
file_types_description : "These Files", else // XMLHttpRequest non supporte par le navigateur
file_upload_limit : 0,
requeue_on_error : true,
file_post_name : "Filedata",
file_queue_limit : 0,
custom_settings : {
progressTarget : "fsUploadProgress",
cancelButtonId : "btnCancel"
},
debug:false,
// Button settings return;
button_image_url: "images/fond400.gif", url= "../include/delses.php?app=8&t="+Math.random();
button_width: "400", xhr_object.open("GET", url, false);
button_height: "30", xhr_object.send(null);
button_placeholder_id: "spanButtonPlaceHolder",
button_text: '<span class="theFont"><?php echo str_replace("'", "\'", sprintf(_('upload :: choisir les fichiers a uploader (max : %d MB)'), $maxVolume)); ?></span>', };
button_text_style: "<?php echo $theFont ?>",
button_text_left_padding: 12, //This event comes from the Queue Plugin
button_text_top_padding: 3, function queueComplete(numFilesUploaded) {
button_window_mode:'transparent', var status = document.getElementById("divStatus");
button_cursor : SWFUpload.CURSOR.HAND, if(numFilesUploaded>1)
status.innerHTML = $.sprintf("<?php echo str_replace('"', '&quot;', _('upload:: %d fichiers uploades')); ?>",numFilesUploaded);
else
status.innerHTML = $.sprintf("<?php echo str_replace('"', '&quot;', _('upload:: %d fichier uploade')); ?>",numFilesUploaded);
var n_quarantine = $('#QUEUE li.progressWrapper.done .progressContainer.orange.quarantine').size();
if(n_quarantine > 0)
alert('<?php echo str_replace("'", "\'", _('Certains elements uploades sont passes en quarantaine')); ?>');
$('#QUEUE li.done .quarantine').removeClass('quarantine');
checkQuarantineSize();
}
$(document).ready(function() {
var settings = {
flash_url : "swfupload/swfupload.swf",
upload_url: "upload.php",
post_params: {"session" : "<?php echo session_id(); ?>"},
file_size_limit : "<?php echo $maxVolume . ' MB'; ?>",
file_types : "<?php echo implode(';', array_map("filize", explode(',', $registry->get('GV_appletAllowedFileExt')))) ?>",
file_types_description : "These Files",
file_upload_limit : 0,
requeue_on_error : true,
file_post_name : "Filedata",
file_queue_limit : 0,
custom_settings : {
progressTarget : "fsUploadProgress",
cancelButtonId : "btnCancel"
},
debug:false,
// Button settings
button_image_url: "images/fond400.gif",
button_width: "400",
button_height: "30",
button_placeholder_id: "spanButtonPlaceHolder",
button_text: '<span class="theFont"><?php echo str_replace("'", "\'", sprintf(_('upload :: choisir les fichiers a uploader (max : %d MB)'), $maxVolume)); ?></span>',
button_text_style: "<?php echo $theFont ?>",
button_text_left_padding: 12,
button_text_top_padding: 3,
button_window_mode:'transparent',
button_cursor : SWFUpload.CURSOR.HAND,
// The event handler functions are defined in handlers.js // The event handler functions are defined in handlers.js
file_queued_handler : fileQueued, file_queued_handler : fileQueued,
file_queue_error_handler : fileQueueError, file_queue_error_handler : fileQueueError,
file_dialog_complete_handler : fileDialogComplete, file_dialog_complete_handler : fileDialogComplete,
upload_start_handler : uploadStart, upload_start_handler : uploadStart,
upload_progress_handler : uploadProgress, upload_progress_handler : uploadProgress,
upload_error_handler : uploadError, upload_error_handler : uploadError,
upload_success_handler : uploadSuccess, upload_success_handler : uploadSuccess,
upload_complete_handler : uploadComplete, upload_complete_handler : uploadComplete,
queue_complete_handler : queueComplete // Queue plugin event queue_complete_handler : queueComplete // Queue plugin event
}; };
swfu = new SWFUpload(settings); swfu = new SWFUpload(settings);
$('#step1 .classic_switch, #flash_return .classic_switch').bind('click', function(event){ $('#step1 .classic_switch, #flash_return .classic_switch').bind('click', function(event){
classic_switch(); classic_switch();
return false; return false;
}); });
}); });
function reverseOrder() function reverseOrder()
{ {
var elems = $('#fsUploadProgress li'); var elems = $('#fsUploadProgress li');
var arr = $.makeArray(elems); var arr = $.makeArray(elems);
arr.reverse(); arr.reverse();
$(arr).appendTo($('#fsUploadProgress')); $(arr).appendTo($('#fsUploadProgress'));
} }
function classic_switch() function classic_switch()
{ {
$('#step1, #step2, #step2classic, #step4, #flash_return').toggle(); $('#step1, #step2, #step2classic, #step4, #flash_return').toggle();
} }
</script> </script>
</head> </head>
<body> <body>
<?php <?php
$count = 0; $count = 0;
try try
{ {
$lazaret = new lazaret(); $lazaret = new lazaret();
$count = $lazaret->get_count(); $count = $lazaret->get_count();
} }
catch (Exception $e) catch (Exception $e)
{ {
}
} $twig = new supertwig();
$twig->display('common/menubar.twig'
$twig = new supertwig(); , array(
$twig->display('common/menubar.twig', array('module' => 'upload')); 'module' => 'upload'
?> , 'events' => eventsmanager_broker::getInstance($appbox)
));
?>
<div id="content"> <div id="content">
<div class="tabs"> <div class="tabs">
<ul> <ul>
@@ -364,7 +365,7 @@ if (count($avBases) == 0)
</div> </div>
<div style="text-align:right"> <div style="text-align:right">
<a href="javascript:void();" onclick="reverseOrder(); return(false);"> <a href="javascript:void();" onclick="reverseOrder(); return(false);">
<?php echo _('upload:: inverser') ?> <?php echo _('upload:: inverser') ?>
</a> </a>
</div> </div>
</div> </div>
@@ -387,14 +388,14 @@ if (count($avBases) == 0)
<span class="legend"><?php echo _('upload:: Que faire avec les fichiers') ?></span> <span class="legend"><?php echo _('upload:: Que faire avec les fichiers') ?></span>
<div id="coll_selector"> <div id="coll_selector">
<label for="collselect"><?php echo _('upload:: Destination (collection) :') ?></label><select id="collselect" onchange="showStatus();"><?php echo $colls ?></select> <label for="collselect"><?php echo _('upload:: Destination (collection) :') ?></label><select id="collselect" onchange="showStatus();"><?php echo $colls ?></select>
<?php echo _('upload:: Status :') ?> <?php echo _('upload:: Status :') ?>
<div id="status_wrapper"> <div id="status_wrapper">
<?php <?php
foreach ($datasSB as $base_id => $dat) foreach ($datasSB as $base_id => $dat)
{ {
echo $dat; echo $dat;
} }
?> ?>
</div> </div>
</div> </div>
</div> </div>
@@ -428,26 +429,26 @@ if (count($avBases) == 0)
<div> <div>
<select name="action"> <select name="action">
<option value=""> <option value="">
<?php echo _('Action'); ?> <?php echo _('Action'); ?>
</option> </option>
<option value="add"> <option value="add">
<?php echo _('Ajouter les documents bloques'); ?> <?php echo _('Ajouter les documents bloques'); ?>
</option> </option>
<option value="substitute"> <option value="substitute">
<?php echo _('Substituer quand possible ou Ajouter les documents bloques'); ?> <?php echo _('Substituer quand possible ou Ajouter les documents bloques'); ?>
</option> </option>
<option value="delete"> <option value="delete">
<?php echo _('Supprimer les documents bloques'); ?> <?php echo _('Supprimer les documents bloques'); ?>
</option> </option>
</select> </select>
</div> </div>
<div> <div>
<input type="checkbox" class="delete_previous" id="delete_previous_global" /> <input type="checkbox" class="delete_previous" id="delete_previous_global" />
<label for="delete_previous_global"> <label for="delete_previous_global">
<?php echo _('Supprimer precedentes propositions a la substitution'); ?> <?php echo _('Supprimer precedentes propositions a la substitution'); ?>
</label> </label>
</div> </div>
</div> </div>
<div id="DIALOG" style="color:white;"></div> <div id="DIALOG" style="color:white;"></div>
</body> </body>
</html> </html>