Merge pull request #105 from SoneYours/develop

조회수 설정 기능을 추가함 #103
This commit is contained in:
BJRambo 2016-01-19 15:46:28 +09:00
commit 64c2253502
8 changed files with 88 additions and 44 deletions

View file

@ -485,7 +485,8 @@ class documentAdminController extends document
function procDocumentAdminInsertConfig()
{
// Get the basic information
$config = Context::gets('thumbnail_type');
$config = new stdClass();
$config->view_count_option = Context::get('view_count_option');
// Insert by creating the module Controller object
$oModuleController = getController('module');
$output = $oModuleController->insertModuleConfig('document',$config);

View file

@ -896,7 +896,11 @@ class documentController extends document
{
// Pass if Crawler access
if(isCrawler()) return false;
$oDocumentModel = getModel('document');
$config = $oDocumentModel->getDocumentConfig();
if($config->view_count_option == 'none') return false;
$document_srl = $oDocument->document_srl;
$member_srl = $oDocument->get('member_srl');
$logged_info = Context::get('logged_info');
@ -906,28 +910,40 @@ class documentController extends document
if(!$trigger_output->toBool()) return $trigger_output;
// Pass if read count is increaded on the session information
if($_SESSION['readed_document'][$document_srl]) return false;
// Pass if the author's IP address is as same as visitor's.
if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'] && Context::getSessionStatus())
if($_SESSION['readed_document'][$document_srl] && $config->view_count_option == 'once')
{
$_SESSION['readed_document'][$document_srl] = true;
return false;
}
// Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user.
if($member_srl && $logged_info->member_srl == $member_srl)
else if($config->view_count_option == 'some')
{
$_SESSION['readed_document'][$document_srl] = true;
return false;
if($_SESSION['readed_document'][$document_srl])
{
return false;
}
}
if($config->view_count_option == 'once')
{
// Pass if the author's IP address is as same as visitor's.
if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'] && Context::getSessionStatus())
{
$_SESSION['readed_document'][$document_srl] = true;
return false;
}
// Pass ater registering sesscion if the author is a member and has same information as the currently logged-in user.
if($member_srl && $logged_info->member_srl == $member_srl)
{
$_SESSION['readed_document'][$document_srl] = true;
return false;
}
}
$oDB = DB::getInstance();
$oDB->begin();
// Update read counts
$args = new stdClass;
$args->document_srl = $document_srl;
$output = executeQuery('document.updateReadedCount', $args);
executeQuery('document.updateReadedCount', $args);
// Call a trigger when the read count is updated (after)
$trigger_output = ModuleHandler::triggerCall('document.updateReadedCount', 'after', $oDocument);

View file

@ -916,7 +916,7 @@ class documentModel extends document
$config = $oModuleModel->getModuleConfig('document');
if(!$config) $config = new stdClass();
if(!$config->thumbnail_type) $config->thumbnail_type = 'crop';
if(!$config->view_count_option) $config->view_count_option = 'once';
$GLOBALS['__document_config__'] = $config;
}
return $GLOBALS['__document_config__'];

View file

@ -23,6 +23,21 @@
<value xml:lang="tr"><![CDATA[Küçük Resim Türü]]></value>
<value xml:lang="vi"><![CDATA[Định dạng hình nhỏ]]></value>
</item>
<item name="view_count_option">
<value xml:lang="ko"><![CDATA[조회수 설정]]></value>
</item>
<item name="view_count_option_all">
<value xml:lang="ko"><![CDATA[모두 계산]]></value>
</item>
<item name="view_count_option_some">
<value xml:lang="ko"><![CDATA[일부 계산]]></value>
</item>
<item name="view_count_option_once">
<value xml:lang="ko"><![CDATA[중복 금지]]></value>
</item>
<item name="view_count_option_none">
<value xml:lang="ko"><![CDATA[계산 안함]]></value>
</item>
<item name="thumbnail_crop">
<value xml:lang="ko"><![CDATA[잘라내기 (정해진 크기에 꽉 찬 모습의 썸네일을 만듭니다.)]]></value>
<value xml:lang="en"><![CDATA[Crop (to a specific size)]]></value>
@ -183,6 +198,9 @@
<value xml:lang="tr"><![CDATA[Lütfen kategori ismi giriniz]]></value>
<value xml:lang="vi"><![CDATA[Hãy nhập tên thể loại]]></value>
</item>
<item name="about_view_count_option">
<value xml:lang="ko"><![CDATA[조회수설정에 따라 중복 조회수 카운트를 할 수 있도록 도와줍니다. 각 옵션에 따라 조회수 기록하는 방식이 달라집니다.]]></value>
</item>
<item name="about_expand">
<value xml:lang="ko"><![CDATA[선택하면 늘 펼쳐진 상태로 있게 합니다.]]></value>
<value xml:lang="en"><![CDATA[Select this option, and they will stay expanded.]]></value>

View file

@ -3,9 +3,7 @@ xe.lang.msg_empty_search_target = '{$lang->msg_empty_search_target}';
xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}';
</script>
<load target="js/document_admin.js" />
<div class="x_page-header">
<h1>{$lang->document} <a class="x_icon-question-sign" href="./common/manual/admin/#UMAN_content_document" target="_blank">{$lang->help}</a></h1>
</div>
<include target="header.html" />
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/document/tpl/declared_list/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>

