Browse Source

Fixes

pull/3/head
M@d D3n 5 years ago
parent
commit
d02cc388a4
  1. 10
      admin/docs.php
  2. 11
      admin/templates/documents/doc_search.tpl
  3. 1
      admin/templates/documents/docs.tpl
  4. 11
      admin/templates/documents/docs_simple.tpl
  5. 328
      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. 10499
      lib/redactor/ckeditor/plugins/codemirror/js/codemirror.js
  10. 54
      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; 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': case 'remark':
if (check_permission_acp('remark_view')) if (check_permission_acp('remark_view'))
{ {
@ -260,8 +266,8 @@
exit; exit;
case 'checkurl': case 'checkurl':
echo($AVE_Document->documentAliasCheck()); $AVE_Document->documentAliasCheck();
exit; break;
case 'aliases': case 'aliases':
if (check_permission_acp('document_view')) if (check_permission_acp('document_view'))

11
admin/templates/documents/doc_search.tpl

@ -160,14 +160,3 @@
</div> </div>
</div> </div>
</form> </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>

1
admin/templates/documents/docs.tpl

@ -483,6 +483,7 @@
$(document).ready(function() { $(document).ready(function() {
AveDocs.init(); AveDocs.init();
AveDocs.list(); AveDocs.list();
AveDocs.search();
}); });
{/literal} {/literal}
</script> </script>

11
admin/templates/documents/docs_simple.tpl

@ -121,3 +121,14 @@ function insertLinkCK(data) {ldelim}
{/if} {/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>

328
admin/templates/documents/form.tpl

@ -1,5 +1,15 @@
<script> <script type="text/javascript">
CKEDitor_loaded = false; 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>
<script type="text/javascript"> <script type="text/javascript">
@ -14,7 +24,9 @@ function openLinkWin(target, rtrn='', data='') {ldelim}
var left = ( screen.width - width ) / 2; var left = ( screen.width - width ) / 2;
var top = ( screen.height - height ) / 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'); 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} {rdelim}
@ -59,103 +71,6 @@ function openFileWin(target,id) {ldelim}
$(document).ready(function(){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 != ''} {if $smarty.request.feld != ''}
$("#feld_{$smarty.request.feld|escape}").css({ldelim} $("#feld_{$smarty.request.feld|escape}").css({ldelim}
'border' : '2px solid red', 'border' : '2px solid red',
@ -164,107 +79,6 @@ $(document).ready(function(){ldelim}
{rdelim}); {rdelim});
{/if} {/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}); {rdelim});
</script> </script>
@ -321,7 +135,7 @@ $(document).ready(function(){ldelim}
</div> </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}"> <input class="mousetrap" name="closeafter" type="hidden" id="closeafter" value="{$smarty.request.closeafter}">
@ -342,7 +156,6 @@ $(document).ready(function(){ldelim}
<!-- Meta данные --> <!-- Meta данные -->
<div id="tab1" class="tab_content" style="display: block;"> <div id="tab1" class="tab_content" style="display: block;">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic"> <table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
<col width="250"> <col width="250">
<col> <col>
@ -415,9 +228,8 @@ $(document).ready(function(){ldelim}
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- Alias документа --> <!-- Alias документа -->
<div id="tab2" class="tab_content" style="display: none;"> <div id="tab2" class="tab_content" style="display: none;">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic"> <table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
@ -459,7 +271,6 @@ $(document).ready(function(){ldelim}
{/if} {/if}
</span> </span>
</div> </div>
<span id="loading" style="display:none"></span>
</td> </td>
</tr> </tr>
@ -500,6 +311,7 @@ $(document).ready(function(){ldelim}
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- Дата публикации --> <!-- Дата публикации -->
<div id="tab3" class="tab_content" style="display: none;"> <div id="tab3" class="tab_content" style="display: none;">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic"> <table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
@ -520,6 +332,7 @@ $(document).ready(function(){ldelim}
</tbody> </tbody>
</table> </table>
</div> </div>
<!-- Прочие параметры --> <!-- Прочие параметры -->
<div id="tab4" class="tab_content" style="display: none;"> <div id="tab4" class="tab_content" style="display: none;">
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic"> <table cellpadding="0" cellspacing="0" width="100%" class="tableStatic">
@ -543,7 +356,9 @@ $(document).ready(function(){ldelim}
<tr> <tr>
<td>{#DOC_CAN_SEARCH#}</td> <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>
<tr> <tr>
@ -598,7 +413,9 @@ $(document).ready(function(){ldelim}
<td>{#DOC_USE_LANG_PACK#}</td> <td>{#DOC_USE_LANG_PACK#}</td>
<td colspan="3"> <td colspan="3">
<a id="show_lang" class="button basicBtn" href="#">{#DOC_SHOW_LANG#}</a> <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> </td>
</tr> </tr>
@ -705,8 +522,11 @@ $(document).ready(function(){ldelim}
<div class="widget first"> <div class="widget first">
<div class="head"> <div class="head">
<h5>{#DOC_REVISSION#}</h5> <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"> </div>
<table cellpadding="0" cellspacing="0" width="100%" class="tableStatic" id="tableRevisions">
<col> <col>
<col> <col>
{if $document->canDelRev == 1} {if $document->canDelRev == 1}
@ -729,12 +549,22 @@ $(document).ready(function(){ldelim}
{if $document_rev} {if $document_rev}
{foreach from=$document_rev item=doc_rev} {foreach from=$document_rev item=doc_rev}
<tr id="{$doc_rev->doc_revision}"> <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">
<td align="center">{$doc_rev->user_id}</td> <span class="date_text dgrey">{$doc_rev->doc_revision|date_format:$TIME_FORMAT|pretty_date}</span>
<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>
<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} {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>
<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> <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} {/if}
</tr> </tr>
{/foreach} {/foreach}
@ -752,75 +582,13 @@ $(document).ready(function(){ldelim}
<div class="fix"></div> <div class="fix"></div>
</div> </div>
<script language="Javascript" type="text/javascript"> <script src="{$ABS_PATH}admin/templates/js/docs.js"></script>
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 language="Javascript" type="text/javascript">
{literal} {literal}
window.onload = function(){ $(document).ready(function() {
if (window.CKEDITOR) { AveDocs.init();
CKEDITOR.on('instanceReady', function (event) { AveDocs.edit();
event.editor.setKeystroke(CKEDITOR.CTRL + 83 /*S*/, 'savedoc');
}); });
}
}
{/literal} {/literal}
{rdelim});
</script> </script>

393
admin/templates/js/docs.js

@ -24,7 +24,18 @@ var AveDocs = {
// //
edit: function () { 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); }, 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']); $alias = empty($_REQUEST['alias']) ? '' : prepare_url($_REQUEST['alias']);
$prefix = empty($_REQUEST['prefix']) ? '' : prepare_url($_REQUEST['prefix']); $prefix = empty($_REQUEST['prefix']) ? '' : prepare_url($_REQUEST['prefix']);
$title = empty($_REQUEST['title']) ? '' : $_REQUEST['title']; $title = empty($_REQUEST['title']) ? '' : prepare_url($_REQUEST['title']);
$title = prepare_url($title);
if ($alias != $title && $alias != trim($prefix . '/' . $title, '/')) if ($alias != $title && $alias != trim($prefix . '/' . $title, '/'))
$alias = trim($alias . '/' . $title, '/'); $alias = trim($alias . '/' . $title, '/');
@ -3995,6 +3994,7 @@
return $alias; return $alias;
} }
/** /**
* Метод, предназначенный для контроля уникальности URL * Метод, предназначенный для контроля уникальности URL
* *
@ -4003,13 +4003,11 @@
{ {
global $AVE_DB, $AVE_Template; 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'] : ''; $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; $alias_id = (isset($_REQUEST['alias_id'])) ? (int)$_REQUEST['alias_id'] : 0;
$errors = array(); $errors = [];
// Если указанный URL пользователем не пустой // Если указанный URL пользователем не пустой
if (! empty($document_alias)) if (! empty($document_alias))
@ -4034,14 +4032,13 @@
if (! empty($matches)) if (! empty($matches))
$errors[] = $AVE_Template->get_config_vars('DOC_URL_ERROR_SEGMENT') . implode(', ', $matches); $errors[] = $AVE_Template->get_config_vars('DOC_URL_ERROR_SEGMENT') . implode(', ', $matches);
$and_docs = (($check === false) ? "AND Id != '" . $document_id . "'" : ''); $and_docs = (($document_id > 0) ? "AND Id != '" . $document_id . "'" : '');
//$and_aliace = (($check === true) ? "AND document_id != '" . $document_id . "'" : '');
$and_alias_id = (isset($alias_id) ? "AND id != '" . $alias_id . "'" : ''); $and_alias_id = (isset($alias_id) ? "AND id != '" . $alias_id . "'" : '');
// Выполняем запрос к БД на получение всех URL и проверку на уникальность // Выполняем запрос к БД на получение всех URL и проверку на уникальность
if (empty($errors)) if (empty($errors))
{ {
$alias_exist = $AVE_DB->Query(" $sql = "
SELECT 1 SELECT 1
FROM FROM
" . PREFIX . "_documents " . PREFIX . "_documents
@ -4049,7 +4046,9 @@
document_alias = '" . $document_alias . "' document_alias = '" . $document_alias . "'
$and_docs $and_docs
LIMIT 1 LIMIT 1
")->NumRows(); ";
$alias_exist = $AVE_DB->Query($sql)->NumRows();
if ($alias_exist) if ($alias_exist)
$errors[] = $AVE_Template->get_config_vars('DOC_URL_ERROR_DUPLICATES'); $errors[] = $AVE_Template->get_config_vars('DOC_URL_ERROR_DUPLICATES');
@ -4077,11 +4076,11 @@
// Если ошибок не найдено, формируем сообщение об успешной операции // Если ошибок не найдено, формируем сообщение об успешной операции
if (empty($errors)) 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 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); $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); _json($return, true);
} }
@ -4488,5 +4487,52 @@
_json($return, true); _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.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); // PHP code
config.protectedSource.push(/<%[\s\S]*?%>/g); // ASP code config.protectedSource.push(/<%[\s\S]*?%>/g); // ASP code
@ -140,7 +140,7 @@ CKEDITOR.editorConfig = function(config) {
config.codemirror = { config.codemirror = {
// Set this to the theme you wish to use (codemirror themes) // Set this to the theme you wish to use (codemirror themes)
theme: 'default', theme: 'dracula',
// Whether or not you want to show line numbers // Whether or not you want to show line numbers
lineNumbers: true, lineNumbers: true,

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

File diff suppressed because it is too large Load Diff

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

@ -14,6 +14,14 @@
init: function (editor) { init: function (editor) {
var rootPath = this.path, var rootPath = this.path,
defaultConfig = { defaultConfig = {
extraKeys: {
'Ctrl-S': function () {
AveDocs.documentSaveFunction();
},
'Cmd-S': function () {
AveDocs.documentSaveFunction();
},
},
autoCloseBrackets: true, autoCloseBrackets: true,
autoCloseTags: true, autoCloseTags: true,
autoFormatOnStart: false, autoFormatOnStart: false,
@ -22,8 +30,10 @@
enableCodeFolding: true, enableCodeFolding: true,
enableCodeFormatting: true, enableCodeFormatting: true,
enableSearchTools: true, enableSearchTools: true,
enterMode: 'keep',
highlightMatches: true, highlightMatches: true,
indentWithTabs: false, indentUnit: 4,
indentWithTabs: true,
lineNumbers: true, lineNumbers: true,
lineWrapping: true, lineWrapping: true,
mode: 'htmlmixed', mode: 'htmlmixed',
@ -36,6 +46,7 @@
showTrailingSpace: true, showTrailingSpace: true,
showUncommentButton: true, showUncommentButton: true,
styleActiveLine: true, styleActiveLine: true,
tabMode: 'shift',
theme: 'default', theme: 'default',
useBeautify: false useBeautify: false
}; };
@ -87,13 +98,18 @@
showCursorWhenSelecting: true, showCursorWhenSelecting: true,
styleActiveLine: config.styleActiveLine, styleActiveLine: config.styleActiveLine,
viewportMargin: Infinity, viewportMargin: Infinity,
//extraKeys: {"Ctrl-Space": "autocomplete"},
extraKeys: { extraKeys: {
"Ctrl-Q": function (codeMirror_Editor) { "Ctrl-Q": function (codeMirror_Editor) {
if (config.enableCodeFolding) { if (config.enableCodeFolding) {
window["foldFunc_" + editor.id](codeMirror_Editor, codeMirror_Editor.getCursor().line); window["foldFunc_" + editor.id](codeMirror_Editor, codeMirror_Editor.getCursor().line);
} }
} },
'Ctrl-S': function (codeMirror_Editor) {
AveDocs.documentSaveFunction();
},
'Cmd-S': function (codeMirror_Editor) {
AveDocs.documentSaveFunction();
},
}, },
foldGutter: true, foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"] gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
@ -198,7 +214,7 @@
if (typeof (CodeMirror) == 'undefined') { if (typeof (CodeMirror) == 'undefined') {
CKEDITOR.scriptLoader.load(rootPath + 'js/codemirror.min.js', function() { CKEDITOR.scriptLoader.load(rootPath + 'js/codemirror.js', function() {
CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), function() { CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), function() {
loadCodeMirrorInline(editor, textArea); loadCodeMirrorInline(editor, textArea);
@ -539,7 +555,7 @@
if (typeof (CodeMirror) == 'undefined') { if (typeof (CodeMirror) == 'undefined') {
CKEDITOR.scriptLoader.load(rootPath + 'js/codemirror.min.js', function() { CKEDITOR.scriptLoader.load(rootPath + 'js/codemirror.js', function() {
CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), function() { CKEDITOR.scriptLoader.load(getCodeMirrorScripts(), function() {
loadCodeMirror(editor); loadCodeMirror(editor);
@ -697,7 +713,13 @@
if (config.enableCodeFolding) { if (config.enableCodeFolding) {
window["foldFunc_" + editor.id](codeMirror_Editor, codeMirror_Editor.getCursor().line); window["foldFunc_" + editor.id](codeMirror_Editor, codeMirror_Editor.getCursor().line);
} }
} },
'Ctrl-S': function (codeMirror_Editor) {
AveDocs.documentSaveFunction();
},
'Cmd-S': function (codeMirror_Editor) {
AveDocs.documentSaveFunction();
},
}; };
addCKEditorKeystrokes(extraKeys); addCKEditorKeystrokes(extraKeys);
@ -715,12 +737,12 @@
autoCloseBrackets: config.autoCloseBrackets, autoCloseBrackets: config.autoCloseBrackets,
highlightSelectionMatches: config.highlightMatches, highlightSelectionMatches: config.highlightMatches,
continueComments: config.continueComments, continueComments: config.continueComments,
indentUnit: config.indentUnit,
indentWithTabs: config.indentWithTabs, indentWithTabs: config.indentWithTabs,
theme: config.theme, theme: config.theme,
showTrailingSpace: config.showTrailingSpace, showTrailingSpace: config.showTrailingSpace,
showCursorWhenSelecting: true, showCursorWhenSelecting: true,
styleActiveLine: config.styleActiveLine, styleActiveLine: config.styleActiveLine,
//extraKeys: {"Ctrl-Space": "autocomplete"},
extraKeys: extraKeys, extraKeys: extraKeys,
foldGutter: true, foldGutter: true,
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"] gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
@ -758,7 +780,12 @@
}; };
} }
window["codemirror_" + editor.id].on("change", function () { window["codemirror_" + editor.id].on('keypress', function () {
window["codemirror_" + editor.id].save();
editor.fire('keypress', this);
});
window["codemirror_" + editor.id].on('change', function () {
window["codemirror_" + editor.id].save(); window["codemirror_" + editor.id].save();
editor.fire('change', this); editor.fire('change', this);
}); });
@ -767,7 +794,7 @@
// Enable Code Folding (Requires 'lineNumbers' to be set to 'true') // Enable Code Folding (Requires 'lineNumbers' to be set to 'true')
if (config.lineNumbers && config.enableCodeFolding) { if (config.lineNumbers && config.enableCodeFolding) {
window["codemirror_" + editor.id].on("gutterClick", window["foldFunc_" + editor.id]); window["codemirror_" + editor.id].on('gutterClick', window["foldFunc_" + editor.id]);
} }
// Run config.onLoad callback, if present. // Run config.onLoad callback, if present.
@ -776,13 +803,15 @@
} }
// inherit blur event // inherit blur event
window["codemirror_" + editor.id].on("blur", function () { window["codemirror_" + editor.id].on('blur', function () {
editor.fire('blur', this); editor.fire('blur', this);
}); });
window["codemirror_" + editor.id].on("keypress", function (codeMirror_Editor, evt) { window["codemirror_" + editor.id].on('keypress', function (codeMirror_Editor, evt) {
if (config.enableCodeFormatting) { if (config.enableCodeFormatting) {
var range = getSelectedRange(); var range = getSelectedRange();
if (evt.type === "keydown" && evt.ctrlKey && evt.keyCode === 75 && !evt.shiftKey && !evt.altKey) { if (evt.type === "keydown" && evt.ctrlKey && evt.keyCode === 75 && !evt.shiftKey && !evt.altKey) {
window["codemirror_" + editor.id].commentRange(true, range.from, range.to); window["codemirror_" + editor.id].commentRange(true, range.from, range.to);
} else if (evt.type === "keydown" && evt.ctrlKey && evt.keyCode === 75 && evt.shiftKey && !evt.altKey) { } else if (evt.type === "keydown" && evt.ctrlKey && evt.keyCode === 75 && evt.shiftKey && !evt.altKey) {
@ -796,6 +825,9 @@
CodeMirror.commands.newlineAndIndentContinueMarkdownList(window["codemirror_" + editor.id]); CodeMirror.commands.newlineAndIndentContinueMarkdownList(window["codemirror_" + editor.id]);
}*/ }*/
} }
window["codemirror_" + editor.id].save();
editor.fire('change', this);
}); });
} }

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

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