mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Merge branch 'rhymix:master' into master
This commit is contained in:
commit
cb1fd188ef
111 changed files with 4286 additions and 5469 deletions
|
|
@ -49,6 +49,7 @@
|
|||
<action name="procDocumentAdminInsertExtraVar" type="controller" permission="manager:config:*" check_var="module_srl" ruleset="insertExtraVar" />
|
||||
<action name="procDocumentAdminDeleteExtraVar" type="controller" permission="manager:config:*" check_var="module_srl" />
|
||||
<action name="procDocumentAdminMoveExtraVar" type="controller" permission="manager:config:*" check_var="module_srl" />
|
||||
<action name="procDocumentAdminReorderExtraVars" type="controller" permission="manager:config:*" check_var="module_srl" />
|
||||
<action name="procDocumentAdminRecalculateCategoryCounts" type="controller" />
|
||||
</actions>
|
||||
<eventHandlers>
|
||||
|
|
|
|||
|
|
@ -246,29 +246,50 @@ class DocumentAdminController extends Document
|
|||
$type = Context::get('type');
|
||||
$module_srl = Context::get('module_srl');
|
||||
$var_idx = Context::get('var_idx');
|
||||
if (!$type || !$module_srl || !$var_idx)
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
if(!$type || !$module_srl || !$var_idx) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
$module_info = ModuleModel::getModuleInfoByModuleSrl($module_srl);
|
||||
if (!$module_info || !$module_info->module_srl)
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\TargetNotFound;
|
||||
}
|
||||
|
||||
$oModuleModel = getModel('module');
|
||||
$module_info = $oModuleModel->getModuleInfoByModuleSrl($module_srl);
|
||||
if(!$module_info->module_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
$extra_keys = DocumentModel::getExtraKeys($module_srl);
|
||||
if (!$extra_keys)
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\TargetNotFound;
|
||||
}
|
||||
if (!$extra_keys[$var_idx])
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$oDocumentModel = getModel('document');
|
||||
$extra_keys = $oDocumentModel->getExtraKeys($module_srl);
|
||||
if(!$extra_keys[$var_idx]) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
|
||||
if($type == 'up') $new_idx = $var_idx-1;
|
||||
else $new_idx = $var_idx+1;
|
||||
if($new_idx<1) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
$new_idx = ($type === 'up') ? $var_idx - 1 : $var_idx + 1;
|
||||
if ($new_idx < 1)
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
$args = new stdClass();
|
||||
$args->module_srl = $module_srl;
|
||||
$args->var_idx = $new_idx;
|
||||
$output = executeQuery('document.getDocumentExtraKeys', $args);
|
||||
if (!$output->toBool()) return $output;
|
||||
if (!$output->data) throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
if (!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
if (!$output->data)
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
unset($args);
|
||||
|
||||
$oDB = DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
// update immediately if there is no idx to change
|
||||
if(!$extra_keys[$new_idx])
|
||||
{
|
||||
|
|
@ -277,11 +298,19 @@ class DocumentAdminController extends Document
|
|||
$args->var_idx = $var_idx;
|
||||
$args->new_idx = $new_idx;
|
||||
$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
// replace if exists
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
// replace if exists
|
||||
else
|
||||
{
|
||||
$args = new stdClass();
|
||||
|
|
@ -289,25 +318,174 @@ class DocumentAdminController extends Document
|
|||
$args->var_idx = $new_idx;
|
||||
$args->new_idx = -10000;
|
||||
$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$args->var_idx = $var_idx;
|
||||
$args->new_idx = $new_idx;
|
||||
$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$args->var_idx = -10000;
|
||||
$args->new_idx = $var_idx;
|
||||
$output = executeQuery('document.updateDocumentExtraKeyIdx', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
$output = executeQuery('document.updateDocumentExtraVarIdx', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
$oDB->commit();
|
||||
|
||||
Rhymix\Framework\Cache::delete("site_and_module:module_document_extra_keys:$module_srl");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reorder extra vars of a module.
|
||||
*/
|
||||
public function procDocumentAdminReorderExtraVars()
|
||||
{
|
||||
// Validate input data.
|
||||
$module_srl = intval(Context::get('module_srl'));
|
||||
$order = Context::get('order');
|
||||
if (!$module_srl || !$order || !is_array($order))
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
foreach ($order as $key => $val)
|
||||
{
|
||||
$order[$key] = $val = (object)$val;
|
||||
if (empty($val->eid))
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
}
|
||||
|
||||
// Validate module info and existing extra keys.
|
||||
$module_info = ModuleModel::getModuleInfoByModuleSrl($module_srl);
|
||||
if (!$module_info || !$module_info->module_srl)
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\TargetNotFound;
|
||||
}
|
||||
|
||||
$extra_keys = DocumentModel::getExtraKeys($module_srl);
|
||||
if (!$extra_keys)
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\TargetNotFound;
|
||||
}
|
||||
$extra_keys = array_combine(array_map(function($item) {
|
||||
return $item->eid;
|
||||
}, $extra_keys), array_values($extra_keys));
|
||||
|
||||
// Calculate changes.
|
||||
// We don't actually do anything with the submitted values of old/new idx.
|
||||
// We calculate them anew with the data we have on the server.
|
||||
$changes = [];
|
||||
$i = 1;
|
||||
foreach ($order as $key => $val)
|
||||
{
|
||||
if (!isset($extra_keys[$val->eid]))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if ($i != $extra_keys[$val->eid]->idx)
|
||||
{
|
||||
$changes[] = [
|
||||
'eid' => $val->eid,
|
||||
'old_idx' => $extra_keys[$val->eid]->idx,
|
||||
'new_idx' => $i,
|
||||
];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Begin transaction.
|
||||
$oDB = DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
// Apply changes.
|
||||
// We need to do this twice because of the unique constraint.
|
||||
foreach ($changes as $change)
|
||||
{
|
||||
$output = executeQuery('document.updateDocumentExtraKeyIdx', [
|
||||
'module_srl' => $module_srl,
|
||||
'eid' => $change['eid'],
|
||||
'var_idx' => $change['old_idx'],
|
||||
'new_idx' => $change['new_idx'] - 10000,
|
||||
]);
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$output = executeQuery('document.updateDocumentExtraVarIdx', [
|
||||
'module_srl' => $module_srl,
|
||||
'eid' => $change['eid'],
|
||||
'var_idx' => $change['old_idx'],
|
||||
'new_idx' => $change['new_idx'] - 10000,
|
||||
]);
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
foreach ($changes as $change)
|
||||
{
|
||||
$output = executeQuery('document.updateDocumentExtraKeyIdx', [
|
||||
'module_srl' => $module_srl,
|
||||
'var_idx' => $change['new_idx'] - 10000,
|
||||
'new_idx' => $change['new_idx'],
|
||||
]);
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$output = executeQuery('document.updateDocumentExtraVarIdx', [
|
||||
'module_srl' => $module_srl,
|
||||
'var_idx' => $change['new_idx'] - 10000,
|
||||
'new_idx' => $change['new_idx'],
|
||||
]);
|
||||
if (!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
// Commit.
|
||||
$oDB->commit();
|
||||
|
||||
// Clear cache.
|
||||
Rhymix\Framework\Cache::delete("site_and_module:module_document_extra_keys:$module_srl");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1780,6 +1780,7 @@ class DocumentController extends Document
|
|||
$output = executeQuery('document.updateDocumentExtraVar', $obj);
|
||||
}
|
||||
|
||||
unset($GLOBALS['XE_EXTRA_KEYS'][$module_srl]);
|
||||
Rhymix\Framework\Cache::delete("site_and_module:module_document_extra_keys:$module_srl");
|
||||
return $output;
|
||||
}
|
||||
|
|
@ -1836,6 +1837,7 @@ class DocumentController extends Document
|
|||
|
||||
$oDB->commit();
|
||||
|
||||
unset($GLOBALS['XE_EXTRA_KEYS'][$module_srl]);
|
||||
Rhymix\Framework\Cache::delete("site_and_module:module_document_extra_keys:$module_srl");
|
||||
return new BaseObject();
|
||||
}
|
||||
|
|
@ -3714,6 +3716,7 @@ Content;
|
|||
if ($type === 'all' || $type === 'extra_vars')
|
||||
{
|
||||
unset($GLOBALS['XE_EXTRA_VARS'][$document_srl]);
|
||||
unset($GLOBALS['XE_EXTRA_CHK'][$document_srl]);
|
||||
unset($GLOBALS['RX_DOCUMENT_LANG'][$document_srl]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,19 +55,16 @@ class DocumentModel extends Document
|
|||
return;
|
||||
}
|
||||
|
||||
static $checked = array();
|
||||
static $module_extra_keys = array();
|
||||
|
||||
// check documents
|
||||
$document_srls = array();
|
||||
foreach($_document_list as $document_srl => $oDocument)
|
||||
{
|
||||
if(isset($checked[$document_srl]) || !($oDocument instanceof documentItem) || !$oDocument->isExists())
|
||||
if(isset($GLOBALS['XE_EXTRA_CHK'][$document_srl]) || !($oDocument instanceof documentItem) || !$oDocument->isExists())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$checked[$document_srl] = true;
|
||||
$GLOBALS['XE_EXTRA_CHK'][$document_srl] = true;
|
||||
$document_srls[] = $document_srl;
|
||||
}
|
||||
|
||||
|
|
@ -102,16 +99,16 @@ class DocumentModel extends Document
|
|||
if(!isset($GLOBALS['XE_EXTRA_VARS'][$document_srl]))
|
||||
{
|
||||
// get extra keys of the module
|
||||
if(!isset($module_extra_keys[$module_srl]))
|
||||
if(!isset($GLOBALS['XE_EXTRA_KEYS'][$module_srl]))
|
||||
{
|
||||
$module_extra_keys[$module_srl] = self::getExtraKeys($module_srl);
|
||||
$GLOBALS['XE_EXTRA_KEYS'][$module_srl] = self::getExtraKeys($module_srl);
|
||||
}
|
||||
|
||||
// set extra variables of the document
|
||||
if($module_extra_keys[$module_srl])
|
||||
if(!empty($GLOBALS['XE_EXTRA_KEYS'][$module_srl]))
|
||||
{
|
||||
$document_extra_vars = array();
|
||||
foreach($module_extra_keys[$module_srl] as $idx => $key)
|
||||
foreach($GLOBALS['XE_EXTRA_KEYS'][$module_srl] as $idx => $key)
|
||||
{
|
||||
$document_extra_vars[$idx] = clone($key);
|
||||
|
||||
|
|
@ -1491,11 +1488,13 @@ class DocumentModel extends Document
|
|||
case 'nick_name' :
|
||||
case 'email_address' :
|
||||
case 'homepage' :
|
||||
case 'regdate' :
|
||||
case 'last_update' :
|
||||
case 'ipaddress' :
|
||||
$args->{'s_' . $search_target} = str_replace(' ', '%', $search_keyword);
|
||||
break;
|
||||
case 'regdate' :
|
||||
case 'last_update' :
|
||||
$args->{'s_' . $search_target} = preg_replace('/[^\d]/', '', $search_keyword);
|
||||
break;
|
||||
case 'member_srl' :
|
||||
case 'readed_count' :
|
||||
case 'voted_count' :
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
<condition operation="equal" column="var_idx" var="var_idx" filter="number" notnull="notnull" pipe="and" />
|
||||
<condition operation="equal" column="var_idx" var="var_idx" filter="number" />
|
||||
<condition operation="equal" column="eid" var="eid" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
<condition operation="equal" column="var_idx" var="var_idx" filter="number" notnull="notnull" pipe="and" />
|
||||
<condition operation="equal" column="var_idx" var="var_idx" filter="number" />
|
||||
<condition operation="equal" column="eid" var="eid" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@
|
|||
<a class="x_btn" href="{getUrl('type','insertExtraForm','selected_var_idx','')}">{$lang->cmd_insert}</a>
|
||||
</div>
|
||||
</div>
|
||||
<table class="x_table x_table-striped x_table-hover">
|
||||
<table class="x_table x_table-striped x_table-hover sortable extra_keys" data-module-srl="{$module_srl}">
|
||||
<thead>
|
||||
<tr class="nowr">
|
||||
<th>{$lang->no}</th>
|
||||
|
|
@ -123,10 +123,15 @@
|
|||
<th> </th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody class="uDrag">
|
||||
<block loop="$extra_keys => $key,$val">
|
||||
<tr>
|
||||
<td rowspan="2"|cond="$val->desc">{$val->idx}</td>
|
||||
<tr data-eid="{$val->eid}" data-idx="{$val->idx}">
|
||||
<td>
|
||||
<div class="wrap" style="user-select:none">
|
||||
<button type="button" class="dragBtn">Move to</button>
|
||||
<span class="var_idx">{$val->idx}</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>{$val->eid}</td>
|
||||
<td class="nowr"><strong>{$val->name}</strong></td>
|
||||
<td class="nowr">{$lang->column_type_list[$val->type]}</td>
|
||||
|
|
@ -144,9 +149,6 @@
|
|||
<button type="button" class="x_icon-trash" onclick="return doDeleteExtraKey('{$module_srl}','{$val->idx}');">{$lang->cmd_delete}</button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr cond="$val->desc">
|
||||
<td colspan="7">{$val->desc}</td>
|
||||
</tr>
|
||||
</block>
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
|||
|
|
@ -3,12 +3,10 @@
|
|||
* @brief 모든 생성된 섬네일 삭제하는 액션 호출
|
||||
**/
|
||||
function doDeleteAllThumbnail() {
|
||||
exec_xml('document','procDocumentAdminDeleteAllThumbnail', [], completeDeleteAllThumbnail);
|
||||
}
|
||||
|
||||
function completeDeleteAllThumbnail(ret_obj) {
|
||||
alert(ret_obj['message']);
|
||||
location.reload();
|
||||
Rhymix.ajax('document.procDocumentAdminDeleteAllThumbnail', {}, function(ret_obj) {
|
||||
alert(ret_obj['message']);
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
/* 선택된 글의 삭제 또는 이동 */
|
||||
|
|
@ -28,22 +26,20 @@ function completeManageDocument(ret_obj) {
|
|||
window.close();
|
||||
}
|
||||
|
||||
|
||||
/* 신고 취소 */
|
||||
function doCancelDeclare() {
|
||||
var document_srl = [];
|
||||
jQuery('#fo_list input[name=cart]:checked').each(function() {
|
||||
document_srl[document_srl.length] = jQuery(this).val();
|
||||
$('#fo_list input[name=cart]:checked').each(function() {
|
||||
document_srl.push($(this).val());
|
||||
});
|
||||
if (document_srl.length < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(document_srl.length<1) return;
|
||||
|
||||
var params = {document_srl : document_srl.join(',')};
|
||||
|
||||
exec_xml('document','procDocumentAdminCancelDeclare', params, completeCancelDeclare);
|
||||
}
|
||||
|
||||
function completeCancelDeclare(ret_obj) {
|
||||
location.reload();
|
||||
var params = { document_srl : document_srl.join(',') };
|
||||
Rhymix.ajax('document.procDocumentAdminCancelDeclare', params, function() {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function completeInsertExtraVar(ret_obj) {
|
||||
|
|
@ -93,8 +89,9 @@ function moveVar(type, module_srl, var_idx) {
|
|||
module_srl : module_srl,
|
||||
var_idx : var_idx
|
||||
};
|
||||
var response_tags = ['error','message'];
|
||||
exec_xml('document','procDocumentAdminMoveExtraVar', params, function() { location.reload() });
|
||||
Rhymix.ajax('document.procDocumentAdminMoveExtraVar', params, function() {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function completeRestoreTrash(ret_obj) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,31 @@
|
|||
(function($) {
|
||||
$(function() {
|
||||
|
||||
// Reorder extra keys
|
||||
$('table.extra_keys.sortable').on('after-drag.st', function(e) {
|
||||
const $table = $(this);
|
||||
let order = [];
|
||||
let i = 1;
|
||||
$table.find('tbody > tr').each(function() {
|
||||
order.push({
|
||||
eid: $(this).data('eid'),
|
||||
old_idx: parseInt($(this).data('idx'), 10),
|
||||
new_idx: i++
|
||||
});
|
||||
});
|
||||
Rhymix.ajax('document.procDocumentAdminReorderExtraVars', {
|
||||
module_srl: $(this).data('moduleSrl'),
|
||||
order: order
|
||||
}, function() {
|
||||
let i = 1;
|
||||
$table.find('.var_idx').each(function() {
|
||||
$(this).text(i);
|
||||
i++;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Show or hide fields depending on the type of variable
|
||||
$('select#type').on('change', function() {
|
||||
const selected_type = $(this).val();
|
||||
$(this).parents('form').find('.x_control-group').each(function() {
|
||||
|
|
@ -21,5 +47,6 @@
|
|||
}
|
||||
});
|
||||
}).triggerHandler('change');
|
||||
|
||||
});
|
||||
})(jQuery);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue