Merge remote-tracking branch 'upstream/master' into master

This commit is contained in:
Lastorder-DC 2025-10-27 23:09:27 +09:00
commit 1c8ae0d766
52 changed files with 447 additions and 1007 deletions

View file

@ -183,7 +183,8 @@ class DocumentAdminController extends Document
$options = array_map('trim', explode("\n", $options));
}
$desc = Context::get('desc') ? Context::get('desc') : '';
$search = Context::get('search');
$search = Context::get('search') === 'Y' ? 'Y' : 'N';
$sort = Context::get('sort') === 'Y' ? 'Y' : 'N';
$eid = Context::get('eid');
$obj = new stdClass();
@ -210,7 +211,7 @@ class DocumentAdminController extends Document
$oDocumentController = DocumentController::getInstance();
$output = $oDocumentController->insertDocumentExtraKey(
$module_srl, $var_idx, $name, $type, $is_required, $search,
$default, $desc, $eid, $is_strict, $options
$default, $desc, $eid, $is_strict, $options, $sort
);
if(!$output->toBool()) return $output;

View file

@ -87,9 +87,6 @@ class Document extends ModuleObject
if(!$oDB->isIndexExists("document_extra_vars", "unique_extra_vars")) return true;
if($oDB->isIndexExists("document_extra_vars", "unique_module_vars")) return true;
// 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table
if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order")) return true;
// 2011. 10. 25 status index check
if(!$oDB->isIndexExists("documents", "idx_module_status")) return true;
@ -113,6 +110,14 @@ class Document extends ModuleObject
if(!$oDB->isColumnExists('document_extra_keys', 'var_is_strict')) return true;
if(!$oDB->isColumnExists('document_extra_keys', 'var_options')) return true;
// 2025.10.23 Add sort to document_extra_keys table, and sort_value to document_extra_vars table
if(!$oDB->isColumnExists('document_extra_keys', 'var_sort')) return true;
if(!$oDB->isColumnExists('document_extra_vars', 'sort_value') || !$oDB->isIndexExists('document_extra_vars', 'idx_sort_value')) return true;
if(!$oDB->isIndexExists('document_extra_vars', 'idx_prefix_value')) return true;
// Delete unnecessary index
if($oDB->isIndexExists('document_extra_vars', 'idx_document_list_order')) return true;
return false;
}
@ -178,12 +183,7 @@ class Document extends ModuleObject
$oDB->dropIndex("document_extra_vars", "unique_module_vars", true);
}
// 2011. 03. 30 Cubrid index Check the index in the document_extra_vars table
if(!$oDB->isIndexExists("document_extra_vars", "idx_document_list_order"))
{
$oDB->addIndex("document_extra_vars", "idx_document_list_order", array("document_srl","module_srl","var_idx"), false);
}
// 2011. 10. 25 status index check
if(!$oDB->isIndexExists("documents", "idx_module_status"))
{
$oDB->addIndex("documents", "idx_module_status", array("module_srl","status"));
@ -233,6 +233,47 @@ class Document extends ModuleObject
{
$oDB->addColumn('document_extra_keys', 'var_options', 'text', null, null, false, 'var_default');
}
// 2025.10.23 Add sort to document_extra_keys table, and sort_value to document_extra_vars table
if(!$oDB->isColumnExists('document_extra_keys', 'var_sort'))
{
$oDB->addColumn('document_extra_keys', 'var_sort', 'char', '1', 'N', true, 'var_search');
}
if(!$oDB->isColumnExists('document_extra_vars', 'sort_value') || !$oDB->isIndexExists('document_extra_vars', 'idx_sort_value'))
{
$oDB->addColumn('document_extra_vars', 'sort_value', 'bigint', null, null, false, 'value');
$oDB->begin();
$output = executeQueryArray('document.getDocumentNumericExtraKeys', ['var_type' => 'number']);
if (!$output->toBool())
{
$oDB->rollback();
return $output;
}
foreach ($output->data ?? [] as $item)
{
$output = executeQuery('document.updateDocumentExtraVarSortValue', [
'module_srl' => $item->module_srl,
'var_idx' => $item->var_idx,
]);
if (!$output->toBool())
{
$oDB->rollback();
return $output;
}
}
$oDB->commit();
$oDB->addIndex('document_extra_vars', 'idx_sort_value', array('module_srl', 'sort_value'));
}
if(!$oDB->isIndexExists('document_extra_vars', 'idx_prefix_value'))
{
$oDB->addIndex('document_extra_vars', 'idx_prefix_value', array('module_srl', 'value(10)'));
}
// Delete unnecessary index
if($oDB->isIndexExists('document_extra_vars', 'idx_document_list_order'))
{
$oDB->dropIndex('document_extra_vars', 'idx_document_list_order');
}
}
/**

View file

@ -761,7 +761,7 @@ class DocumentController extends Document
{
if (!$category_list[$obj->category_srl]->grant)
{
return new BaseObject(-1, 'msg_not_permitted');
return new BaseObject(-1, 'document.msg_category_not_permitted');
}
}
else
@ -769,6 +769,10 @@ class DocumentController extends Document
$obj->category_srl = 0;
}
}
else
{
$obj->category_srl = 0;
}
}
// Set the read counts and update order.
@ -851,7 +855,7 @@ class DocumentController extends Document
{
foreach($extra_keys as $idx => $extra_item)
{
$value = NULL;
$value = $sort_value = null;
if(isset($obj->{'extra_vars'.$idx}))
{
$tmp = $obj->{'extra_vars'.$idx};
@ -904,7 +908,11 @@ class DocumentController extends Document
}
$extra_vars[$extra_item->name] = $value;
$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
if ($extra_item->type === 'number')
{
$sort_value = (int)$value;
}
$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid, null, $sort_value);
}
}
@ -1117,7 +1125,7 @@ class DocumentController extends Document
{
if (!$category_list[$obj->category_srl]->grant)
{
return new BaseObject(-1, 'msg_not_permitted');
return new BaseObject(-1, 'document.msg_category_not_permitted');
}
}
else
@ -1125,6 +1133,10 @@ class DocumentController extends Document
$obj->category_srl = 0;
}
}
else
{
$obj->category_srl = 0;
}
}
// Hash the password if it exists
@ -1234,7 +1246,7 @@ class DocumentController extends Document
{
foreach($extra_keys as $idx => $extra_item)
{
$value = NULL;
$value = $sort_value = null;
if(isset($obj->{'extra_vars'.$idx}))
{
$tmp = $obj->{'extra_vars'.$idx};
@ -1331,7 +1343,11 @@ class DocumentController extends Document
}
}
$extra_vars[$extra_item->name] = $value;
$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid);
if ($extra_item->type === 'number')
{
$sort_value = (int)$value;
}
$this->insertDocumentExtraVar($obj->module_srl, $obj->document_srl, $idx, $value, $extra_item->eid, null, $sort_value);
}
}
@ -1779,9 +1795,10 @@ class DocumentController extends Document
* @param int $eid
* @param string $var_is_strict
* @param array $var_options
* @param string $var_sort
* @return object
*/
function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid = 0, $var_is_strict = 'N', $var_options = null)
function insertDocumentExtraKey($module_srl, $var_idx, $var_name, $var_type, $var_is_required = 'N', $var_search = 'N', $var_default = '', $var_desc = '', $eid = 0, $var_is_strict = 'N', $var_options = null, $var_sort = 'N')
{
if (!$module_srl || !$var_idx || !$var_name || !$var_type || !$eid)
{
@ -1796,6 +1813,7 @@ class DocumentController extends Document
$obj->var_is_required = $var_is_required=='Y'?'Y':'N';
$obj->var_is_strict = $var_is_strict=='Y'?'Y':'N';
$obj->var_search = $var_search=='Y'?'Y':'N';
$obj->var_sort = $var_sort=='Y'?'Y':'N';
$obj->var_default = $var_default;
$obj->var_options = $var_options ? json_encode($var_options, \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES) : null;
$obj->var_desc = $var_desc;
@ -1883,9 +1901,10 @@ class DocumentController extends Document
* @param mixed $value
* @param int $eid
* @param string $lang_code
* @return Object|void
* @param ?int $sort_value
* @return BaseObject
*/
public static function insertDocumentExtraVar($module_srl, $document_srl, $idx_or_eid, $value, $eid = null, $lang_code = null)
public static function insertDocumentExtraVar($module_srl, $document_srl, $idx_or_eid, $value, $eid = null, $lang_code = null, $sort_value = null)
{
if(!$module_srl || !$document_srl || !$idx_or_eid || !isset($value))
{
@ -1918,6 +1937,7 @@ class DocumentController extends Document
$obj->document_srl = $document_srl;
$obj->var_idx = $idx_or_eid;
$obj->value = $value;
$obj->sort_value = $sort_value;
$obj->lang_code = $lang_code ?: Context::getLangType();
$obj->eid = $eid;
@ -1932,9 +1952,10 @@ class DocumentController extends Document
* @param mixed $value
* @param int $eid
* @param string $lang_code
* @return Object|void
* @param ?int $sort_value
* @return BaseObject
*/
public static function updateDocumentExtraVar($module_srl, $document_srl, $idx_or_eid, $value, $eid = null, $lang_code = null)
public static function updateDocumentExtraVar($module_srl, $document_srl, $idx_or_eid, $value, $eid = null, $lang_code = null, $sort_value = null)
{
if(!$module_srl || !$document_srl || !$idx_or_eid || !isset($value))
{
@ -1962,13 +1983,10 @@ class DocumentController extends Document
}
}
$obj = new stdClass;
$obj->module_srl = $module_srl;
$obj->document_srl = $document_srl;
$obj->var_idx = $idx_or_eid;
$obj->value = $value;
$obj->lang_code = $lang_code ?: Context::getLangType();
$obj->eid = $eid;
if (!$lang_code)
{
$lang_code = Context::getLangType();
}
$oDB = DB::getInstance();
$oDB->begin();
@ -1980,7 +1998,7 @@ class DocumentController extends Document
return $output;
}
$output = self::insertDocumentExtraVar($module_srl, $document_srl, $idx_or_eid, $value, $eid, $lang_code);
$output = self::insertDocumentExtraVar($module_srl, $document_srl, $idx_or_eid, $value, $eid, $lang_code, $sort_value);
if (!$output->toBool())
{
$oDB->rollback();
@ -1998,7 +2016,7 @@ class DocumentController extends Document
* @param int $var_idx
* @param string $lang_code
* @param int $eid
* @return $output
* @return BaseObject
*/
public static function deleteDocumentExtraVars($module_srl, $document_srl = null, $var_idx = null, $lang_code = null, $eid = null)
{
@ -2008,8 +2026,7 @@ class DocumentController extends Document
if(!is_null($var_idx)) $obj->var_idx = $var_idx;
if(!is_null($lang_code)) $obj->lang_code = $lang_code;
if(!is_null($eid)) $obj->eid = $eid;
$output = executeQuery('document.deleteDocumentExtraVars', $obj);
return $output;
return executeQuery('document.deleteDocumentExtraVars', $obj);
}

View file

@ -239,6 +239,7 @@ class DocumentModel extends Document
$sort_check = self::_setSortIndex($obj, $load_extra_vars);
$obj->sort_index = $sort_check->sort_index;
$obj->isExtraVars = $sort_check->isExtraVars;
$obj->isExtraVarsSortAsNumber = $sort_check->isExtraVarsSortAsNumber;
$obj->except_notice = $except_notice;
$obj->columnList = $columnList;
@ -672,6 +673,7 @@ class DocumentModel extends Document
$sort_check = self::_setSortIndex($opt);
$opt->sort_index = $sort_check->sort_index;
$opt->isExtraVars = $sort_check->isExtraVars;
$opt->isExtraVarsSortAsNumber = $sort_check->isExtraVarsSortAsNumber;
self::_setSearchOption($opt, $args, $query_id, $use_division);
@ -1348,6 +1350,7 @@ class DocumentModel extends Document
$args = new stdClass;
$args->sort_index = $obj->sort_index ?? null;
$args->isExtraVars = false;
$args->isExtraVarsSortAsNumber = false;
// check it's default sort
$default_sort = array('list_order', 'regdate', 'last_update', 'update_order', 'readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count', 'title', 'category_srl');
@ -1363,20 +1366,20 @@ class DocumentModel extends Document
return $args;
}
$eids = array();
foreach($extra_keys as $idx => $key)
foreach($extra_keys as $extra_key)
{
$eids[] = $key->eid;
if ($args->sort_index === $extra_key->eid)
{
$args->isExtraVars = true;
if ($extra_key->type === 'number')
{
$args->isExtraVarsSortAsNumber = true;
}
return $args;
}
}
// check it exists in extra keys of the module
if(!in_array($args->sort_index, $eids))
{
$args->sort_index = 'list_order';
return $args;
}
$args->isExtraVars = true;
$args->sort_index = 'list_order';
return $args;
}
@ -1560,7 +1563,14 @@ class DocumentModel extends Document
{
$args->sort_eid = $args->sort_index;
$args->sort_lang = Context::getLangType();
$args->sort_index = 'extra_sort.value';
if ($searchOpt->isExtraVarsSortAsNumber ?? false)
{
$args->sort_index = 'extra_sort.sort_value';
}
else
{
$args->sort_index = 'extra_sort.value';
}
}
$query_id = 'document.getDocumentListWithExtraVars';
}

View file

@ -38,6 +38,7 @@ $lang->msg_category_not_moved = 'Could not be moved';
$lang->msg_is_secret = 'This is a secret article.';
$lang->msg_checked_document_is_deleted = '%d article(s) was(were) deleted.';
$lang->msg_document_is_admin_not_permitted = 'You don\'t have permission to delete the posts of Top Admin.';
$lang->msg_category_not_permitted = 'You don\'t have permission to post in the selected category.';
$lang->move_target_module = 'Target module ';
$lang->search_target_list['title'] = 'Subject';
$lang->search_target_list['content'] = 'Content';

View file

@ -38,6 +38,7 @@ $lang->msg_category_not_moved = '이동할 수 없습니다.';
$lang->msg_is_secret = '비밀글입니다.';
$lang->msg_checked_document_is_deleted = '%d개의 글이 삭제되었습니다.';
$lang->msg_document_is_admin_not_permitted = '최고 관리자의 게시글을 삭제할 권한이 없습니다.';
$lang->msg_category_not_permitted = '선택한 분류에 게시할 권한이 없습니다.';
$lang->move_target_module = '대상 페이지';
$lang->search_target_list['title'] = '제목';
$lang->search_target_list['content'] = '내용';

View file

@ -10,6 +10,7 @@
<column name="var_is_required" alias="is_required" />
<column name="var_is_strict" alias="is_strict" />
<column name="var_search" alias="search" />
<column name="var_sort" alias="sort" />
<column name="var_default" alias="default" />
<column name="var_options" alias="options" />
<column name="var_desc" alias="desc" />

View file

@ -0,0 +1,13 @@
<query id="getDocumentNumericExtraKeys" action="select">
<tables>
<table name="document_extra_keys" />
</tables>
<columns>
<column name="module_srl" />
<column name="var_idx" />
<column name="var_type" />
</columns>
<conditions>
<condition operation="in" column="var_type" var="var_type" />
</conditions>
</query>

View file

@ -10,6 +10,7 @@
<column name="var_is_required" var="var_is_required" default="N" notnull="notnull" />
<column name="var_is_strict" var="var_is_strict" default="N" notnull="notnull" />
<column name="var_search" var="var_search" default="N" notnull="notnull" />
<column name="var_sort" var="var_sort" default="N" notnull="notnull" />
<column name="var_default" var="var_default" />
<column name="var_options" var="var_options" />
<column name="var_desc" var="var_desc" />

View file

@ -7,6 +7,7 @@
<column name="document_srl" var="document_srl" filter="number" notnull="notnull" />
<column name="var_idx" var="var_idx" filter="number" notnull="notnull" />
<column name="value" var="value" notnull="notnull" />
<column name="sort_value" var="sort_value" />
<column name="lang_code" var="lang_code" />
<column name="eid" var="eid" notnull="notnull" />
</columns>

View file

@ -8,6 +8,7 @@
<column name="var_is_required" var="var_is_required" default="N" notnull="notnull" />
<column name="var_is_strict" var="var_is_strict" default="N" notnull="notnull" />
<column name="var_search" var="var_search" default="N" notnull="notnull" />
<column name="var_sort" var="var_sort" default="N" notnull="notnull" />
<column name="var_default" var="var_default" default="" />
<column name="var_options" var="var_options" default="" />
<column name="var_desc" var="var_desc" />

View file

@ -4,6 +4,7 @@
</tables>
<columns>
<column name="value" var="value" />
<column name="sort_value" var="sort_value" />
<column name="lang_code" var="lang_code" />
<column name="eid" var="eid" />
</columns>

View file

@ -0,0 +1,12 @@
<query id="updateDocumentExtraVarSortValue" action="update">
<tables>
<table name="document_extra_vars" />
</tables>
<columns>
<column name="sort_value" default="CAST(value AS SIGNED)" />
</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" />
</conditions>
</query>

View file

@ -6,6 +6,7 @@
<column name="var_is_required" type="char" size="1" default="N" notnull="notnull" />
<column name="var_is_strict" type="char" size="1" default="N" notnull="notnull" />
<column name="var_search" type="char" size="1" default="N" notnull="notnull" />
<column name="var_sort" type="char" size="1" default="N" notnull="notnull" />
<column name="var_default" type="text" />
<column name="var_options" type="text" />
<column name="var_desc" type="text" />

View file

@ -1,8 +1,11 @@
<table name="document_extra_vars">
<column name="module_srl" type="number" size="11" notnull="notnull" unique="unique_extra_vars" />
<column name="document_srl" type="number" size="11" notnull="notnull" unique="unique_extra_vars" />
<column name="var_idx" type="number" size="11" notnull="notnull" unique="unique_extra_vars" />
<column name="lang_code" type="varchar" size="10" notnull="notnull" unique="unique_extra_vars" />
<column name="value" type="bigtext" />
<column name="eid" type="varchar" size="40" />
<column name="module_srl" type="number" size="11" notnull="notnull" unique="unique_extra_vars" />
<column name="document_srl" type="number" size="11" notnull="notnull" unique="unique_extra_vars" />
<column name="var_idx" type="number" size="11" notnull="notnull" unique="unique_extra_vars" />
<column name="lang_code" type="varchar" size="10" notnull="notnull" unique="unique_extra_vars" />
<column name="value" type="bigtext" />
<column name="sort_value" type="bigint" />
<column name="eid" type="varchar" size="40" />
<index name="idx_prefix_value" columns="module_srl,value(10)" />
<index name="idx_sort_value" columns="module_srl,sort_value" />
</table>

View file

@ -86,6 +86,13 @@
<label class="x_inline" for="search_n"><input type="radio" name="search" id="search_n" value="N" checked="checked"|cond="$selected_var->search!='Y'" /> {$lang->not}</label>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_sort}</label>
<div class="x_controls">
<label class="x_inline" for="sort_y"><input type="radio" name="sort" id="sort_y" value="Y" checked="checked"|cond="$selected_var->sort=='Y'" /> {$lang->yes}</label>
<label class="x_inline" for="sort_n"><input type="radio" name="sort" id="sort_n" value="N" checked="checked"|cond="$selected_var->sort!='Y'" /> {$lang->not}</label>
</div>
</div>
<div class="x_clearfix btnArea">
<div class="x_pull-left">
@ -120,6 +127,7 @@
<th>{$lang->default_value}</th>
<th>{$lang->is_required}</th>
<th>{$lang->cmd_search}</th>
<th>{$lang->cmd_sort}</th>
<th>&nbsp;</th>
</tr>
</thead>
@ -138,6 +146,7 @@
<td>{$val->default}&nbsp;</td>
<td class="nowr"><!--@if($val->is_required=='Y')--><strong>Y</strong><!--@else-->N<!--@end--></td>
<td class="nowr"><!--@if($val->search=='Y')--><strong>Y</strong><!--@else-->N<!--@end--></td>
<td class="nowr"><!--@if($val->sort=='Y')--><strong>Y</strong><!--@else-->N<!--@end--></td>
<td class="nowr" style="text-align:right">
<block cond="$val->idx > 1">
<button type="button" class="x_icon-arrow-up" onclick="moveVar('up','{$module_srl}','{$val->idx}')">{$lang->cmd_move_up}</button>