mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-09 21:42:10 +09:00
Merge pull request #324 from kijin/pr/redirect-after-board-write
#323 게시판에서 글이나 댓글을 작성 또는 삭제한 후 짧은 주소로 redirect하도록 변경
This commit is contained in:
commit
f40ea2e05d
5 changed files with 72 additions and 48 deletions
|
|
@ -59,11 +59,7 @@ class ModuleObject extends Object
|
|||
* */
|
||||
function setRedirectUrl($url = './', $output = NULL)
|
||||
{
|
||||
$ajaxRequestMethod = array_flip($this->ajaxRequestMethod);
|
||||
if(!isset($ajaxRequestMethod[Context::getRequestMethod()]))
|
||||
{
|
||||
$this->add('redirect_url', $url);
|
||||
}
|
||||
$this->add('redirect_url', $url);
|
||||
|
||||
if($output !== NULL && is_object($output))
|
||||
{
|
||||
|
|
|
|||
|
|
@ -377,6 +377,21 @@ function sendMailTo(to) {
|
|||
location.href="mailto:"+to;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief url이동 (Rhymix 개선된 버전)
|
||||
*/
|
||||
function redirect(url) {
|
||||
if (url === window.location.href || url.indexOf(window.location.href.replace(/#.+$/, "") + "#") === 0)
|
||||
{
|
||||
window.location.href = url;
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
window.location.href = url;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief url이동 (open_window 값이 N 가 아니면 새창으로 띄움)
|
||||
**/
|
||||
|
|
@ -394,7 +409,7 @@ function move_url(url, open_window) {
|
|||
if(open_window) {
|
||||
winopen(url);
|
||||
} else {
|
||||
location.href=url;
|
||||
redirect(url);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -102,9 +102,11 @@
|
|||
}
|
||||
|
||||
// If the response contains a redirect URL, redirect immediately.
|
||||
if (result.redirect_url) {
|
||||
window.location = result.redirect_url.replace(/&/g, "&");
|
||||
return null;
|
||||
if (data.redirect_url) {
|
||||
data.redirect_url = data.redirect_url.replace(/&/g, "&");
|
||||
}
|
||||
if (data.redirect_url && !$.isFunction(callback_success)) {
|
||||
return redirect(data.redirect_url);
|
||||
}
|
||||
|
||||
// If there was a success callback, call it.
|
||||
|
|
@ -220,6 +222,14 @@
|
|||
}
|
||||
}
|
||||
|
||||
// If the response contains a redirect URL, redirect immediately.
|
||||
if (data.redirect_url) {
|
||||
data.redirect_url = data.redirect_url.replace(/&/g, "&");
|
||||
}
|
||||
if (data.redirect_url && !$.isFunction(callback_success)) {
|
||||
return redirect(data.redirect_url);
|
||||
}
|
||||
|
||||
// If there was a success callback, call it.
|
||||
if($.isFunction(callback_success)) {
|
||||
callback_success(data);
|
||||
|
|
|
|||
|
|
@ -198,6 +198,7 @@ class boardController extends board
|
|||
}
|
||||
|
||||
// return the results
|
||||
$this->setRedirectUrl(getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '', 'document_srl', $output->get('document_srl')));
|
||||
$this->add('mid', Context::get('mid'));
|
||||
$this->add('document_srl', $output->get('document_srl'));
|
||||
|
||||
|
|
@ -406,6 +407,7 @@ class boardController extends board
|
|||
}
|
||||
|
||||
$this->setMessage('success_registed');
|
||||
$this->setRedirectUrl(getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '', 'document_srl', $obj->document_srl) . '#comment_' . $obj->comment_srl);
|
||||
$this->add('mid', Context::get('mid'));
|
||||
$this->add('document_srl', $obj->document_srl);
|
||||
$this->add('comment_srl', $obj->comment_srl);
|
||||
|
|
@ -456,6 +458,7 @@ class boardController extends board
|
|||
$this->add('page', Context::get('page'));
|
||||
$this->add('document_srl', $output->get('document_srl'));
|
||||
$this->setMessage('success_deleted');
|
||||
$this->setRedirectUrl(getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '', 'page', Context::get('page'), 'document_srl', $output->get('document_srl')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -480,6 +483,7 @@ class boardController extends board
|
|||
$this->add('page', Context::get('page'));
|
||||
$this->add('document_srl', $output->get('document_srl'));
|
||||
$this->setMessage('success_deleted');
|
||||
$this->setRedirectUrl(getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '', 'page', Context::get('page'), 'document_srl', $output->get('document_srl')));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -13,19 +13,21 @@ function completeDocumentInserted(ret_obj)
|
|||
var document_srl = ret_obj.document_srl;
|
||||
var category_srl = ret_obj.category_srl;
|
||||
|
||||
//alert(message);
|
||||
|
||||
var url;
|
||||
if(!document_srl)
|
||||
{
|
||||
url = current_url.setQuery('mid',mid).setQuery('act','');
|
||||
if (ret_obj.redirect_url) {
|
||||
redirect(ret_obj.redirect_url);
|
||||
} else {
|
||||
var url;
|
||||
if(!document_srl)
|
||||
{
|
||||
url = current_url.setQuery('mid',mid).setQuery('act','');
|
||||
}
|
||||
else
|
||||
{
|
||||
url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
|
||||
}
|
||||
if(category_srl) url = url.setQuery('category',category_srl);
|
||||
redirect(url);
|
||||
}
|
||||
else
|
||||
{
|
||||
url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
|
||||
}
|
||||
if(category_srl) url = url.setQuery('category',category_srl);
|
||||
location.href = url;
|
||||
}
|
||||
|
||||
/* delete the document */
|
||||
|
|
@ -38,10 +40,7 @@ function completeDeleteDocument(ret_obj)
|
|||
|
||||
var url = current_url.setQuery('mid',mid).setQuery('act','').setQuery('document_srl','');
|
||||
if(page) url = url.setQuery('page',page);
|
||||
|
||||
//alert(message);
|
||||
|
||||
location.href = url;
|
||||
redirect(url);
|
||||
}
|
||||
|
||||
/* document search */
|
||||
|
|
@ -54,8 +53,7 @@ function completeVote(ret_obj)
|
|||
{
|
||||
var error = ret_obj.error;
|
||||
var message = ret_obj.message;
|
||||
alert(message);
|
||||
location.href = location.href;
|
||||
redirect(window.location.href);
|
||||
}
|
||||
|
||||
// current page reload
|
||||
|
|
@ -63,8 +61,7 @@ function completeReload(ret_obj)
|
|||
{
|
||||
var error = ret_obj.error;
|
||||
var message = ret_obj.message;
|
||||
|
||||
location.href = location.href;
|
||||
redirect(window.location.href);
|
||||
}
|
||||
|
||||
/* complete to insert comment*/
|
||||
|
|
@ -75,13 +72,13 @@ function completeInsertComment(ret_obj)
|
|||
var mid = ret_obj.mid;
|
||||
var document_srl = ret_obj.document_srl;
|
||||
var comment_srl = ret_obj.comment_srl;
|
||||
|
||||
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
|
||||
if(comment_srl) url = url.setQuery('rnd',comment_srl)+"#comment_"+comment_srl;
|
||||
|
||||
//alert(message);
|
||||
|
||||
location.href = url;
|
||||
if (ret_obj.redirect_url) {
|
||||
redirect(ret_obj.redirect_url);
|
||||
} else {
|
||||
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
|
||||
if (comment_srl) url = url.setQuery('rnd',comment_srl)+"#comment_"+comment_srl;
|
||||
redirect(url);
|
||||
}
|
||||
}
|
||||
|
||||
/* delete the comment */
|
||||
|
|
@ -93,12 +90,13 @@ function completeDeleteComment(ret_obj)
|
|||
var document_srl = ret_obj.document_srl;
|
||||
var page = ret_obj.page;
|
||||
|
||||
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
|
||||
if(page) url = url.setQuery('page',page);
|
||||
|
||||
//alert(message);
|
||||
|
||||
location.href = url;
|
||||
if (ret_obj.redirect_url) {
|
||||
redirect(ret_obj.redirect_url);
|
||||
} else {
|
||||
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
|
||||
if (page) url = url.setQuery('page',page);
|
||||
redirect(url);
|
||||
}
|
||||
}
|
||||
|
||||
/* delete the trackback */
|
||||
|
|
@ -110,12 +108,13 @@ function completeDeleteTrackback(ret_obj)
|
|||
var document_srl = ret_obj.document_srl;
|
||||
var page = ret_obj.page;
|
||||
|
||||
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
|
||||
if(page) url = url.setQuery('page',page);
|
||||
|
||||
//alert(message);
|
||||
|
||||
location.href = url;
|
||||
if (ret_obj.redirect_url) {
|
||||
redirect(ret_obj.redirect_url);
|
||||
} else {
|
||||
var url = current_url.setQuery('mid',mid).setQuery('document_srl',document_srl).setQuery('act','');
|
||||
if (page) url = url.setQuery('page',page);
|
||||
redirect(url);
|
||||
}
|
||||
}
|
||||
|
||||
/* change category */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue