Browse Source

Fixes

master
M@d D3n 4 years ago
parent
commit
d02cc388a4
  1. 10
      admin/docs.php
  2. 13
      admin/templates/documents/doc_search.tpl
  3. 7
      admin/templates/documents/docs.tpl
  4. 13
      admin/templates/documents/docs_simple.tpl
  5. 348
      admin/templates/documents/form.tpl
  6. 393
      admin/templates/js/docs.js
  7. 72
      class/class.docs.php
  8. 4
      lib/redactor/ckeditor/config.js
  9. 17969
      lib/redactor/ckeditor/plugins/codemirror/js/codemirror.js
  10. 2296
      lib/redactor/ckeditor/plugins/codemirror/plugin.js
  11. 12
      lib/redactor/ckeditor/plugins/savedocs/plugin.js

10
admin/docs.php

@ -182,6 +182,12 @@
}
break;
case 'revisions_delete':
if (check_permission_acp('document_view')) {
$AVE_Document->documentRevissionsDelete((int) $_REQUEST['doc_id'], (int) $_REQUEST['revission'], (int) $_REQUEST['rubric_id']);
}
break;
case 'remark':
if (check_permission_acp('remark_view'))
{
@ -260,8 +266,8 @@
exit;
case 'checkurl':
echo($AVE_Document->documentAliasCheck());
exit;
$AVE_Document->documentAliasCheck();
break;
case 'aliases':
if (check_permission_acp('document_view'))

13
admin/templates/documents/doc_search.tpl

@ -159,15 +159,4 @@
</div>
</div>
</form>
<script src="{$ABS_PATH}admin/templates/js/docs.js"></script>
<script type="text/javascript">
{literal}
$(document).ready(function() {
AveDocs.init();
AveDocs.search();
});
{/literal}
</script>
</form>

7
admin/templates/documents/docs.tpl

@ -470,9 +470,9 @@
{if $page_nav}
<div class="pagination">
<ul class="pages">
{$page_nav}
</ul>
<ul class="pages">
{$page_nav}
</ul>
</div>
{/if}
@ -483,6 +483,7 @@
$(document).ready(function() {
AveDocs.init();
AveDocs.list();
AveDocs.search();
});
{/literal}
</script>

13
admin/templates/documents/docs_simple.tpl

@ -120,4 +120,15 @@ function insertLinkCK(data) {ldelim}
</div>
{/if}
<br />
<br />
<script src="{$ABS_PATH}admin/templates/js/docs.js"></script>
<script language="Javascript" type="text/javascript">
{literal}
$(document).ready(function() {
AveDocs.init();
AveDocs.search();
});
{/literal}
</script>

348
admin/templates/documents/form.tpl

@ -1,5 +1,15 @@
<script>
<script type="text/javascript">
CKEDitor_loaded = false;
var defaultLang = '{$smarty.session.accept_langs[$smarty.const.DEFAULT_LANGUAGE]}',
noneLanguage = '{#DOC_LANG_NONE#}',
alert_none_id = '{#DOC_CTRLO_ALERT#}',
alert_none_id_t = '{#DOC_CTRLO_TIT#}';
var doc_form = $('#documentForm'),
doc_action = doc_form.attr('action'),
doc_id = doc_form.data('id'),
doc_prefix = doc_form.data('prefix');
</script>
<script type="text/javascript">
@ -14,7 +24,9 @@ function openLinkWin(target, rtrn='', data='') {ldelim}
var left = ( screen.width - width ) / 2;
var top = ( screen.height - height ) / 2;
data = data.length ? data : 'selurl';
data = data.length
? data
: 'selurl';
window.open('index.php?do=docs&action=showsimple&target='+target+'&'+data+'=1&pop=1','pop','left='+left+',top='+top+',width='+width+',height='+height+',scrollbars=1,resizable=1');
{rdelim}
@ -59,103 +71,6 @@ function openFileWin(target,id) {ldelim}
$(document).ready(function(){ldelim}
$(".ConfirmRecover").click( function(e) {ldelim}
e.preventDefault();
var href = $(this).attr('href');
var title = $(this).attr('dir');
var confirm = $(this).attr('name');
jConfirm(
confirm,
title,
function(b){ldelim}
if (b){ldelim}
$.alerts._overlay('show');
window.location = href;
{rdelim}
{rdelim}
);
{rdelim});
$(".ConfirmDeleteRev").click( function(e) {ldelim}
e.preventDefault();
var revission = $(this).attr('rev');
var href = $(this).attr('href');
var title = $(this).attr('dir');
var confirm = $(this).attr('name');
jConfirm(
confirm,
title,
function(b){ldelim}
if (b){ldelim}
$.alerts._overlay('hide');
$.alerts._overlay('show');
$.ajax({ldelim}
url: ave_path+'admin/'+href+'&ajax=run',
type: 'POST',
success: function (data) {ldelim}
$.alerts._overlay('hide');
$.jGrowl(revission,{ldelim}theme: 'accept'{rdelim});
$("#"+revission).remove();
{rdelim}
{rdelim});
{rdelim}
{rdelim}
);
{rdelim});
function check(){ldelim}
$.ajax({ldelim}
beforeSend: function(){ldelim}
{rdelim},
url: 'index.php',
data: ({ldelim}
'action': 'checkurl',
'do': 'docs',
'check': false,
'cp': '{$sess}',
'id': '{$document->Id}',
'alias': $("#document_alias").val()
{rdelim}),
timeout:3000,
dataType: "json",
success:
function(data){ldelim}
$.jGrowl(data[0],{ldelim}theme: data[1]{rdelim});
{rdelim}
{rdelim});
{rdelim};
$("#translit").click(function(){ldelim}
$.ajax({ldelim}
beforeSend: function(){ldelim}
$("#checkResult").html('');
{rdelim},
url:'index.php',
data: ({ldelim}
action: 'translit',
'do': 'docs',
cp: '{$sess}',
alias: $("#document_alias").val(),
title: $("#document_title").val(),
prefix: '{$document->rubric_url_prefix}'
{rdelim}),
timeout:3000,
success: function(data){ldelim}
$("#document_alias").val(data);
check();
{rdelim}
{rdelim});
{rdelim});
$("#document_alias").change(function(){ldelim}
if ($("#document_alias").val()!='') check();
{rdelim});
$("#loading")
.bind("ajaxSend", function(){ldelim}$.alerts._overlay('show'){rdelim})
.bind("ajaxComplete", function(){ldelim}$.alerts._overlay('hide'){rdelim}
);
{if $smarty.request.feld != ''}
$("#feld_{$smarty.request.feld|escape}").css({ldelim}
'border' : '2px solid red',
@ -164,107 +79,6 @@ $(document).ready(function(){ldelim}
{rdelim});
{/if}
$('#document_published').datetimepicker({ldelim}
changeMonth: true,
changeYear: true,
stepHour: 1,
stepMinute: 1,
onClose: function(dateText, inst) {ldelim}
var endDateTextBox = $('#document_expire');
if (endDateTextBox.val() != '') {ldelim}
var testStartDate = new Date(dateText);
var testEndDate = new Date(endDateTextBox.val());
if (testStartDate > testEndDate)
endDateTextBox.val(dateText);
{rdelim}
else {ldelim}
endDateTextBox.val(dateText);
{rdelim}
{rdelim}
{rdelim});
$('#document_expire').datetimepicker({ldelim}
changeMonth: true,
changeYear: true,
stepHour: 1,
stepMinute: 1,
onClose: function(dateText, inst) {ldelim}
var startDateTextBox = $('#document_published');
if (startDateTextBox.val() != '') {ldelim}
var testStartDate = new Date(startDateTextBox.val());
var testEndDate = new Date(dateText);
if (testStartDate > testEndDate)
startDateTextBox.val(dateText);
{rdelim}
else {ldelim}
startDateTextBox.val(dateText);
{rdelim}
{rdelim},
onSelect: function (selectedDateTime){ldelim}
var end = $(this).datetimepicker('getDate');
$('#document_published').datetimepicker('option', 'maxDate', new Date(end.getTime()) );
{rdelim}
{rdelim});
$(".linkSelect").change(function() {ldelim}
var link = $(this).val();
var parent = $(this).find(' option:selected').attr("data-id");
{if $document->rubric_url_prefix == ""}
$("#document_alias").val(link);
{else}
$("#document_alias").val(link+'/{$document->rubric_url_prefix}');
{/if}
$("#document_parent").val(parent);
return false;
{rdelim});
$("#document_meta_keywords").autocomplete("index.php?do=docs&action=keywords&ajax=run&cp={$sess}", {ldelim}
max: 20,
width: 300,
highlight: false,
multiple: true,
multipleSeparator: ", ",
autoFill: true,
scroll: true,
scrollHeight: 180
{rdelim});
$('#document_lang').change(function() {ldelim}
var defaultLang = '{$smarty.session.accept_langs[$smarty.const.DEFAULT_LANGUAGE]}';
var lang = $('#document_lang option:selected').val();
var alias = $('#document_alias').val().split('/');
var languages = [];
$('#document_lang option').each(function(){ldelim}
languages.push($(this).attr('value'));
{rdelim});
if ($.inArray(alias[0], languages) > -1) {ldelim}
alias.splice(0, 1);
{rdelim}
if ((lang == defaultLang)||(lang == "{#DOC_LANG_NONE#}")) {ldelim}
$('#document_alias').val(alias.join('/'));
{rdelim} else {ldelim}
if (alias[0] != "") {ldelim}
console.log(alias);
$('#document_alias').val(lang + '/' + alias.join('/'));
{rdelim} else {ldelim}
$('#document_alias').val(lang);
{rdelim}
{rdelim}
{rdelim});
$('#lang_block').hide();
$('#show_lang').click(function(event) {ldelim}
event.preventDefault();
$('#lang_block').show();
$('#show_lang').hide();
{rdelim});
{rdelim});
</script>
@ -321,7 +135,7 @@ $(document).ready(function(){ldelim}
</div>
<form method="post" name="formDocOption" action="{$document->formaction}" enctype="multipart/form-data" class="mainForm" id="formDoc">
<form method="post" name="formDocOption" action="{$document->formaction}" enctype="multipart/form-data" data-id="{$document->Id}" data-prefix="{$document->rubric_url_prefix}" class="mainForm" id="formDoc">
<input class="mousetrap" name="closeafter" type="hidden" id="closeafter" value="{$smarty.request.closeafter}">
@ -342,7 +156,6 @@ $(document).ready(function(){ldelim}
<!-- Meta данные -->
<div id="tab1" class="tab_content" style="display: block;">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
<col width="250">
<col>
@ -415,9 +228,8 @@ $(document).ready(function(){ldelim}
</tbody>
</table>
</div>
<!-- Alias документа -->
<div id="tab2" class="tab_content" style="display: none;">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
@ -459,7 +271,6 @@ $(document).ready(function(){ldelim}
{/if}
</span>
</div>
<span id="loading" style="display:none"></span>
</td>
</tr>
@ -500,6 +311,7 @@ $(document).ready(function(){ldelim}
</tbody>
</table>
</div>
<!-- Дата публикации -->
<div id="tab3" class="tab_content" style="display: none;">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
@ -520,6 +332,7 @@ $(document).ready(function(){ldelim}
</tbody>
</table>
</div>
<!-- Прочие параметры -->
<div id="tab4" class="tab_content" style="display: none;">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
@ -543,7 +356,9 @@ $(document).ready(function(){ldelim}
<tr>
<td>{#DOC_CAN_SEARCH#}</td>
<td colspan="3"><input name="document_in_search" type="checkbox" id="document_in_search" value="1" {if $document->document_in_search==1 || $smarty.request.action=='new'}checked{/if} /><label> </label></td>
<td colspan="3">
<input name="document_in_search" type="checkbox" id="document_in_search" value="1" {if $document->document_in_search==1 || $smarty.request.action=='new'}checked{/if} /><label> </label>
</td>
</tr>
<tr>
@ -598,7 +413,9 @@ $(document).ready(function(){ldelim}
<td>{#DOC_USE_LANG_PACK#}</td>
<td colspan="3">
<a id="show_lang" class="button basicBtn" href="#">{#DOC_SHOW_LANG#}</a>
<div id="lang_block"><input name="document_lang_group" class="mousetrap" type="text" id="document_lang_group" value="{if $smarty.request.lang_pack}{$smarty.request.lang_pack}{else}{$document->document_lang_group}{/if}" size="4" maxlength="10" style="width: 50px;" /></div>
<div id="lang_block">
<input name="document_lang_group" class="mousetrap" type="text" id="document_lang_group" value="{if $smarty.request.lang_pack}{$smarty.request.lang_pack}{else}{$document->document_lang_group}{/if}" size="4" maxlength="10" style="width: 50px;" />
</div>
</td>
</tr>
@ -683,7 +500,7 @@ $(document).ready(function(){ldelim}
&nbsp;
<input type="submit" class="blackBtn SaveEdit" value="{#DOC_BUTTON_EDIT_DOCUMENT_NEXT#}" />
</div>
<input style="float:right" type="submit" class="greenBtn" value="{#DOC_DISPLAY_NEW_WINDOW#} &raquo;" onClick="window.open('/{if $document_id!=1}index.php?id={$smarty.request.Id}{/if}','_blank');return false;" />
<input style="float:right" type="submit" class="greenBtn" value="{#DOC_DISPLAY_NEW_WINDOW#} &raquo;" onClick="window.open('/{if $document_id!=1}index.php?id={$smarty.request.Id}{/if}', '_blank');return false;" />
<div class="clear"></div>
{elseif $smarty.request.action == 'copy'}
<input type="submit" class="basicBtn" name="doc_after" value="{#DOC_BUTTON_ADD_DOCUMENT#}" />
@ -705,8 +522,11 @@ $(document).ready(function(){ldelim}
<div class="widget first">
<div class="head">
<h5>{#DOC_REVISSION#}</h5>
<div class="num">
<a class="basicNum deleteRevisions" href="index.php?do=docs&action=revisions_delete&id={$document->Id}&rubric_id={$document->rubric_id}&cp={$sess}" data-title="{#DOC_REVISSIONS_DELETE#}" data-confirm="{#DOC_REVISSIONS_DELETE_T#}">{#DOC_REVISSIONS_DELETE#}</a>
</div>
</div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic" id="tableRevisions">
<col>
<col>
{if $document->canDelRev == 1}
@ -718,23 +538,33 @@ $(document).ready(function(){ldelim}
{/if}
<thead>
<tr>
<td>{#DOC_REVISSION_DATA#}</td>
<td>{#DOC_REVISSION_USER#}</td>
<td colspan="3">{#DOC_ACTIONS#}</td>
</tr>
<tr>
<td>{#DOC_REVISSION_DATA#}</td>
<td>{#DOC_REVISSION_USER#}</td>
<td colspan="3">{#DOC_ACTIONS#}</td>
</tr>
</thead>
<tbody>
{if $document_rev}
{foreach from=$document_rev item=doc_rev}
<tr id="{$doc_rev->doc_revision}">
<td align="center"><span class="date_text dgrey">{$doc_rev->doc_revision|date_format:$TIME_FORMAT|pretty_date}</span></td>
<td align="center">{$doc_rev->user_id}</td>
<td align="center"><a class="topleftDir icon_sprite ico_look" title="{#DOC_REVISSION_VIEW#}" href="../?id={$doc_rev->doc_id}&revission={$doc_rev->doc_revision}" target="_blank"></a></td>
<td align="center">
<span class="date_text dgrey">{$doc_rev->doc_revision|date_format:$TIME_FORMAT|pretty_date}</span>
</td>
<td align="center">
{$doc_rev->user_id}
</td>
<td align="center">
<a class="topleftDir icon_sprite ico_look" title="{#DOC_REVISSION_VIEW#}" href="../?id={$doc_rev->doc_id}&revission={$doc_rev->doc_revision}" target="_blank"></a>
</td>
{if $document->canDelRev == 1}
<td><a class="topleftDir ConfirmRecover icon_sprite ico_copy" title="{#DOC_REVISSION_RECOVER#}" dir="{#DOC_REVISSION_RECOVER#}" name="{#DOC_REVISSION_RECOVER_T#}" href="index.php?do=docs&action=revision_recover&doc_id={$doc_rev->doc_id}&revission={$doc_rev->doc_revision}&rubric_id={$smarty.request.rubric_id}&cp={$sess}"></a></td>
<td><a class="topleftDir ConfirmDeleteRev icon_sprite ico_delete" title="{#DOC_REVISSION_DELETE#}" dir="{#DOC_REVISSION_DELETE#}" rev="{$doc_rev->doc_revision}" name="{#DOC_REVISSION_DELETE_T#}" href="index.php?do=docs&action=revision_delete&doc_id={$doc_rev->doc_id}&revission={$doc_rev->doc_revision}&rubric_id={$smarty.request.rubric_id}&cp={$sess}"></a></td>
<td>
<a class="topleftDir recoverRevision icon_sprite ico_copy" title="{#DOC_REVISSION_RECOVER#}" data-title="{#DOC_REVISSION_RECOVER#}" data-confirm="{#DOC_REVISSION_RECOVER_T#}" href="index.php?do=docs&action=revision_recover&doc_id={$doc_rev->doc_id}&revission={$doc_rev->doc_revision}&rubric_id={$smarty.request.rubric_id}&cp={$sess}"></a>
</td>
<td>
<a class="topleftDir deleteRevision icon_sprite ico_delete" title="{#DOC_REVISSION_DELETE#}" data-title="{#DOC_REVISSION_DELETE#}" data-confirm="{#DOC_REVISSION_DELETE_T#}" data-rev="{$doc_rev->doc_revision}" href="index.php?do=docs&action=revision_delete&doc_id={$doc_rev->doc_id}&revission={$doc_rev->doc_revision}&rubric_id={$smarty.request.rubric_id}&cp={$sess}"></a>
</td>
{/if}
</tr>
{/foreach}
@ -752,75 +582,13 @@ $(document).ready(function(){ldelim}
<div class="fix"></div>
</div>
<script language="Javascript" type="text/javascript">
var sett_options = {ldelim}
url: '{$document->formaction}',
beforeSubmit: Request,
dataType: 'json',
success: Response
{rdelim}
function Request(){ldelim}
$.alerts._overlay('show');
{rdelim}
function Response(data){ldelim}
$.alerts._overlay('hide');
$.jGrowl(data['message'], {ldelim}
header: data['header'],
theme: data['theme']
{rdelim});
{rdelim}
function SaveAjax () {ldelim}
if (window.CKEDITOR) for(var instanceName in CKEDITOR.instances) CKEDITOR.instances[instanceName].updateElement();
{if $smarty.request.action=='edit'}
$('#formDoc').ajaxSubmit(sett_options);
{else}
$('#formDoc').submit();
{/if}
{rdelim}
function docLook () {ldelim}
{if $smarty.request.action=='edit'}
window.open('/{if $smarty.request.Id!=1}index.php?id={$smarty.request.Id}{/if}','_blank');
{else}
jAlert('{#DOC_CTRLO_ALERT#}','{#DOC_CTRLO_TIT#}');
{/if}
{rdelim}
$(document).ready(function(){ldelim}
Mousetrap.bind(['ctrl+s', 'command+s'], function(event) {ldelim}
event.preventDefault();
if (window.CKEDITOR) for(var instanceName in CKEDITOR.instances) CKEDITOR.instances[instanceName].updateElement();
SaveAjax();
return false;
{rdelim});
$('.SaveEdit').click(function (event) {ldelim}
event.preventDefault();
if (window.CKEDITOR) for(var instanceName in CKEDITOR.instances) CKEDITOR.instances[instanceName].updateElement();
SaveAjax();
return false;
{rdelim});
Mousetrap.bind(['ctrl+o', 'meta+o'], function (event) {ldelim}
event.preventDefault();
docLook();
return false;
{rdelim});
<script src="{$ABS_PATH}admin/templates/js/docs.js"></script>
{literal}
window.onload = function(){
if (window.CKEDITOR) {
CKEDITOR.on('instanceReady', function (event) {
event.editor.setKeystroke(CKEDITOR.CTRL + 83 /*S*/, 'savedoc');
});
}
}
{/literal}
{rdelim});
</script>
<script language="Javascript" type="text/javascript">
{literal}
$(document).ready(function() {
AveDocs.init();
AveDocs.edit();
});
{/literal}
</script>

393
admin/templates/js/docs.js

@ -24,7 +24,18 @@ var AveDocs = {
//
edit: function () {
this.revisionDelete();
this.revisionRecover();
this.revisionsDelete();
this.translitURL();
this.checkURLInput();
this.editDateTime();
this.linkSelect();
this.metaKeywords();
this.documentLanguage();
this.saveEditBtn();
this.editMousetrap();
this.windowOnLoadCKEditor();
},
@ -273,4 +284,384 @@ var AveDocs = {
}, 10);
});
},
//
revisionRecover: function () {
$(".recoverRevision").on('click', function (event) {
event.preventDefault();
let href = $(this).attr('href'),
title = $(this).data('title'),
confirm = $(this).data('confirm');
jConfirm(
confirm,
title,
function (success) {
if (success) {
$.alerts._overlay('show');
window.location = href;
}
}
);
});
},
//
revisionDelete: function () {
$(".deleteRevision").on('click', function (event) {
event.preventDefault();
let revission = $(this).data('rev'),
href = $(this).attr('href'),
title = $(this).data('title'),
confirm = $(this).data('confirm');
jConfirm(
confirm,
title,
function (success) {
if (success) {
$.alerts._overlay('hide');
$.alerts._overlay('show');
$.ajax({
url: ave_path + 'admin/' + href + '&ajax=run',
type: 'POST',
success: function (data) {
$.alerts._overlay('hide');
$.jGrowl(revission, { theme: 'accept' });
$("#" + revission).remove();
}
});
}
}
);
});
},
//
revisionsDelete: function () {
$(".deleteRevisions").on('click', function (event) {
event.preventDefault();
let href = $(this).attr('href'),
title = $(this).data('title'),
confirm = $(this).data('confirm');
jConfirm(
confirm,
title,
function (success) {
if (success) {
$.alerts._overlay('hide');
$.alerts._overlay('show');
$.ajax({
url: ave_path + 'admin/' + href,
type: 'POST',
dataType: 'JSON',
success: function (data) {
$.alerts._overlay('hide');
$.jGrowl(data.message, { theme: 'accept' });
$('#tableRevisions').find('tbody').html('');
}
});
}
}
);
});
},
//
checkURL: function () {
let alias = $("#document_alias").val(),
doc_id = $('#formDoc').data('id');
$.ajax({
beforeSend: function () {
},
url: 'index.php',
data: ({
'action': 'checkurl',
'do': 'docs',
'check': false,
'cp': sess,
'id': doc_id,
'alias': alias
}),
timeout: 3000,
dataType: 'JSON',
success:
function (data) {
$.jGrowl(data[0], {theme: data[1]});
}
});
},
//
translitURL: function () {
$("#translit").on('click', function () {
let alias = $("#document_alias").val(),
title = $("#document_title").val(),
prefix = $('#formDoc').data('prefix');
$.ajax({
beforeSend: function () {
$("#checkResult").html('');
},
url: 'index.php',
data: ({
'action': 'translit',
'do': 'docs',
'cp': sess,
'alias': alias,
'title': title,
'prefix': prefix
}),
timeout: 3000,
success: function (data) {
$("#document_alias").val(data);
AveDocs.checkURL();
}
});
});
},
//
checkURLInput: function () {
$("#document_alias").on('change', function () {
if ($(this).val() != '')
AveDocs.checkURL();
});
},
//
editDateTime: function () {
$('#document_published').datetimepicker({
changeMonth: true,
changeYear: true,
stepHour: 1,
stepMinute: 1,
onClose: function (dateText, inst) {
var endDateTextBox = $('#document_expire');
if (endDateTextBox.val() != '') {
var testStartDate = new Date(dateText);
var testEndDate = new Date(endDateTextBox.val());
if (testStartDate > testEndDate)
endDateTextBox.val(dateText);
}
else {
endDateTextBox.val(dateText);
}
}
});
$('#document_expire').datetimepicker({
changeMonth: true,
changeYear: true,
stepHour: 1,
stepMinute: 1,
onClose: function (dateText, inst) {
var startDateTextBox = $('#document_published');
if (startDateTextBox.val() != '') {
var testStartDate = new Date(startDateTextBox.val());
var testEndDate = new Date(dateText);
if (testStartDate > testEndDate)
startDateTextBox.val(dateText);
}
else {
startDateTextBox.val(dateText);
}
},
onSelect: function (selectedDateTime) {
var end = $(this).datetimepicker('getDate');
$('#document_published').datetimepicker('option', 'maxDate', new Date(end.getTime()));
}
});
},
//
linkSelect: function () {
$(".linkSelect").on('change', function() {
let link = $(this).val(),
parent = $(this).find('option:selected').attr("data-id"),
prefix = $('#formDoc').data('prefix');
if (prefix == '') {
$("#document_alias").val(link);
} else {
$("#document_alias").val(link + '/' + prefix);
}
$("#document_parent").val(parent);
return false;
});
},
//
metaKeywords: function () {
$("#document_meta_keywords").autocomplete("index.php?do=docs&action=keywords&ajax=run&cp=" + sess, {
max: 20,
width: 300,
highlight: false,
multiple: true,
multipleSeparator: ", ",
autoFill: true,
scroll: true,
scrollHeight: 180
});
},
//
documentLanguage: function () {
$('#document_lang').on('change', function () {
let lang = $('#document_lang option:selected').val(),
alias = $('#document_alias').val().split('/'),
languages = [];
$('#document_lang option').each(function () {
languages.push($(this).attr('value'));
});
if ($.inArray(alias[0], languages) > -1) {
alias.splice(0, 1);
}
if ((lang == defaultLang) || (lang == noneLanguage)) {
$('#document_alias').val(alias.join('/'));
} else {
if (alias[0] != "") {
$('#document_alias').val(lang + '/' + alias.join('/'));
} else {
$('#document_alias').val(lang);
}
}
});
$('#lang_block').hide();
$('#show_lang').on('click', function (event) {
event.preventDefault();
$('#lang_block').show();
$('#show_lang').hide();
});
},
//
documentSaveFunction: function () {
let form = $('#formDoc');
form.ajaxSubmit({
url: form.attr('action'),
dataType: 'JSON',
beforeSubmit: function () {
$.alerts._overlay('show');
},
success: function (data) {
$.alerts._overlay('hide');
$.jGrowl(data['message'], {
header: data['header'],
theme: data['theme']
});
}
});
},
//
saveDocument: function () {
let form = $('#formDoc');
if (window.CKEDITOR)
for (var instanceName in CKEDITOR.instances)
CKEDITOR.instances[instanceName].updateElement();
if (form.data('id') > 0) {
AveDocs.documentSaveFunction();
} else {
form.submit();
}
},
//
documentSee: function () {
let form = $('#formDoc'),
doc_id = form.data('id');
if (doc_id > 0) {
window.open('/index.php?id=' + doc_id, '_blank');
} else {
jAlert(alert_none_id, alert_none_id_t);
}
},
//
saveEditBtn: function () {
$('.SaveEdit').on('click', function (event) {
event.preventDefault();
if (window.CKEDITOR)
for (var instanceName in CKEDITOR.instances)
CKEDITOR.instances[instanceName].updateElement();
AveDocs.saveDocument();
return false;
});
},
//
editMousetrap: function () {
Mousetrap.bind(['ctrl+s', 'command+s'], function (event) {
event.preventDefault();
if (window.CKEDITOR)
for (var instanceName in CKEDITOR.instances)
CKEDITOR.instances[instanceName].updateElement();
AveDocs.saveDocument();
return false;
});
Mousetrap.bind(['ctrl+o', 'command+o'], function (event) {
event.preventDefault();
AveDocs.documentSee();
return false;
});
},
//
windowOnLoadCKEditor: function () {
window.onload = function () {
if (window.CKEDITOR) {
CKEDITOR.on('instanceReady', function (event) {
event.editor.setKeystroke(CKEDITOR.CTRL + 83 /*S*/, 'savedoc');
});
}
}
}
};

72
class/class.docs.php

@ -3986,8 +3986,7 @@
{
$alias = empty($_REQUEST['alias']) ? '' : prepare_url($_REQUEST['alias']);
$prefix = empty($_REQUEST['prefix']) ? '' : prepare_url($_REQUEST['prefix']);
$title = empty($_REQUEST['title']) ? '' : $_REQUEST['title'];
$title = prepare_url($title);
$title = empty($_REQUEST['title']) ? '' : prepare_url($_REQUEST['title']);
if ($alias != $title && $alias != trim($prefix . '/' . $title, '/'))
$alias = trim($alias . '/' . $title, '/');
@ -3995,6 +3994,7 @@
return $alias;
}
/**
* Метод, предназначенный для контроля уникальности URL
*
@ -4003,13 +4003,11 @@
{
global $AVE_DB, $AVE_Template;
$document_id = (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) ? $_REQUEST['id'] : 0;
$document_id = (isset($_REQUEST['id']) && is_numeric($_REQUEST['id'])) ? (int)$_REQUEST['id'] : 0;
$document_alias = (isset($_REQUEST['alias'])) ? $_REQUEST['alias'] : '';
$check = (isset($_REQUEST['check']) && (bool)$_REQUEST['check'] === true) ? true : false;
$alias_id = (isset($_REQUEST['alias_id'])) ? (int)$_REQUEST['alias_id'] : 0;
$errors = array();
$errors = [];
// Если указанный URL пользователем не пустой
if (! empty($document_alias))
@ -4034,14 +4032,13 @@
if (! empty($matches))
$errors[] = $AVE_Template->get_config_vars('DOC_URL_ERROR_SEGMENT') . implode(', ', $matches);
$and_docs = (($check === false) ? "AND Id != '" . $document_id . "'" : '');
//$and_aliace = (($check === true) ? "AND document_id != '" . $document_id . "'" : '');
$and_docs = (($document_id > 0) ? "AND Id != '" . $document_id . "'" : '');
$and_alias_id = (isset($alias_id) ? "AND id != '" . $alias_id . "'" : '');
// Выполняем запрос к БД на получение всех URL и проверку на уникальность
if (empty($errors))
{
$alias_exist = $AVE_DB->Query("
$sql = "
SELECT 1
FROM
" . PREFIX . "_documents
@ -4049,7 +4046,9 @@
document_alias = '" . $document_alias . "'
$and_docs
LIMIT 1
")->NumRows();
";
$alias_exist = $AVE_DB->Query($sql)->NumRows();
if ($alias_exist)
$errors[] = $AVE_Template->get_config_vars('DOC_URL_ERROR_DUPLICATES');
@ -4077,11 +4076,11 @@
// Если ошибок не найдено, формируем сообщение об успешной операции
if (empty($errors))
{
return json_encode(array($AVE_Template->get_config_vars('DOC_URL_CHECK_OK') . implode(',<br />', $errors), 'accept', $check));
return _json(array($AVE_Template->get_config_vars('DOC_URL_CHECK_OK') . implode(',<br />', $errors), 'accept'), true);
}
else
{ // В противном случае формируем сообщение с ошибкой
return json_encode(array($AVE_Template->get_config_vars('DOC_URL_CHECK_ER') . implode(',<br />', $errors), 'error'));
return _json(array($AVE_Template->get_config_vars('DOC_URL_CHECK_ER') . implode(',<br />', $errors), 'error'), true);
}
}
@ -4429,7 +4428,7 @@
$AVE_DB->clearDocument($doc_id);
reportLog($_SESSION['user_name'] . ' - ' . (($status == 1) ? $AVE_Template->get_config_vars('DOC_STATUS_OFF') : $AVE_Template->get_config_vars('DOC_STATUS_ON')) . ' (' . $doc_id . ')', 2, 2);
reportLog($_SESSION['user_name'] . ' - ' . (($status == 1) ? $AVE_Template->get_config_vars('DOC_DOCUMENT_CLOSE') : $AVE_Template->get_config_vars('DOC_DOCUMENT_OPEN')) . ' (' . $doc_id . ')', 2, 2);
_json($return, true);
}
@ -4488,5 +4487,52 @@
_json($return, true);
}
function documentRevissionsDelete()
{
global $AVE_DB, $AVE_Template;
$document_id = (int)$_REQUEST['id'];
$rubric_id = (int)$_REQUEST['rubric_id'];
$this->documentPermissionFetch($rubric_id);
if ((isset($_SESSION[$rubric_id . '_delrev']) && $_SESSION[$rubric_id . '_delrev'] == 1)
|| (isset($_SESSION[$rubric_id . '_alles']) && $_SESSION[$rubric_id . '_alles'] == 1)
|| (defined('UGROUP') && UGROUP == 1))
{
$run = true;
}
if ($run === true)
{
$sql = "
DELETE
FROM
" . PREFIX . "_document_rev
WHERE
doc_id = '" . $document_id . "'
";
$AVE_DB->Query($sql);
reportLog($AVE_Template->get_config_vars('DOC_REVISIONS_DELETE') . " (Doc: $document_id)");
if (! isAjax()) {
header('Location:index.php?do=docs&action=edit&rubric_id=' . $rubric_id . '&Id=' . $document_id . '&cp=' . SESSION);
} else {
$return = [
'success' => true,
'message' => $AVE_Template->get_config_vars('DOC_REVISIONS_DELETE')
];
_json($return, true);
}
} else {
$AVE_Template->assign('content', $AVE_Template->get_config_vars('DOC_NO_DEL_REVISION'));
}
}
}
?>

4
lib/redactor/ckeditor/config.js

@ -8,7 +8,7 @@ CKEDITOR.editorConfig = function(config) {
config.removePlugins = 'scayt';
config.extraPlugins = 'codemirror,placeholder,savedocs';
config.extraPlugins = 'codemirror,savedocs';
config.protectedSource.push(/<\?[\s\S]*?\?>/g); // PHP code
config.protectedSource.push(/<%[\s\S]*?%>/g); // ASP code
@ -140,7 +140,7 @@ CKEDITOR.editorConfig = function(config) {
config.codemirror = {
// Set this to the theme you wish to use (codemirror themes)
theme: 'default',
theme: 'dracula',
// Whether or not you want to show line numbers
lineNumbers: true,

17969
lib/redactor/ckeditor/plugins/codemirror/js/codemirror.js

File diff suppressed because it is too large Load Diff

2296
lib/redactor/ckeditor/plugins/codemirror/plugin.js

File diff suppressed because it is too large Load Diff

12
lib/redactor/ckeditor/plugins/savedocs/plugin.js

@ -1,7 +1,7 @@
CKEDITOR.plugins.add('savedocs', {
init: function(a) {
var cmd = a.addCommand('savedoc', {
exec: saveAjax
exec: saveDocument
})
a.ui.addButton('savedocs', {
label: 'Save',
@ -9,14 +9,14 @@ CKEDITOR.plugins.add('savedocs', {
icon: this.path + "images/save.png"
})
}
})
});
function saveAjax(e) {
var theForm = e.element.$.form;
function saveDocument(event) {
var theForm = event.element.$.form;
if (typeof(theForm.onsubmit) == 'function') {
SaveAjax();
AveDocs.saveDocument();
return false;
} else {
SaveAjax();
AveDocs.saveDocument();
}
}
Loading…
Cancel
Save