230 lines
10 KiB
Smarty
230 lines
10 KiB
Smarty
<div class="title">
|
|
<h5>Управление редиректами модуля: <span class="blue">{$module_link_name}</span></h5>
|
|
</div>
|
|
|
|
<div class="breadCrumbHolder module">
|
|
<div class="breadCrumb module">
|
|
<ul>
|
|
<li>Модуль: <strong class="code">{$module_name}</strong></li>
|
|
<li>Системная ссылка: <strong class="code">{$module_link}</strong></li>
|
|
<li>Основной алиас: <strong class="code">{$module_url}</strong></li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="widget first">
|
|
<div class="head">
|
|
<h5 class="iPlus">Добавить новый редирект</h5>
|
|
</div>
|
|
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic mainForm">
|
|
<tbody>
|
|
<tr style="background: #f9f9f9;">
|
|
<td style="padding: 15px;">
|
|
<input type="text" id="new_alias_input" placeholder="Введите старый URL (например: old-page.html)" style="width: 96%;" />
|
|
</td>
|
|
<td width="100" align="center">
|
|
<select id="new_alias_code" style="width: 80px;">
|
|
<option value="301">301</option>
|
|
<option value="302">302</option>
|
|
</select>
|
|
</td>
|
|
<td width="50" align="center">
|
|
<a href="javascript:void(0);" class="icon_sprite ico_add addHistoryRecord" title="Добавить"></a>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="widget">
|
|
<div class="head">
|
|
<h5 class="iFrames">Активные редиректы</h5>
|
|
</div>
|
|
|
|
<form action="index.php?do=modules&action=alias_history_save&cp={$sess}" method="post" class="mainForm" id="HistoryForm-{$alias_id}">
|
|
<input type="hidden" name="alias_id" value="{$alias_id}">
|
|
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
|
|
<thead id="history_thead" {if !$history_list}style="display:none;"{/if}>
|
|
<tr>
|
|
<td width="20"><div align="center"><input type="checkbox" class="selall_history"></div></td>
|
|
<td style="padding-left: 10px;">Старый URL (Алиас)</td>
|
|
<td width="80" align="center">HTTP Код</td>
|
|
<td width="80" colspan="2" align="center">Действия</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="history_items_container">
|
|
{foreach from=$history_list item=h}
|
|
<tr id="history-row-{$h.id}">
|
|
<td align="center">
|
|
<input type="checkbox" class="checkbox history_check" name="history_del[{$h.id}]" value="1">
|
|
</td>
|
|
<td style="padding-left: 10px;"><span class="dgrey">{$h.module_alias}</span></td>
|
|
<td align="center"><span class="blue"><b>{$h.module_alias_header}</b></span></td>
|
|
<td width="30" align="center">
|
|
<a href="/{$h.module_alias}" class="icon_sprite ico_globus" target="_blank" title="Просмотр"></a>
|
|
</td>
|
|
<td width="30" align="center">
|
|
<a href="javascript:void(0);"
|
|
class="icon_sprite ico_delete deleteHistory"
|
|
data-id="{$h.id}"
|
|
title="Удалить"></a>
|
|
</td>
|
|
</tr>
|
|
{foreachelse}
|
|
<tr id="no-history-row">
|
|
<td colspan="5" align="center" style="padding: 30px;">
|
|
<span class="lred">История редиректов пуста</span>
|
|
</td>
|
|
</tr>
|
|
{/foreach}
|
|
</tbody>
|
|
<tfoot>
|
|
<tr>
|
|
<td colspan="5" style="padding: 10px;">
|
|
<table cellpadding="0" cellspacing="0" width="auto">
|
|
<tr>
|
|
<td style="padding-right: 10px;">
|
|
<input type="submit" id="btn_save_history" class="basicBtn SaveHistoryBatch" value="Сохранить" style="float: none; {if !$history_list}display:none;{/if}" />
|
|
</td>
|
|
<td>
|
|
<a href="javascript:void(0);" class="button redBtn CloseHistory" style="float: none; ">
|
|
Закрыть окно
|
|
</a>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</td>
|
|
</tr>
|
|
</tfoot>
|
|
</table>
|
|
</form>
|
|
</div>
|
|
|
|
{literal}
|
|
<script type="text/javascript">
|
|
$(function(){
|
|
var a_id = '{/literal}{$alias_id}{literal}';
|
|
var sess = '{/literal}{$sess}{literal}';
|
|
var $dialog = $('#ajax-dialog-alias-history-' + a_id);
|
|
var $form = $('#HistoryForm-' + a_id);
|
|
|
|
function toggleHistoryVisibility() {
|
|
var rowsCount = $('#history_items_container tr').not('#no-history-row, :hidden').length;
|
|
var $thead = $('#history_thead');
|
|
var $btnSave = $('#btn_save_history');
|
|
var $tbody = $('#history_items_container');
|
|
|
|
if (rowsCount > 0) {
|
|
$thead.show();
|
|
$btnSave.show();
|
|
$('#no-history-row').remove();
|
|
} else {
|
|
$thead.hide();
|
|
$btnSave.hide();
|
|
if ($('#no-history-row').length == 0) {
|
|
$tbody.append('<tr id="no-history-row"><td colspan="5" align="center" style="padding: 30px;"><span class="lred">История редиректов пуста</span></td></tr>');
|
|
}
|
|
}
|
|
}
|
|
|
|
$dialog.find('.CloseHistory').off('click').on('click', function(e){
|
|
e.preventDefault();
|
|
$dialog.dialog('destroy').remove();
|
|
});
|
|
|
|
$form.on('change', '.selall_history', function(){
|
|
var checked = $(this).is(':checked');
|
|
$form.find('.history_check').each(function(){
|
|
$(this).prop('checked', checked);
|
|
if(checked) $(this).addClass('jqTransformChecked');
|
|
else $(this).removeClass('jqTransformChecked');
|
|
});
|
|
});
|
|
|
|
$form.on('click', '.SaveHistoryBatch', function(e){
|
|
e.preventDefault();
|
|
var $checked = $form.find('.history_check:checked');
|
|
if($checked.length == 0) {
|
|
$.jGrowl("Ничего не выбрано", {theme: 'error'});
|
|
return false;
|
|
}
|
|
|
|
jConfirm('Удалить выбранные редиректы?', 'Подтверждение', function(r) {
|
|
if(r) {
|
|
$form.ajaxSubmit({
|
|
url: 'index.php?do=modules&action=alias_history_delete_batch&ajax=1&cp=' + sess,
|
|
dataType: 'json',
|
|
success: function(data){
|
|
if(data.status == 'success') {
|
|
$.jGrowl("Записи удалены", {theme: 'accept'});
|
|
$checked.closest('tr').fadeOut(400, function(){
|
|
$(this).remove();
|
|
toggleHistoryVisibility();
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
});
|
|
|
|
$dialog.find('.addHistoryRecord').off('click').on('click', function(e){
|
|
e.preventDefault();
|
|
var $input = $dialog.find('#new_alias_input');
|
|
var new_val = $input.val().trim();
|
|
var h_code = $dialog.find('#new_alias_code').val();
|
|
|
|
if (new_val == '') {
|
|
$.jGrowl("Введите адрес!", {theme: 'error'});
|
|
return false;
|
|
}
|
|
|
|
$.post('index.php?do=modules&action=alias_history_add&ajax=1', {
|
|
alias_id: a_id,
|
|
new_alias: new_val,
|
|
code: h_code,
|
|
cp: sess
|
|
}, function(data) {
|
|
if (data && data.status == 'success') {
|
|
$.jGrowl("Добавлено в историю", {theme: 'accept'});
|
|
var $tbody = $('#history_items_container');
|
|
|
|
var newRow = '<tr id="history-row-' + data.id + '" style="display:none;">' +
|
|
'<td align="center"><input type="checkbox" class="checkbox history_check" name="history_del['+data.id+']" value="1"></td>' +
|
|
'<td style="padding-left: 10px;"><span class="dgrey">' + new_val + '</span></td>' +
|
|
'<td align="center"><span class="blue"><b>' + h_code + '</b></span></td>' +
|
|
'<td align="center"><a href="/' + new_val + '" class="icon_sprite ico_globus" target="_blank"></a></td>' +
|
|
'<td align="center"><a href="javascript:void(0);" class="icon_sprite ico_delete deleteHistory" data-id="' + data.id + '"></a></td>' +
|
|
'</tr>';
|
|
|
|
$tbody.prepend(newRow);
|
|
$('#history-row-' + data.id).fadeIn(400);
|
|
$input.val('');
|
|
toggleHistoryVisibility();
|
|
} else {
|
|
$.jGrowl(data.message || "Ошибка сохранения", {theme: 'error'});
|
|
}
|
|
}, 'json');
|
|
});
|
|
|
|
$dialog.find('tbody').off('click', '.deleteHistory').on('click', '.deleteHistory', function(){
|
|
var h_id = $(this).data('id');
|
|
var $row = $('#history-row-' + h_id);
|
|
|
|
jConfirm('Удалить этот редирект?', 'Подтверждение', function(r) {
|
|
if(r) {
|
|
$.post('index.php?do=modules&action=alias_history_delete&ajax=1', { id: h_id, cp: sess }, function(data){
|
|
if(data && data.status == 'success') {
|
|
$row.fadeOut(400, function(){
|
|
$(this).remove();
|
|
toggleHistoryVisibility();
|
|
});
|
|
$.jGrowl("Запись удалена", {theme: "accept"});
|
|
}
|
|
}, 'json');
|
|
}
|
|
});
|
|
});
|
|
});
|
|
</script>
|
|
{/literal} |