mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 01:01:41 +09:00
Move friendly error message feature to Message module
This commit is contained in:
parent
26710e2675
commit
e31704ffc2
9 changed files with 41 additions and 20 deletions
|
|
@ -1,3 +1,5 @@
|
|||
<?php
|
||||
$lang->message = 'Display Errors';
|
||||
$lang->about_skin = 'You may select skins for error messages.';
|
||||
$lang->msg_administrator_login = 'Administrator Login';
|
||||
$lang->error_help['baseobject'] = 'Object → BaseObject conversion is required in a third-party program. Please fix it by consulting the file name and line number shown above.';
|
||||
|
|
|
|||
|
|
@ -2,3 +2,4 @@
|
|||
$lang->message = '오류 표시';
|
||||
$lang->about_skin = '오류 메시지용 스킨을 지정할 수 있습니다.';
|
||||
$lang->msg_administrator_login = '관리자 로그인';
|
||||
$lang->error_help['baseobject'] = 'Object → BaseObject 변환이 필요한 서드파티 자료가 있습니다. 위의 에러 메시지에 포함된 파일명과 줄 번호를 참고하여 수정하세요.';
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
<div class="message" cond="$system_message_detail">
|
||||
{$system_message_detail}
|
||||
</div>
|
||||
<div class="message help" cond="$system_message_help">
|
||||
{$system_message_help}
|
||||
</div>
|
||||
<div class="message location" cond="$system_message_location">
|
||||
{$system_message_location}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -7,17 +7,10 @@
|
|||
*/
|
||||
class MessageView extends Message
|
||||
{
|
||||
/**
|
||||
* @brief Initialization
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Display messages
|
||||
*/
|
||||
function dispMessage($detail = null, $location = null)
|
||||
public function dispMessage($detail = null, $location = null)
|
||||
{
|
||||
// Get skin configuration
|
||||
$config = ModuleModel::getModuleConfig('message') ?: new stdClass;
|
||||
|
|
@ -79,6 +72,7 @@ class MessageView extends Message
|
|||
Context::set('ssl_mode', \RX_SSL);
|
||||
Context::set('system_message', nl2br($this->getMessage()));
|
||||
Context::set('system_message_detail', nl2br($detail));
|
||||
Context::set('system_message_help', self::getErrorHelp($detail));
|
||||
Context::set('system_message_location', escape($location));
|
||||
|
||||
if ($this->getError())
|
||||
|
|
@ -101,6 +95,29 @@ class MessageView extends Message
|
|||
$this->setHttpStatusCode(403);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get friendly help message for common types of errors.
|
||||
*
|
||||
* @param string $error_message
|
||||
* @return string
|
||||
*/
|
||||
public static function getErrorHelp(string $error_message): string
|
||||
{
|
||||
$regexp_list = [
|
||||
'/Class [\'"]Object[\'"] not found/' => 'baseobject',
|
||||
];
|
||||
|
||||
foreach ($regexp_list as $regexp => $key)
|
||||
{
|
||||
if (preg_match($regexp, $error_message))
|
||||
{
|
||||
return lang('message.error_help.' . $key);
|
||||
}
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
/* End of file message.view.php */
|
||||
/* Location: ./modules/message/message.view.php */
|
||||
|
|
|
|||
|
|
@ -11,6 +11,9 @@
|
|||
<div class="message" cond="$system_message_detail">
|
||||
{$system_message_detail}
|
||||
</div>
|
||||
<div class="message help" cond="$system_message_help">
|
||||
{$system_message_help}
|
||||
</div>
|
||||
<div class="message location" cond="$system_message_location">
|
||||
{$system_message_location}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -8,6 +8,9 @@
|
|||
<div class="message" cond="$system_message_detail">
|
||||
{$system_message_detail}
|
||||
</div>
|
||||
<div class="message help" cond="$system_message_help">
|
||||
{$system_message_help}
|
||||
</div>
|
||||
<div class="message location" cond="$system_message_location">
|
||||
{$system_message_location}
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue