mirror of
https://github.com/Oreolek/ifhub.club.git
synced 2024-06-16 23:00:51 +03:00
Функционал редактирования комментариев
This commit is contained in:
parent
da9d6d3093
commit
e3b838f41d
|
@ -71,6 +71,8 @@ class ActionAjax extends Action {
|
|||
$this->AddEventPreg('/^autocompleter$/i','/^user$/','EventAutocompleterUser');
|
||||
|
||||
$this->AddEventPreg('/^comment$/i','/^delete$/','EventCommentDelete');
|
||||
$this->AddEventPreg('/^comment$/i','/^load$/','EventCommentLoad');
|
||||
$this->AddEventPreg('/^comment$/i','/^update$/','EventCommentUpdate');
|
||||
|
||||
$this->AddEventPreg('/^geo$/i','/^get/','/^regions$/','EventGeoGetRegions');
|
||||
$this->AddEventPreg('/^geo$/i','/^get/','/^cities$/','EventGeoGetCities');
|
||||
|
@ -1789,4 +1791,66 @@ class ActionAjax extends Action {
|
|||
$this->Viewer_AssignAjax('bState',$bState);
|
||||
$this->Viewer_AssignAjax('sTextToggle',$sTextToggle);
|
||||
}
|
||||
/**
|
||||
* Загрузка данных комментария для редактировоания
|
||||
*
|
||||
*/
|
||||
protected function EventCommentLoad() {
|
||||
/**
|
||||
* Комментарий существует?
|
||||
*/
|
||||
$idComment=getRequestStr('idComment',null,'post');
|
||||
if (!($oComment=$this->Comment_GetCommentById($idComment))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
if (!$oComment->isAllowEdit()) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('not_access'),$this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
$sText=$oComment->getTextSource() ? $oComment->getTextSource() : $oComment->getText();
|
||||
$this->Viewer_AssignAjax('sText',$sText);
|
||||
}
|
||||
|
||||
/**
|
||||
* Редактирование комментария
|
||||
*
|
||||
*/
|
||||
protected function EventCommentUpdate() {
|
||||
/**
|
||||
* Комментарий существует?
|
||||
*/
|
||||
$idComment=getRequestStr('comment_id',null,'post');
|
||||
if (!($oComment=$this->Comment_GetCommentById($idComment))) {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
if (!$oComment->isAllowEdit()) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('not_access'),$this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
|
||||
$sText=getRequestStr('comment_text');
|
||||
/**
|
||||
* Проверяем текст комментария
|
||||
*/
|
||||
if (!func_check($sText,'text',2,10000)) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('topic_comment_add_text_error'),$this->Lang_Get('error'));
|
||||
return;
|
||||
}
|
||||
|
||||
$oComment->setText($this->Text_Parser($sText));
|
||||
$oComment->setTextSource($sText);
|
||||
$oComment->setDateEdit(date('Y-m-d H:i:s'));
|
||||
$oComment->setCountEdit($oComment->getCountEdit()+1);
|
||||
|
||||
if ($this->Comment_UpdateComment($oComment)) {
|
||||
$oViewerLocal=$this->Viewer_GetLocalViewer();
|
||||
$oViewerLocal->Assign('oUserCurrent',$this->oUserCurrent);
|
||||
$oViewerLocal->Assign('bOneComment',true);
|
||||
$oViewerLocal->Assign('oComment',$oComment);
|
||||
$sHtml=$oViewerLocal->Fetch($this->Comment_GetTemplateCommentByTarget($oComment->getTargetId(),$oComment->getTargetType()));
|
||||
$this->Viewer_AssignAjax('sHtml',$sHtml);
|
||||
} else {
|
||||
return $this->EventErrorDebug();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1160,7 +1160,7 @@ class ActionBlog extends Action {
|
|||
protected function SubmitComment() {
|
||||
|
||||
$oTopic = $this->Topic_GetTopicById(getRequestStr('cmt_target_id'));
|
||||
$sText = $this->Text_Parser(getRequestStr('comment_text'));
|
||||
$sText = getRequestStr('comment_text');
|
||||
$sParentId = (int)getRequest('reply');
|
||||
$oCommentParent = null;
|
||||
|
||||
|
@ -1199,7 +1199,8 @@ class ActionBlog extends Action {
|
|||
$oCommentNew->setTargetType('topic');
|
||||
$oCommentNew->setTargetParentId($oTopic->getBlog()->getId());
|
||||
$oCommentNew->setUserId($this->oUserCurrent->getId());
|
||||
$oCommentNew->setText($sText);
|
||||
$oCommentNew->setText($this->Text_Parser($sText));
|
||||
$oCommentNew->setTextSource($sText);
|
||||
$oCommentNew->setDate(date("Y-m-d H:i:s"));
|
||||
$oCommentNew->setUserIp(func_getIp());
|
||||
$oCommentNew->setPid($sParentId);
|
||||
|
|
|
@ -631,7 +631,7 @@ class ActionTalk extends Action {
|
|||
/**
|
||||
* Проверяем текст комментария
|
||||
*/
|
||||
$sText=$this->Text_Parser(getRequestStr('comment_text'));
|
||||
$sText=getRequestStr('comment_text');
|
||||
if (!func_check($sText,'text',2,3000)) {
|
||||
$this->Message_AddErrorSingle($this->Lang_Get('talk_comment_add_text_error'),$this->Lang_Get('error'));
|
||||
return;
|
||||
|
@ -677,7 +677,8 @@ class ActionTalk extends Action {
|
|||
$oCommentNew->setTargetId($oTalk->getId());
|
||||
$oCommentNew->setTargetType('talk');
|
||||
$oCommentNew->setUserId($this->oUserCurrent->getId());
|
||||
$oCommentNew->setText($sText);
|
||||
$oCommentNew->setText($this->Text_Parser($sText));
|
||||
$oCommentNew->setTextSource($sText);
|
||||
$oCommentNew->setDate(date("Y-m-d H:i:s"));
|
||||
$oCommentNew->setUserIp(func_getIp());
|
||||
$oCommentNew->setPid($sParentId);
|
||||
|
|
|
@ -357,16 +357,46 @@ class ModuleACL extends Module {
|
|||
return false;
|
||||
}
|
||||
/**
|
||||
* Проверка на редактирование комментария
|
||||
*
|
||||
* @param ModuleComment_EntityComment $oComment
|
||||
* @param ModuleUser_EntityUser $oUser
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowEditComment($oComment,$oUser) {
|
||||
if (!$oUser) {
|
||||
return false;
|
||||
}
|
||||
if (!in_array($oComment->getTargetType(),(array)Config::Get('module.comment.edit_target_allow'))) {
|
||||
return false;
|
||||
}
|
||||
if ($oUser->isAdministrator()) {
|
||||
return true;
|
||||
}
|
||||
if ($oComment->getUserId()==$oUser->getId() and $oUser->getRating()>=Config::Get('acl.update.comment.rating')) {
|
||||
/**
|
||||
* Проверяем на лимит времени
|
||||
*/
|
||||
if (!Config::Get('acl.update.comment.limit_time') or (time()-strtotime($oComment->getDate()) <= Config::Get('acl.update.comment.limit_time')) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Проверка на удаление комментария
|
||||
*
|
||||
* @param ModuleComment_EntityComment $oComment
|
||||
* @param ModuleUser_EntityUser $oUser
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function IsAllowDeleteComment($oComment,$oUser) {
|
||||
/**
|
||||
* Разрешаем если это админ сайта или автор комментария
|
||||
* Разрешаем если это админ сайта
|
||||
*/
|
||||
if ($oComment->getUserId()==$oUser->getId() or $oUser->isAdministrator()) {
|
||||
if ($oUser and $oUser->isAdministrator()) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -94,6 +94,14 @@ class ModuleComment_EntityComment extends Entity {
|
|||
public function getText() {
|
||||
return $this->_getDataOne('comment_text');
|
||||
}
|
||||
/**
|
||||
* Возвращает исходный текст комментария
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTextSource() {
|
||||
return $this->_getDataOne('comment_text_source') ? $this->_getDataOne('comment_text_source') : '';
|
||||
}
|
||||
/**
|
||||
* Возвращает дату комментария
|
||||
*
|
||||
|
@ -102,6 +110,14 @@ class ModuleComment_EntityComment extends Entity {
|
|||
public function getDate() {
|
||||
return $this->_getDataOne('comment_date');
|
||||
}
|
||||
/**
|
||||
* Возвращает дату последнего редактирования комментария
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getDateEdit() {
|
||||
return $this->_getDataOne('comment_date_edit');
|
||||
}
|
||||
/**
|
||||
* Возвращает IP пользователя
|
||||
*
|
||||
|
@ -126,6 +142,14 @@ class ModuleComment_EntityComment extends Entity {
|
|||
public function getCountVote() {
|
||||
return $this->_getDataOne('comment_count_vote');
|
||||
}
|
||||
/**
|
||||
* Возвращает количество редактирований комментария
|
||||
*
|
||||
* @return int|null
|
||||
*/
|
||||
public function getCountEdit() {
|
||||
return $this->_getDataOne('comment_count_edit');
|
||||
}
|
||||
/**
|
||||
* Возвращает флаг удаленного комментария
|
||||
*
|
||||
|
@ -210,7 +234,35 @@ class ModuleComment_EntityComment extends Entity {
|
|||
public function getCountFavourite() {
|
||||
return $this->_getDataOne('comment_count_favourite');
|
||||
}
|
||||
|
||||
/**
|
||||
* Проверка на разрешение редактировать комментарий
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function isAllowEdit() {
|
||||
return $this->ACL_IsAllowEditComment($this,$this->User_GetUserCurrent());
|
||||
}
|
||||
/**
|
||||
* Возвращает количество сикунд в течении которых возможно редактирование
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getEditTimeRemaining() {
|
||||
$oUser=$this->User_GetUserCurrent();
|
||||
if (($oUser and $oUser->isAdministrator()) or !Config::Get('acl.update.comment.limit_time')) {
|
||||
return 0;
|
||||
}
|
||||
$iTime=Config::Get('acl.update.comment.limit_time')-(time()-strtotime($this->getDate()));
|
||||
return $iTime>0 ? $iTime : 0;
|
||||
}
|
||||
/**
|
||||
* Проверка на разрешение удалить комментарий
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function isAllowDelete() {
|
||||
return $this->ACL_IsAllowDeleteComment($this,$this->User_GetUserCurrent());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -285,6 +337,14 @@ class ModuleComment_EntityComment extends Entity {
|
|||
public function setText($data) {
|
||||
$this->_aData['comment_text']=$data;
|
||||
}
|
||||
/**
|
||||
* Устанавливает исходный текст комментария
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function setTextSource($data) {
|
||||
$this->_aData['comment_text_source']=$data;
|
||||
}
|
||||
/**
|
||||
* Устанавливает дату комментария
|
||||
*
|
||||
|
@ -294,7 +354,15 @@ class ModuleComment_EntityComment extends Entity {
|
|||
$this->_aData['comment_date']=$data;
|
||||
}
|
||||
/**
|
||||
* Устанвливает IP пользователя
|
||||
* Устанавливает дату последнего редактирования комментария
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
public function setDateEdit($data) {
|
||||
$this->_aData['comment_date_edit']=$data;
|
||||
}
|
||||
/**
|
||||
* Устанавливает IP пользователя
|
||||
*
|
||||
* @param string $data
|
||||
*/
|
||||
|
@ -317,6 +385,14 @@ class ModuleComment_EntityComment extends Entity {
|
|||
public function setCountVote($data) {
|
||||
$this->_aData['comment_count_vote']=$data;
|
||||
}
|
||||
/**
|
||||
* Устанавливает количество редактирований комментария
|
||||
*
|
||||
* @param int $data
|
||||
*/
|
||||
public function setCountEdit($data) {
|
||||
$this->_aData['comment_count_edit']=$data;
|
||||
}
|
||||
/**
|
||||
* Устанавливает флаг удаленности комментария
|
||||
*
|
||||
|
|
|
@ -509,14 +509,15 @@ class ModuleComment_MapperComment extends Mapper {
|
|||
target_parent_id,
|
||||
user_id,
|
||||
comment_text,
|
||||
comment_text_source,
|
||||
comment_date,
|
||||
comment_user_ip,
|
||||
comment_publish,
|
||||
comment_text_hash
|
||||
)
|
||||
VALUES(?, ?d, ?, ?d, ?d, ?, ?, ?, ?d, ?)
|
||||
VALUES(?, ?d, ?, ?d, ?d, ?, ?, ?, ?, ?d, ?)
|
||||
";
|
||||
if ($iId=$this->oDb->query($sql,$oComment->getPid(),$oComment->getTargetId(),$oComment->getTargetType(),$oComment->getTargetParentId(),$oComment->getUserId(),$oComment->getText(),$oComment->getDate(),$oComment->getUserIp(),$oComment->getPublish(),$oComment->getTextHash()))
|
||||
if ($iId=$this->oDb->query($sql,$oComment->getPid(),$oComment->getTargetId(),$oComment->getTargetType(),$oComment->getTargetParentId(),$oComment->getUserId(),$oComment->getText(),$oComment->getTextSource(),$oComment->getDate(),$oComment->getUserIp(),$oComment->getPublish(),$oComment->getTextHash()))
|
||||
{
|
||||
return $iId;
|
||||
}
|
||||
|
@ -624,16 +625,19 @@ class ModuleComment_MapperComment extends Mapper {
|
|||
$sql = "UPDATE ".Config::Get('db.table.comment')."
|
||||
SET
|
||||
comment_text= ?,
|
||||
comment_text_source= ?,
|
||||
comment_rating= ?f,
|
||||
comment_count_vote= ?d,
|
||||
comment_count_favourite= ?d,
|
||||
comment_count_edit= ?d,
|
||||
comment_date_edit= ?,
|
||||
comment_delete = ?d ,
|
||||
comment_publish = ?d ,
|
||||
comment_text_hash = ?
|
||||
WHERE
|
||||
comment_id = ?d
|
||||
";
|
||||
$res=$this->oDb->query($sql,$oComment->getText(),$oComment->getRating(),$oComment->getCountVote(),$oComment->getCountFavourite(),$oComment->getDelete(),$oComment->getPublish(),$oComment->getTextHash(),$oComment->getId());
|
||||
$res=$this->oDb->query($sql,$oComment->getText(),$oComment->getTextSource(),$oComment->getRating(),$oComment->getCountVote(),$oComment->getCountFavourite(),$oComment->getCountEdit(),$oComment->getDateEdit(),$oComment->getDelete(),$oComment->getPublish(),$oComment->getTextHash(),$oComment->getId());
|
||||
return $res===false or is_null($res) ? false : true;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -90,6 +90,8 @@ $config['acl']['create']['talk_comment']['limit_time'] = 10; // врем
|
|||
$config['acl']['create']['talk_comment']['limit_time_rating'] = 5; // рейтинг, выше которого перестаёт действовать ограничение по времени на отправку инбоксов
|
||||
$config['acl']['create']['wall']['limit_time'] = 20; // рейтинг, выше которого перестаёт действовать ограничение по времени на отправку сообщений на стену
|
||||
$config['acl']['create']['wall']['limit_time_rating'] = 0; // рейтинг, выше которого перестаёт действовать ограничение по времени на отправку сообщений на стену
|
||||
$config['acl']['update']['comment']['rating'] = -5; // порог рейтинга при котором юзер может редактировать комментарии
|
||||
$config['acl']['update']['comment']['limit_time'] = 60*3; // время в секундах после создания комментария, когда можно его отредактировать, если 0 то ограничение по времени не будет работать
|
||||
$config['acl']['vote']['comment']['rating'] = -3; // порог рейтинга при котором юзер может голосовать за комментарии
|
||||
$config['acl']['vote']['blog']['rating'] = -5; // порог рейтинга при котором юзер может голосовать за блог
|
||||
$config['acl']['vote']['topic']['rating'] = -7; // порог рейтинга при котором юзер может голосовать за топик
|
||||
|
@ -152,6 +154,7 @@ $config['module']['comment']['use_nested'] = false; // Использовать
|
|||
$config['module']['comment']['nested_per_page'] = 0; // Число комментов на одну страницу в топике, актуально только при use_nested = true
|
||||
$config['module']['comment']['nested_page_reverse'] = true; // Определяет порядок вывода страниц. true - последние комментарии на первой странице, false - последние комментарии на последней странице
|
||||
$config['module']['comment']['favourite_target_allow'] = array('topic'); // Список типов комментов, которые разрешено добавлять в избранное
|
||||
$config['module']['comment']['edit_target_allow'] = array('topic'); // Список типов комментов, которые разрешено редактировать
|
||||
// Модуль Talk
|
||||
$config['module']['talk']['per_page'] = 30; // Число приватных сообщений на одну страницу
|
||||
$config['module']['talk']['encrypt'] = 'livestreet'; // Ключ XXTEA шифрования идентификаторов в ссылках
|
||||
|
@ -463,6 +466,7 @@ $config['head']['default']['js'] = array(
|
|||
"___path.framework.frontend.web___/js/vendor/jquery.charcount.js",
|
||||
"___path.framework.frontend.web___/js/vendor/jquery.imagesloaded.js",
|
||||
"___path.framework.frontend.web___/js/vendor/jquery.fileupload.js",
|
||||
"___path.framework.frontend.web___/js/vendor/jquery.timers.js",
|
||||
"___path.framework.frontend.web___/js/vendor/notifier/jquery.notifier.js",
|
||||
"___path.framework.frontend.web___/js/vendor/prettify/prettify.js",
|
||||
"___path.framework.frontend.web___/js/vendor/parsley/parsley.js",
|
||||
|
|
|
@ -43,6 +43,8 @@ ls.comments = (function ($) {
|
|||
reply: '.js-comment-reply',
|
||||
fold: '.js-comment-fold',
|
||||
remove: '.js-comment-remove',
|
||||
update: '.js-comment-update',
|
||||
update_timer: '.js-comment-update-timer',
|
||||
scroll_to_child: '.js-comment-scroll-to-child',
|
||||
scroll_to_parent: '.js-comment-scroll-to-parent'
|
||||
},
|
||||
|
@ -51,6 +53,8 @@ ls.comments = (function ($) {
|
|||
text: '#form_comment_text',
|
||||
submit: '.js-comment-form-submit',
|
||||
preview: '.js-comment-form-preview',
|
||||
update_submit: '.js-comment-form-update-submit',
|
||||
update_cancel: '.js-comment-form-update-cancel',
|
||||
comment_id: '#form_comment_reply'
|
||||
},
|
||||
toolbar: {
|
||||
|
@ -100,6 +104,8 @@ ls.comments = (function ($) {
|
|||
text: $(this.options.selectors.form.text),
|
||||
submit: $(this.options.selectors.form.submit),
|
||||
preview: $(this.options.selectors.form.preview),
|
||||
update_cancel: $(this.options.selectors.form.update_cancel),
|
||||
update_submit: $(this.options.selectors.form.update_submit),
|
||||
comment_id: $(this.options.selectors.form.comment_id)
|
||||
},
|
||||
toolbar: {
|
||||
|
@ -172,6 +178,27 @@ ls.comments = (function ($) {
|
|||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Редактирование
|
||||
this.elements.container.on('click', this.options.selectors.comment.update, function(e) {
|
||||
var oElement = $(this),
|
||||
iCommentId = oElement.data('id');
|
||||
|
||||
_this.formToggle(iCommentId,false,true);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Отмена редактирования
|
||||
this.elements.form.update_cancel.on('click', function (e) {
|
||||
_this.formToggle(_this.iFormTargetId,false,true);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Сохранение после редактирования
|
||||
this.elements.form.update_submit.on('click', function (e) {
|
||||
_this.submitCommentUpdate(_this.elements.form.form,_this.iFormTargetId);
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
// Сворачивание
|
||||
if (this.options.folding) {
|
||||
// Свернуть все
|
||||
|
@ -197,6 +224,8 @@ ls.comments = (function ($) {
|
|||
});
|
||||
}
|
||||
|
||||
this.initUpdateTimers();
|
||||
|
||||
ls.hook.run('ls_comments_init_after',[],this);
|
||||
};
|
||||
|
||||
|
@ -330,6 +359,7 @@ ls.comments = (function ($) {
|
|||
if (iCommentSelfId) {
|
||||
this.scrollToComment(this.getCommentById(iCommentSelfId));
|
||||
}
|
||||
this.initUpdateTimers();
|
||||
|
||||
ls.hook.run('ls_comments_load_after', [iTargetId, sTargetType, iCommentSelfId, bNotFlushNew, oResponse]);
|
||||
}
|
||||
|
@ -384,8 +414,9 @@ ls.comments = (function ($) {
|
|||
* @param {Number} iCommentId ID комментария
|
||||
* @param {Boolean} bNoFocus Переводить фокус на инпут с текстом или нет
|
||||
*/
|
||||
this.formToggle = function(iCommentId, bNoFocus) {
|
||||
this.formToggle = function(iCommentId, bNoFocus, bIsUpdate) {
|
||||
this.previewHide();
|
||||
bIsUpdate=bIsUpdate || false;
|
||||
|
||||
if (this.iFormTargetId == iCommentId && this.elements.form.form.is(':visible')) {
|
||||
this.elements.form.form.hide();
|
||||
|
@ -396,12 +427,92 @@ ls.comments = (function ($) {
|
|||
this.elements.form.form.insertAfter(iCommentId ? this.getCommentById(iCommentId) : this.elements.reply_root).show();
|
||||
this.elements.form.text.val('');
|
||||
this.elements.form.comment_id.val(iCommentId);
|
||||
/**
|
||||
* Показываем необходимые кнопки
|
||||
*/
|
||||
if (bIsUpdate) {
|
||||
this.elements.form.update_cancel.show();
|
||||
this.elements.form.update_submit.show();
|
||||
this.elements.form.submit.hide();
|
||||
/**
|
||||
* Загружаем исходный текст комментария
|
||||
*/
|
||||
this.loadCommentUpdate(iCommentId);
|
||||
} else {
|
||||
this.elements.form.update_cancel.hide();
|
||||
this.elements.form.update_submit.hide();
|
||||
this.elements.form.submit.show();
|
||||
}
|
||||
|
||||
this.iFormTargetId = iCommentId;
|
||||
|
||||
if ( ! bNoFocus ) this.elements.form.text.focus();
|
||||
};
|
||||
|
||||
this.loadCommentUpdate = function(iCommentId) {
|
||||
var sUrl = aRouter['ajax'] + 'comment/load/',
|
||||
oParams = { idComment: iCommentId };
|
||||
|
||||
ls.utils.formLock(this.elements.form.form);
|
||||
ls.hook.marker('loadBefore');
|
||||
|
||||
ls.ajax.load(sUrl, oParams, function(oResponse) {
|
||||
if (oResponse.bStateError) {
|
||||
ls.msg.error(null, oResponse.sMsg);
|
||||
} else {
|
||||
this.elements.form.text.val(oResponse.sText);
|
||||
}
|
||||
ls.hook.run('ls_comments_load_comment_update_after',[iCommentId, oResponse]);
|
||||
ls.utils.formUnlock(this.elements.form.form);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
this.submitCommentUpdate = function(oForm, iCommentId) {
|
||||
var oData = oForm.serializeJSON(),
|
||||
sUrl = aRouter['ajax'] + 'comment/update/';
|
||||
|
||||
ls.utils.formLock(oForm);
|
||||
this.previewHide();
|
||||
oData.comment_id=iCommentId;
|
||||
ls.ajax.load(sUrl, oData, function(oResponse) {
|
||||
if (oResponse.bStateError) {
|
||||
ls.msg.error(null, oResponse.sMsg);
|
||||
} else {
|
||||
var wrap=$('<div></div>').html(oResponse.sHtml);
|
||||
var comment=this.getCommentById(iCommentId);
|
||||
comment.find(this.options.selectors.comment.update_timer).stopTime();
|
||||
comment.replaceWith(wrap.children('.js-comment'));
|
||||
this.aComments = $(this.options.selectors.comment.comment); // hack
|
||||
this.formToggle(iCommentId, true);
|
||||
this.initUpdateTimers();
|
||||
this.scrollToComment(this.getCommentById(iCommentId));
|
||||
}
|
||||
ls.hook.run('ls_comments_submit_comment_update_after', [oForm, iCommentId, oResponse]);
|
||||
ls.utils.formUnlock(oForm);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
this.initUpdateTimers = function() {
|
||||
var _this=this;
|
||||
$(this.options.selectors.comment.update_timer).each(function(k,el){
|
||||
el=$(el);
|
||||
if (!el.data('isInit')) {
|
||||
el.data('isInit',true);
|
||||
el.everyTime(1000,function(){
|
||||
var seconds=parseInt(el.data('seconds'));
|
||||
seconds--;
|
||||
el.data('seconds',seconds);
|
||||
if (seconds>0) {
|
||||
el.text(ls.utils.timeRemaining(seconds));
|
||||
} else {
|
||||
el.parents(_this.options.selectors.comment.comment)
|
||||
.find(_this.options.selectors.comment.update).hide();
|
||||
el.stopTime();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Скрывает кнопку сворачивания у комментариев без дочерних комментариев
|
||||
*/
|
||||
|
|
|
@ -209,6 +209,11 @@ ls.media = (function ($) {
|
|||
$('.fotorama').fotorama();
|
||||
}.bind(this));
|
||||
|
||||
// Инициализация фоторамы после hедактирования коммента
|
||||
ls.hook.add('ls_comments_submit_comment_update_after',function(){
|
||||
$('.fotorama').fotorama();
|
||||
}.bind(this));
|
||||
|
||||
// После добавления комментария необходимо получить новый временный идентификатор и очистить галлерею
|
||||
ls.hook.add('ls_comments_add_after',function(){
|
||||
this.options.target_id='';
|
||||
|
|
|
@ -31,6 +31,7 @@ return array(
|
|||
'empty' => 'Тут ничего нет',
|
||||
'form_reset' => 'Очистить форму',
|
||||
'preview_text' => 'Предпросмотр',
|
||||
'times_declension' => 'раз;раза;раз',
|
||||
'error' => array(
|
||||
'add' => 'При добавлении возникла ошибка',
|
||||
'save' => 'Ошибка сохранения',
|
||||
|
@ -475,6 +476,7 @@ return array(
|
|||
'scroll_to_child' => 'Обратно к ответу',
|
||||
'target_author' => 'Автор',
|
||||
'url' => 'Ссылка на комментарий',
|
||||
'edit_info' => 'Комментарий отредактирован',
|
||||
),
|
||||
|
||||
// Сворачивание
|
||||
|
|
|
@ -242,4 +242,6 @@
|
|||
background: url(../images/icons.png) -168px 0 no-repeat;
|
||||
vertical-align: middle;
|
||||
}
|
||||
.user.inactive { color: #aaa; cursor: help; }
|
||||
.user.inactive { color: #aaa; cursor: help; }
|
||||
|
||||
.hide { display: none; }
|
|
@ -23,7 +23,13 @@
|
|||
{include 'forms/fields/form.field.hidden.tpl' sFieldName='reply' sFieldValue='0' sFieldId='form_comment_reply'}
|
||||
{include 'forms/fields/form.field.hidden.tpl' sFieldName='cmt_target_id' sFieldValue=$iTargetId}
|
||||
|
||||
{* Кнопки *}
|
||||
{* Кнопки создания *}
|
||||
{include 'forms/fields/form.field.button.tpl' sFieldName='submit_comment' sFieldText=$aLang.common.add sFieldStyle='primary' sFieldClasses='js-comment-form-submit'}
|
||||
|
||||
{* Кнопки редактирования *}
|
||||
{include 'forms/fields/form.field.button.tpl' sFieldName='submit_comment' sFieldType='button' sFieldText=$aLang.common.save sFieldStyle='primary' sFieldClasses='js-comment-form-update-submit hide'}
|
||||
{include 'forms/fields/form.field.button.tpl' sFieldName='submit_comment' sFieldType='button' sFieldText=$aLang.common.cancel sFieldClasses='js-comment-form-update-cancel fl-r hide'}
|
||||
|
||||
{* Общие кнопки *}
|
||||
{include 'forms/fields/form.field.button.tpl' sFieldText=$aLang.common.preview_text sFieldType='button' sFieldClasses='js-comment-form-preview'}
|
||||
</form>
|
|
@ -87,6 +87,15 @@
|
|||
{$oComment->getText()}
|
||||
</div>
|
||||
|
||||
{* Информация о редактировании *}
|
||||
{if $oComment->getDateEdit()}
|
||||
<div>
|
||||
{$aLang.comments.comment.edit_info}: {date_format date=$oComment->getDateEdit() hours_back="12" minutes_back="60" now="60" day="day H:i" format="j F Y, H:i"}
|
||||
{if $oComment->getCountEdit()>1}
|
||||
({$oComment->getCountEdit()} {$oComment->getCountEdit()|declension:$aLang.common.times_declension})
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{* Кнопки ответа, удаления и т.д. *}
|
||||
{if $oUserCurrent}
|
||||
|
@ -97,7 +106,18 @@
|
|||
|
||||
<li class="link-dotted comment-fold js-comment-fold open" data-id="{$oComment->getId()}" style="display: none"><a href="#">{$aLang.comments.folding.fold}</a></li>
|
||||
|
||||
{if $oUserCurrent and $oUserCurrent->isAdministrator()}
|
||||
{if $oComment->IsAllowEdit()}
|
||||
<li>
|
||||
<a href="#" class="link-dotted js-comment-update" data-id="{$oComment->getId()}">
|
||||
{$aLang.common.edit}
|
||||
{if $oComment->getEditTimeRemaining()}
|
||||
(<span class="js-comment-update-timer" data-seconds="{$oComment->getEditTimeRemaining()}"></span>)
|
||||
{/if}
|
||||
</a>
|
||||
</li>
|
||||
{/if}
|
||||
|
||||
{if $oComment->IsAllowDelete()}
|
||||
<li><a href="#" class="link-dotted js-comment-remove" data-id="{$oComment->getId()}">{($oComment->getDelete()) ? $aLang.comments.comment.restore : $aLang.common.remove}</a></li>
|
||||
{/if}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 5d82ea62c8a1ee4accf850d7de3aa127c033d0f0
|
||||
Subproject commit ca9d2968f88d2ce934d5d810682e726149353358
|
|
@ -499,4 +499,12 @@ ADD INDEX ( `target_type` ) ;
|
|||
-- 21.03.2014
|
||||
ALTER TABLE `prefix_media_target` ADD `is_preview` TINYINT( 1 ) NOT NULL DEFAULT '0',
|
||||
ADD INDEX ( `is_preview` ) ;
|
||||
ALTER TABLE `prefix_media_target` ADD `data` TEXT NOT NULL ;
|
||||
ALTER TABLE `prefix_media_target` ADD `data` TEXT NOT NULL ;
|
||||
|
||||
|
||||
-- 24.04.2014
|
||||
ALTER TABLE `prefix_comment` ADD `comment_text_source` TEXT NOT NULL AFTER `comment_text` ;
|
||||
ALTER TABLE `prefix_comment` ADD `comment_date_edit` DATETIME NULL DEFAULT NULL AFTER `comment_date` ,
|
||||
ADD INDEX ( `comment_date_edit` ) ;
|
||||
ALTER TABLE `prefix_comment` ADD `comment_count_edit` INT NOT NULL DEFAULT '0' AFTER `comment_count_favourite` ,
|
||||
ADD INDEX ( `comment_count_edit` ) ;
|
Loading…
Reference in a new issue