Version 0.3.2

This commit is contained in:
dmzx
2016-01-01 20:35:04 +01:00
parent 42d123402f
commit 08b6b57225
53 changed files with 3848 additions and 4243 deletions

View File

@@ -61,25 +61,25 @@ class admin_controller
* @param \phpbb\db\driver\driver_interface $db
* @param \phpbb\cache\service $cache
* @param \phpbb\request\request $request
* @param \phpbb\extension\manager $phpbb_extension_manager
* @param \phpbb\extension\manager $phpbb_extension_manager
* @param string $phpbb_root_path
* @param string $phpEx
* @param string $mchat_config_table
*/
public function __construct(\dmzx\mchat\core\functions_mchat $functions_mchat, \phpbb\config\config $config, \phpbb\template\template $template, \phpbb\log\log_interface $log, \phpbb\user $user, \phpbb\db\driver\driver_interface $db, \phpbb\cache\service $cache, \phpbb\request\request $request, \phpbb\extension\manager $phpbb_extension_manager, $phpbb_root_path, $phpEx, $mchat_config_table)
{
$this->functions_mchat = $functions_mchat;
$this->config = $config;
$this->template = $template;
$this->log = $log;
$this->user = $user;
$this->db = $db;
$this->cache = $cache;
$this->request = $request;
$this->phpbb_extension_manager = $phpbb_extension_manager;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $phpEx;
$this->mchat_config_table = $mchat_config_table;
$this->functions_mchat = $functions_mchat;
$this->config = $config;
$this->template = $template;
$this->log = $log;
$this->user = $user;
$this->db = $db;
$this->cache = $cache;
$this->request = $request;
$this->phpbb_extension_manager = $phpbb_extension_manager;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $phpEx;
$this->mchat_config_table = $mchat_config_table;
}
/**
@@ -94,7 +94,7 @@ class admin_controller
$mchat_row = array(
'location' => $this->request->variable('mchat_location', 0),
'refresh' => $this->request->variable('mchat_refresh', 0),
'refresh' => $this->request->variable('mchat_refresh', 0),
'message_limit' => $this->request->variable('mchat_message_limit', 0),
'message_num' => $this->request->variable('mchat_message_num', 0),
'archive_limit' => $this->request->variable('mchat_archive_limit', 0),
@@ -149,7 +149,7 @@ class admin_controller
}
// Replace "error" strings with their real, localised form
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$this->user->lang['\\1'])) ? \$this->user->lang['\\1'] : '\\1'", $error);
$error = preg_replace('#^([A-Z_]+)$#e', "(!empty(\$this->user->lang('\\1'))) ? \$this->user->lang('\\1') : '\\1'", $error);
if (!sizeof($error))
{
@@ -173,7 +173,7 @@ class admin_controller
// rebuild the cache
$this->functions_mchat->mchat_cache();
trigger_error($this->user->lang['MCHAT_CONFIG_SAVED'] . adm_back_link($this->u_action));
trigger_error($this->user->lang('MCHAT_CONFIG_SAVED') . adm_back_link($this->u_action));
}
}
@@ -203,7 +203,7 @@ class admin_controller
foreach ($this->user->lang['dateformats'] as $format => $null)
{
$dateformat_options .= '<option value="' . $format . '"' . (($format == $mchat_config['date']) ? ' selected="selected"' : '') . '>';
$dateformat_options .= $this->user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $this->user->lang['VARIANT_DATE_SEPARATOR'] . $this->user->format_date(time(), $format, true) : '');
$dateformat_options .= $this->user->format_date(time(), $format, false) . ((strpos($format, '|') !== false) ? $this->user->lang('VARIANT_DATE_SEPARATOR') . $this->user->format_date(time(), $format, true) : '');
$dateformat_options .= '</option>';
}
@@ -214,7 +214,7 @@ class admin_controller
$dateformat_options .= ' selected="selected"';
$s_custom = true;
}
$dateformat_options .= '>' . $this->user->lang['MCHAT_CUSTOM_DATEFORMAT'] . '</option>';
$dateformat_options .= '>' . $this->user->lang('MCHAT_CUSTOM_DATEFORMAT') . '</option>';
$this->template->assign_vars(array(
'MCHAT_ERROR' => isset($error) ? ((sizeof($error)) ? implode('<br />', $error) : '') : '',
@@ -252,8 +252,8 @@ class admin_controller
'MCHAT_NEW_POSTS_EDIT' => ($mchat_new_posts_edit) ? true : false,
'MCHAT_NEW_POSTS_QUOTE' => ($mchat_new_posts_quote) ? true : false,
'MCHAT_PAUSE_ON_INPUT' => !empty($mchat_row['pause_on_input']) ? $mchat_row['pause_on_input'] : $mchat_config['pause_on_input'],
'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => sprintf($this->user->lang['MCHAT_BBCODES_DISALLOWED_EXPLAIN'], '<a href="' . append_sid("{$this->phpbb_root_path}index.$this->php_ext", 'i=bbcodes', true, $this->user->session_id) . '">', '</a>'),
'L_MCHAT_TIMEOUT_EXPLAIN' => sprintf($this->user->lang['MCHAT_USER_TIMEOUT_EXPLAIN'],'<a href="' . append_sid("{$this->phpbb_root_path}index.$this->php_ext", 'i=board&amp;mode=load', true, $this->user->session_id) . '">', '</a>', $this->config['session_length']),
'L_MCHAT_BBCODES_DISALLOWED_EXPLAIN' => sprintf($this->user->lang('MCHAT_BBCODES_DISALLOWED_EXPLAIN'), '<a href="' . append_sid("{$this->phpbb_root_path}adm/index.$this->php_ext", 'i=bbcodes', true, $this->user->session_id) . '">', '</a>'),
'L_MCHAT_TIMEOUT_EXPLAIN' => sprintf($this->user->lang('MCHAT_USER_TIMEOUT_EXPLAIN'),'<a href="' . append_sid("{$this->phpbb_root_path}adm/index.$this->php_ext", 'i=board&amp;mode=load', true, $this->user->session_id) . '">', '</a>', $this->config['session_length']),
'S_MCHAT_DATEFORMAT_OPTIONS' => $dateformat_options,
'S_CUSTOM_DATEFORMAT' => $s_custom,

View File

@@ -9,29 +9,26 @@
namespace dmzx\mchat\controller;
use \Symfony\Component\HttpFoundation\JsonResponse;
class mchat
{
/** @var \dmzx\mchat\core\render_helper*/
protected $render_helper;
/** @var \phpbb\controller\helper*/
protected $helper;
/** @var \phpbb\request\request*/
protected $request;
/**
* Constructor
*
* @param \dmzx\mchat\core\render_helper $render_helper
* @param \phpbb\controller\helper $helper
* @param \phpbb\request\request $request
* @param \dmzx\mchat\core\render_helper $render_helper
* @param \phpbb\request\request $request
*/
public function __construct(\dmzx\mchat\core\render_helper $render_helper, \phpbb\controller\helper $helper, \phpbb\request\request $request)
public function __construct(\dmzx\mchat\core\render_helper $render_helper, \phpbb\request\request $request)
{
$this->render_helper = $render_helper;
$this->helper = $helper;
$this->request = $request;
$this->render_helper = $render_helper;
$this->request = $request;
}
/**
@@ -41,22 +38,7 @@ class mchat
*/
public function handle()
{
$ret = $this->render_helper->render_data_for_page(false);
// If this was an ajax request, we just create an json_response and return that. It's not ours to handle here.
if ($this->request->is_ajax() && is_array($ret) && isset($ret['json']) && $ret['json'] === true)
{
return new \Symfony\Component\HttpFoundation\JsonResponse(
$ret
);
}
// If error occured, render it
if (isset($ret['error']) && $ret['error'] == true)
{
return $this->helper->error($ret['error_text'], $ret['error_type']);
}
return $this->helper->render($ret['filename'], $ret['lang_title']);
$content = $this->render_helper->render_data_for_page(false);
return $this->request->is_ajax() ? new JsonResponse($content) : $content;
}
}