Refactor BoardView::_makeListColumnList (fixes #1695)

This commit is contained in:
Kijin Sung 2021-04-26 15:24:14 +09:00
parent c68f676342
commit 3a4fb82666

View file

@ -640,32 +640,48 @@ class boardView extends board
function _makeListColumnList() function _makeListColumnList()
{ {
$configColumList = array_keys($this->listConfig); // List of all available columns
$tableColumnList = array('document_srl', 'module_srl', 'category_srl', 'lang_code', 'is_notice', $allColumnList = array(
'title', 'title_bold', 'title_color', 'content', 'readed_count', 'voted_count', 'document_srl', 'module_srl', 'category_srl', 'lang_code', 'is_notice',
'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count', 'password', 'user_id', 'title', 'title_bold', 'title_color', 'content',
'user_name', 'nick_name', 'member_srl', 'email_address', 'homepage', 'tags', 'extra_vars', 'readed_count', 'voted_count', 'blamed_count', 'comment_count', 'trackback_count', 'uploaded_count',
'regdate', 'last_update', 'last_updater', 'ipaddress', 'list_order', 'update_order', 'password', 'user_id', 'user_name', 'nick_name', 'member_srl', 'email_address', 'homepage', 'tags', 'extra_vars',
'allow_trackback', 'notify_message', 'status', 'comment_status'); 'regdate', 'last_update', 'last_updater', 'ipaddress', 'list_order', 'update_order',
$this->columnList = array_intersect($configColumList, $tableColumnList); 'allow_trackback', 'notify_message', 'status', 'comment_status',
);
if(in_array('summary', $configColumList)) array_push($this->columnList, 'content');
// List of columns that should always be selected
// default column list add $defaultColumnList = array(
$defaultColumn = array('document_srl', 'module_srl', 'category_srl', 'lang_code', 'is_notice', 'member_srl', 'last_update', 'comment_count', 'trackback_count', 'uploaded_count', 'status', 'regdate', 'title_bold', 'title_color'); 'document_srl', 'module_srl', 'category_srl', 'lang_code', 'is_notice',
'title', 'title_bold', 'title_color', 'member_srl', 'nick_name', 'extra_vars',
//TODO guestbook, blog style supports legacy codes. 'comment_count', 'trackback_count', 'uploaded_count', 'status', 'regdate', 'last_update',
);
// List of columns selected by the user
$selectedColumnList = array_keys($this->listConfig);
// Return all columns for some legacy skins
if($this->module_info->skin == 'xe_guestbook' || $this->module_info->default_style == 'blog') if($this->module_info->skin == 'xe_guestbook' || $this->module_info->default_style == 'blog')
{ {
$defaultColumn = $tableColumnList; $this->columnList = $allColumnList;
} }
else
if (in_array('last_post', $configColumList)){ {
array_push($this->columnList, 'last_updater'); // Convert some special names to corresponding column names
if(in_array('summary', $selectedColumnList))
{
$selectedColumnList[] = 'content';
}
if(in_array('last_post', $selectedColumnList))
{
$selectedColumnList[] = 'last_updater';
}
// Remove duplicates and/or invalid column names
$selectedColumnList = array_intersect($selectedColumnList, $allColumnList);
$this->columnList = array_unique(array_merge($defaultColumnList, $selectedColumnList));
} }
$this->columnList = array_unique(array_merge($this->columnList, $defaultColumn));
// add table name // add table name
foreach($this->columnList as $no => $value) foreach($this->columnList as $no => $value)
{ {