Skip to content
This repository has been archived by the owner on Feb 13, 2018. It is now read-only.

Commit

Permalink
Merge pull request #34 from xpressengine/develop
Browse files Browse the repository at this point in the history
Ver 1.0.1
  • Loading branch information
qw5414 committed Jan 21, 2016
2 parents d8576c5 + 2c7dc3b commit 0855c70
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 19 deletions.
2 changes: 1 addition & 1 deletion conf/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<description xml:lang="en"></description>
<description xml:lang="ko"></description>
<description xml:lang="jp"></description>
<version>1.0</version>
<version>1.0.1</version>
<date>2014-12-11</date>
<author email_address="[email protected]" link="http://www.xpressengine.com/">
<name xml:lang="en">NAVER</name>
Expand Down
3 changes: 2 additions & 1 deletion conf/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
<action name="procProfilerAdminDeleteTrigger" type="controller" />
<action name="procProfilerAdminDeleteModuleConfig" type="controller" />
<action name="procProfilerAdminDeleteTable" type="controller" />
<action name="procProfilerAdminRepairTable" type="controller" />
<action name="procProfilerAdminDeleteTablePiece" type="controller" />
<action name="procProfilerAdminDeleteAddonConfig" type="controller" />
<action name="procProfilerAdminDeleteLogFile" type="controller" />
</actions>
<menus>
<menu name="profiler" type="all">
Expand Down
33 changes: 32 additions & 1 deletion lang/lang.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@
<value xml:lang="ko"><![CDATA[호출 방법]]></value>
<value xml:lang="jp"><![CDATA[呼び出されたメソッド]]></value>
</item>
<item name="delete">
<value xml:lang="en"><![CDATA[]]></value>
<value xml:lang="ko"><![CDATA[삭제]]></value>
<value xml:lang="jp"><![CDATA[]]></value>
</item>
</item>
<item name="cmd_profiler_dashboard">
<value xml:lang="en"><![CDATA[Dashboard]]></value>
Expand Down Expand Up @@ -132,7 +137,6 @@
<value xml:lang="ko"><![CDATA[실행 시간]]></value>
<value xml:lang="jp"><![CDATA[]]></value>
</item>

