sibtracker/system/modules/addimg.php
2019-05-18 13:46:03 +08:00

71 lines
2.2 KiB
PHP

<?php
if( ! defined( 'DATALIFEENGINE' ) ) {
die( "Hacking attempt!" );
}
require_once ROOT_DIR.'/language/'.$config['langs'].'/img.lng';
#### IMG
$addim = "<script language=\"javascript\" type=\"text/javascript\">
function ShowOrHideEx(id, show) {
var item = null;
if (document.getElementById) {
item = document.getElementById(id);
} else if (document.all) {
item = document.all[id];
} else if (document.layers){
item = document.layers[id];
}
if (item && item.style) {
item.style.display = show ? \"\" : \"none\";
}
}
var total_allow_rows = {$config['max_file_count']};
function AddImages() {
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
if (total_allow_rows && lastRow == total_allow_rows ) return;
// if there's no header row in the table, then iteration = lastRow + 1
var iteration = lastRow+1;
var row = tbl.insertRow(lastRow);
var cellRight = row.insertCell(0);
var el = document.createElement('input');
el.setAttribute('type', 'file');
el.setAttribute('name', 'addimg_' + iteration);
el.setAttribute('size', '41');
el.setAttribute('value', iteration);
cellRight.appendChild(el);
document.getElementById('images_number').value = iteration;
}
function RemoveImages() {
var tbl = document.getElementById('tblSample');
var lastRow = tbl.rows.length;
if (lastRow > 1){
tbl.deleteRow(lastRow - 1);
document.getElementById('images_number').value = document.getElementById('images_number').value - 1;
}
}
</script>";
$addim .= <<<HTML
<input type="hidden" name="images_number" id="images_number" value="1">
<table id="tblSample" class="upload">
<tr id="row">
<td><input type="file" size="41" name="addimg_1">&nbsp;<input type=button class=buttons value=' - ' style="width:30px;" title='{$lang['images_rem_tl']}' onClick="RemoveImages();return false;"><input type=button class=buttons value=' + ' style="width:30px;" title='{$lang['images_add_tl']}' onClick="AddImages();return false;"> &nbsp;</td>
</tr>
</table>
HTML;
$tpl->set( '{addimg}', $addim );
#### IMG
?>