View file

@ -1,21 +1,27 @@
<!--#include("header.html")-->
<include target="header.html" />
<form action="./" method="post">
<form action="./" method="post" class="x_form-horizontal" method="post">
<input type="hidden" name="module" value="document" />
<input type="hidden" name="act" value="procDocumentAdminInsertConfig" />
<table class="x_table x_table-striped x_table-hover">
<tr>
<th scope="col">{$lang->thumbnail_type}</th>
</tr>
<tr>
<td>
<input type="radio" name="thumbnail_type" value="crop" <!--@if($config->thumbnail_type != 'ratio')-->checked="checked"<!--@end-->/> {$lang->thumbnail_crop} <br />
<input type="radio" name="thumbnail_type" value="ratio" <!--@if($config->thumbnail_type == 'ratio')-->checked="checked"<!--@end-->/> {$lang->thumbnail_ratio}
</td>
</tr>
</table>
<div class="btnArea">
<input class="btn" type="submit" value="{$lang->cmd_registration}" />
<input class="btn" type="button" value="{$lang->cmd_delete_all_thumbnail}" onclick="doDeleteAllThumbnail()"/>
<input type="hidden" name="xe_validator_id" value="modules/document/tpl/document_config/1" />
<div class="x_control-group">
<div class="x_control-group">
<label class="x_control-label">{$lang->view_count_option}</label>
<div class="x_controls">
<select name="view_count_option">
<option value="all" selected="selected"|cond="$config->view_count_option=='all'">{$lang->view_count_option_all}</option>
<option value="some" selected="selected"|cond="$config->view_count_option=='some'">{$lang->view_count_option_some}</option>
<option value="once" selected="selected"|cond="$config->view_count_option=='once'">{$lang->view_count_option_once}</option>
<option value="none" selected="selected"|cond="$config->view_count_option=='none'">{$lang->view_count_option_none}</option>
</select>
<p>{$lang->about_view_count_option}</p>
</div>
</div>
</div>
</form>
<div class="btnArea x_clearfix">
<span class="x_pull-right" style="margin-left:10px;"><input class="btn" type="button" value="{$lang->cmd_delete_all_thumbnail}" onclick="doDeleteAllThumbnail()"/></span>
<span class="x_pull-right"><input class="x_btn x_btn-primary" type="submit" value="{$lang->cmd_save}" /></span>
</div>
</form>

View file

@ -3,9 +3,7 @@ xe.lang.msg_empty_search_target = '{$lang->msg_empty_search_target}';
xe.lang.msg_empty_search_keyword = '{$lang->msg_empty_search_keyword}';
</script>
<load target="js/document_admin.js" />
<div class="x_page-header">
<h1>{$lang->document} <a class="x_icon-question-sign" href="./common/manual/admin/#UMAN_content_document" target="_blank">{$lang->help}</a></h1>
</div>
<include target="header.html" />
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/document/tpl/document_list/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
<p>{$XE_VALIDATOR_MESSAGE}</p>
</div>

View file

@ -1,9 +1,16 @@
<load target="js/document_admin.js" />
<h1>{$lang->document} {$lang->cmd_management}</h1>
<p>
<a href="{getUrl('act','dispDocumentAdminList')}" class="active"|cond="$act=='dispDocumentAdminList'">{$lang->document_list}</a>
<i>|</i>
<a href="{getUrl('act','dispDocumentAdminConfig')}" class="active"|cond="$act=='dispDocumentAdminConfig'">{$lang->cmd_module_config}</a>
<i>|</i>
<a href="{getUrl('act','dispDocumentAdminDeclared')}" class="active"|cond="$act=='dispDocumentAdminDeclared'">{$lang->cmd_declared_list}</a>
</p>
<div class="x_page-header">
<h1>{$lang->document} <a class="x_icon-question-sign" href="./common/manual/admin/#UMAN_content_document" target="_blank">{$lang->help}</a></h1>
</div>
<ul class="x_nav x_nav-tabs">
<li class="x_active"|cond="$act == 'dispDocumentAdminList'">
<a href="{getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminList')}">{$lang->document_list}</a>
</li>
<li class="x_active"|cond="$act == 'dispDocumentAdminConfig'">
<a href="{getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminConfig')}">{$lang->cmd_module_config}</a>
</li>
<li class="x_active"|cond="$act == 'dispDocumentAdminDeclared'">
<a href="{getUrl('', 'module', 'admin', 'act', 'dispDocumentAdminDeclared')}">{$lang->cmd_declared_list}</a>
</li>
</ul>