<item name="about_profiler">
<value xml:lang="en"><![CDATA[]]></value>
<value xml:lang="ko"><![CDATA[]]></value>
Expand Down Expand Up @@ -168,6 +172,28 @@
<value xml:lang="ko"><![CDATA[슬로우로그를 기록할지 선택합니다.]]></value>
<value xml:lang="jp"><![CDATA[]]></value>
</item>
<item name="about_profiler_slowlog_file_deleted">
<value xml:lang="en"><![CDATA[]]></value>
<value xml:lang="ko"><![CDATA[
<div class="file">
<h1>슬로우로그 파일 삭제</h1>
<div class="file-item">
<p>
슬로우 로그으로 만들어졌던 파일들을 삭제 하게됩니다.
<br>XE설치경로에서 files 폴더 안에 다음 파일을 삭제 합니다.
</p>
<ul>
<li>_slowlog_addon.php</li>
<li>_slowlog_trigger.php</li>
<li>_slowlog_widget.php</li>
<li>_slowlog_query.php</li>
</ul>
<p>그 외 files 풀더 안의 다른 파일들을 건드리지 않습니다.</p>
</div>
</div>
]]></value>
<value xml:lang="jp"><![CDATA[]]></value>
</item>
<item name="msg_profiler_arranged">
<value xml:lang="en"><![CDATA[]]></value>
<value xml:lang="ko"><![CDATA[정리했습니다.]]></value>
Expand Down Expand Up @@ -198,4 +224,9 @@
<value xml:lang="ko"><![CDATA[사용하지 않는 테이블을 삭제하면 복구할 수 없습니다. 정말로 삭제하시겠습니까?]]></value>
<value xml:lang="jp"><![CDATA[]]></value>
</item>
<item name="msg_profiler_slowlog_file_arranged">
<value xml:lang="en"><![CDATA[]]></value>
<value xml:lang="ko"><![CDATA[슬로우로그 파일을 정리 하였습니다.]]></value>
<value xml:lang="jp"><![CDATA[]]></value>
</item>
</lang>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "XE-Profiler",
"version": "1.0",
"version": "1.0.1",
"author": "NAVER",
"keywords": [
"XpressEngine",
Expand Down
72 changes: 62 additions & 10 deletions profiler.admin.controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function procProfilerAdminInsertConfig()
$oProfilerModel = getModel('profiler');

$vars = Context::getRequestVars();
$section = $vars->_config_section;

$config = $oProfilerModel->getConfig();
if(!$config->slowlog)
Expand All @@ -33,19 +32,13 @@ function procProfilerAdminInsertConfig()

$oModuleController->updateModuleConfig('profiler', $config);

$oInstallController = getController('install');
if(!$oInstallController->makeConfigFile())
{
return new Object(-1, 'msg_invalid_request');
}

$this->setMessage('success_updated');
$this->setRedirectUrl(Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispProfilerAdminConfig'));
}

function procProfilerAdminTruncateSlowlog()
{
$output = executeQuery('profiler.truncateSlowlog');
executeQuery('profiler.truncateSlowlog');

$this->setMessage('msg_profiler_arranged');
$this->setRedirectUrl(Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispProfilerAdminSlowlog'));
Expand All @@ -61,10 +54,9 @@ function procProfilerAdminDeleteTrigger()
$invalid_trigger_list = $oProfilerAdminModel->getTriggersToBeDeleted($advanced);

// 트리거 삭제
$oModuleController = getController('module');
foreach($invalid_trigger_list as $trigger)
{
$output = $oModuleController->deleteTrigger($trigger->trigger_name, $trigger->module, $trigger->type, $trigger->called_method, $trigger->called_position);
$output = $this->deleteTrigger($trigger->trigger_name, $trigger->module, $trigger->type, $trigger->called_method, $trigger->called_position);
if(!$output->toBool())
{
return $output;
Expand Down Expand Up @@ -144,6 +136,40 @@ function procProfilerAdminDeleteTable()
$this->setRedirectUrl($success_return_url ? $success_return_url : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispProfilerAdminTable', 'page', Context::get('page')));
}

function procProfilerAdminDeleteTablePiece()
{
$table_name = Context::get('table_name');
$oDB = DB::getInstance();
$oDB->dropTable(substr($table_name, strlen($oDB->prefix)));

$this->setMessage('msg_profiler_arranged');
$success_return_url = Context::get('success_return_url');
$this->setRedirectUrl($success_return_url ? $success_return_url : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispProfilerAdminTable', 'page', Context::get('page')));
}

function procProfilerAdminDeleteLogFile()
{
$slowlog_files = array(
_XE_PATH_.'files/_slowlog_addon.php',
_XE_PATH_.'files/_slowlog_trigger.php',
_XE_PATH_.'files/_slowlog_widget.php',
_XE_PATH_.'files/_slowlog_query.php'
);

foreach($slowlog_files as $file)
{
$slowlog_file = FileHandler::exists($file);
if($slowlog_file === false)
{
continue;
}
FileHandler::removeFile($file);
}

$this->setMessage('msg_profiler_slowlog_file_arranged');
$this->setRedirectUrl(Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispProfilerAdminConfig'));
}

/**
* @brief 테이블 복구
* @param string $table_name
Expand Down Expand Up @@ -183,6 +209,32 @@ function repairTable($table_name)

return new Object();
}

/**
* @brief 트리거 삭제명령
* @param string $table_name
* @return $output
*/
function deleteTrigger($trigger_name, $module, $type, $called_method, $called_position)
{
$args = new stdClass();
$args->trigger_name = $trigger_name;
$args->module = $module;
$args->type = $type;
$args->called_method = $called_method;
$args->called_position = $called_position;
$output = executeQuery('module.deleteTrigger', $args);
//캐시파일도 함께 삭제.
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);
if($oCacheHandler->isSupport())
{
$oCacheHandler->invalidateGroupKey('triggers');
}
// 캐시파일 함께 삭제
FileHandler::removeFilesInDir('./files/cache/triggers');

return $output;
}
}

/* End of file profiler.admin.controller.php */
Expand Down
38 changes: 35 additions & 3 deletions profiler.admin.model.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,38 @@ function getStaticsSlowlogCount($type, $count, $args = NULL)
return $output;
}

/**
* @brief DB의 기록된 트리거 목록을 가져옴
* @return array
*/
function getTriggers($trigger_name, $called_position)
{
$triggers = false;
$oCacheHandler = CacheHandler::getInstance('object', NULL, TRUE);

if($oCacheHandler->isSupport())
{
$object_key = $trigger_name.'_'.$called_position;
$cache_key = $oCacheHandler->getGroupKey('triggers', $object_key);
$triggers = $oCacheHandler->get($cache_key);
}

if($triggers === false)
{
$args = new stdClass();
$args->trigger_name = $trigger_name;
$args->called_position = $called_position;
$output = executeQueryArray('module.getTriggers', $args);
$triggers = $output->data;
if($output->toBool() && $oCacheHandler->isSupport())
{
$oCacheHandler->put($cache_key, $triggers);
}
}

return $triggers;
}

/**
* @brief 설치된 모듈 이름 목록 반환
* @return array
Expand Down Expand Up @@ -183,10 +215,8 @@ function getTableList()
*/
function getTriggersToBeDeleted($advanced = FALSE)
{
$oModuleModel = getModel('module');

// DB 상의 트리거 목록
$trigger_list = $oModuleModel->getTriggers();
$trigger_list = $this->getTriggers();

// 설치되어 있는 모듈 목록
$module_list = $this->getModuleList();
Expand Down Expand Up @@ -222,6 +252,7 @@ function getTriggersToBeDeleted($advanced = FALSE)
*/
function getModuleConfigToBeDeleted($advanced = FALSE)
{
$oModuleModel = getModel('module');
// DB 상의 모듈 설정 목록
$output = executeQueryArray('profiler.getModuleConfig');
$module_config = $output->data;
Expand Down Expand Up @@ -271,6 +302,7 @@ function getAddonConfigToBeDeleted($advanced = FALSE)

$module_list = $this->getModuleList();

$invalid_addon_config = array();
foreach($addon_config as $config)
{
$addons_j_list[] = $config->addon;
Expand Down
1 change: 0 additions & 1 deletion profiler.admin.view.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ function dispProfilerAdminWidgetList()
Context::set('widget_slowlog', $paging->data);
Context::set('page_navigation', $paging->page_navigation);


Context::set('w_slowlog', $w_slowlog2);
}

Expand Down
14 changes: 13 additions & 1 deletion tpl/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ <h1>{$lang->cmd_profiler_slowlog}</h1>
<input type="hidden" name="module" value="profiler">
<input type="hidden" name="act" value="procProfilerAdminInsertConfig">
<input type="hidden" name="xe_validator_id" value="modules/profiler/tpl/config/1" />
<input type="hidden" name="_config_section" value="slowlog">

<div class="x_control-group">
<div class="x_control-label">{$lang->cmd_profiler_enable_slowlog}</div>
Expand Down Expand Up @@ -59,4 +58,17 @@ <h1>{$lang->cmd_profiler_slowlog}</h1>
</div>
</div>
</form>

</section>
<section class="section">
<h1></h1>
<form class="x_form-horizontal" action="{getUrl('')}" method="post">
<input type="hidden" name="module" value="profiler" />
<input type="hidden" name="act" value="procProfilerAdminDeleteLogFile" />
<input type="hidden" name="xe_validator_id" value="modules/profiler/tpl/config/1" />
{$lang->about_profiler_slowlog_file_deleted}

<button class="x_btn x_btn-primary" type="submit">{$lang->profiler_unit->delete}</button>

</form>
</section>
23 changes: 23 additions & 0 deletions tpl/css/profiler.admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,27 @@
text-decoration : none;
}

.file .file-item {
overflow-x: hidden;
overflow-y: auto;
margin: 0 !important;
padding: 20px;
color: rgb(34, 34, 34);
font-size: 15px;
font-family: 'Roboto Condensed', Tauri, 'Hiragino Sans GB', 'Microsoft YaHei', STHeiti, SimSun, 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', 'Segoe UI', AppleSDGothicNeo-Medium, 'Malgun Gothic', Verdana, Tahoma, sans-serif;
line-height: 1.6;
-webkit-font-smoothing: antialiased;
background: rgb(255, 255, 255);
}

.file .file-item p {
margin: 1em 0;
word-wrap: break-word;
}
.file .file-item p br {
clear: both;
}
.file .file-item li {
display: list-item; line-height: 1.4em;
}
/* End of file */
7 changes: 7 additions & 0 deletions tpl/table.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@
{@$enable_delete = TRUE}
{$lang->notuse}
</label>
<form cond="$table_info->to_be_deleted" class="x_inline" action="{getUrl('')}" mothod="post">
<input type="hidden" name="module" value="profiler" />
<input type="hidden" name="act" value="procProfilerAdminDeleteTablePiece" />
<input type="hidden" name="table_name" value="{$table_info->name}" />
<input type="hidden" name="xe_validator_id" value="modules/profiler/tpl/table/1" />
<button class="x_btn x_btn-mini" type="submit">{$lang->profiler_unit->delete}</button>
</form>
{$table_info->name}
</td>
<td cond="in_array('type', $column_list)">{$table_info->type}</td>
Expand Down

0 comments on commit 0855c70

Please sign in to comment.