[ticket/436] Generate routes with modules_helper and remove use of app.php
Modules should generate routes with the modules helper instead of directly creating links to app.php. B3P-436
This commit is contained in:
@@ -80,9 +80,6 @@ class announcements extends module_base
|
||||
/** @var \board3\portal\portal\fetch_posts */
|
||||
protected $fetch_posts;
|
||||
|
||||
/** @var \phpbb\controller\helper */
|
||||
protected $controller_helper;
|
||||
|
||||
/**
|
||||
* Construct an announcements object
|
||||
*
|
||||
@@ -98,9 +95,8 @@ class announcements extends module_base
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param \phpbb\user $user phpBB user object
|
||||
* @param \board3\portal\portal\fetch_posts $fetch_posts Fetch posts object
|
||||
* @param \phpbb\controller\helper $controller_helper Controller helper
|
||||
*/
|
||||
public function __construct($auth, $cache, $config, $template, $db, $pagination, $modules_helper, $request, $phpEx, $phpbb_root_path, $user, $fetch_posts, $controller_helper)
|
||||
public function __construct($auth, $cache, $config, $template, $db, $pagination, $modules_helper, $request, $phpEx, $phpbb_root_path, $user, $fetch_posts)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->cache = $cache;
|
||||
@@ -114,7 +110,6 @@ class announcements extends module_base
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->user = $user;
|
||||
$this->fetch_posts = $fetch_posts;
|
||||
$this->controller_helper = $controller_helper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -239,7 +234,7 @@ class announcements extends module_base
|
||||
|
||||
if ($this->config['board3_number_of_announcements_' . $module_id] != 0 && $this->config['board3_announcements_archive_' . $module_id])
|
||||
{
|
||||
$pagination = generate_portal_pagination($this->controller_helper->route('board3_portal_controller'), $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start, 'announcements', $module_id);
|
||||
$pagination = generate_portal_pagination($this->modules_helper->route('board3_portal_controller'), $total_announcements, $this->config['board3_number_of_announcements_' . $module_id], $start, 'announcements', $module_id);
|
||||
|
||||
$announcements_row = array_merge($announcements_row, array(
|
||||
'AP_PAGINATION' => (isset($pagination)) ? $pagination : '',
|
||||
@@ -345,7 +340,7 @@ class announcements extends module_base
|
||||
'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
|
||||
'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id . '&view=unread#unread'),
|
||||
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&' . (($real_forum_id) ? 'f=' . $real_forum_id . '&' : '') . 't=' . $topic_id),
|
||||
'U_READ_FULL' => $this->controller_helper->route('board3_portal_controller') . '?' . $read_full_url,
|
||||
'U_READ_FULL' => $this->modules_helper->route('board3_portal_controller') . '?' . $read_full_url,
|
||||
'L_READ_FULL' => $read_full,
|
||||
'OPEN' => $open_bracket,
|
||||
'CLOSE' => $close_bracket,
|
||||
@@ -379,7 +374,7 @@ class announcements extends module_base
|
||||
*/
|
||||
if (!isset($fetch_news[$i]))
|
||||
{
|
||||
redirect($this->controller_helper->route('board3_portal_controller') . '#top');
|
||||
redirect($this->modules_helper->route('board3_portal_controller') . '#top');
|
||||
}
|
||||
|
||||
$forum_id = $fetch_news[$i]['forum_id'];
|
||||
@@ -391,7 +386,7 @@ class announcements extends module_base
|
||||
$read_full = $this->user->lang['BACK'];
|
||||
$real_forum_id = ($forum_id == 0) ? $fetch_news['global_id']: $forum_id;
|
||||
|
||||
$read_full_url = ($this->request->is_set('ap_' . $module_id)) ? $this->controller_helper->route('board3_portal_controller') . "?ap_{$module_id}=$start#a_{$module_id}_$i" : $this->controller_helper->route('board3_portal_controller') . "#a_{$module_id}_$i";
|
||||
$read_full_url = ($this->request->is_set('ap_' . $module_id)) ? $this->modules_helper->route('board3_portal_controller') . "?ap_{$module_id}=$start#a_{$module_id}_$i" : $this->modules_helper->route('board3_portal_controller') . "#a_{$module_id}_$i";
|
||||
$view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
|
||||
|
||||
$this->template->assign_block_vars('announcements.center_row', array(
|
||||
|
||||
@@ -89,13 +89,13 @@ class calendar extends module_base
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/** @var \phpbb\template */
|
||||
/** @var \phpbb\template\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb\db\driver */
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\request\request */
|
||||
/** @var \phpbb\request\request_interface */
|
||||
protected $request;
|
||||
|
||||
/** @var string PHP file extension */
|
||||
@@ -116,22 +116,27 @@ class calendar extends module_base
|
||||
/** @var \phpbb\log\log phpBB log */
|
||||
protected $log;
|
||||
|
||||
/** @var \board3\portal\includes\modules_helper */
|
||||
protected $modules_helper;
|
||||
|
||||
/**
|
||||
* Construct a calendar object
|
||||
*
|
||||
* @param \phpbb\config\config $config phpBB config
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param \phpbb\db\driver $db Database driver
|
||||
* @param \phpbb\request\request $request phpBB request
|
||||
* @param \board3\portal\includes\modules_helper $modules_helper Modules helper
|
||||
* @param \phpbb\template\template $template phpBB template
|
||||
* @param \phpbb\db\driver\driver_interface $db Database driver
|
||||
* @param \phpbb\request\request_interface $request phpBB request
|
||||
* @param string $phpEx php file extension
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param \phpbb\user $user phpBB user object
|
||||
* @param \phpbb\path_helper $path_helper phpBB path helper
|
||||
* @param \phpbb\log\log $log phpBB log object
|
||||
*/
|
||||
public function __construct($config, $template, $db, $request, $phpbb_root_path, $phpEx, $user, $path_helper, $log)
|
||||
public function __construct($config, $modules_helper, $template, $db, $request, $phpbb_root_path, $phpEx, $user, $path_helper, $log)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->modules_helper = $modules_helper;
|
||||
$this->template = $template;
|
||||
$this->db = $db;
|
||||
$this->request = $request;
|
||||
@@ -183,8 +188,8 @@ class calendar extends module_base
|
||||
// output our general calendar bits
|
||||
$down = $this->mini_cal_month - 1;
|
||||
$up = $this->mini_cal_month + 1;
|
||||
$prev_month = '<a href="' . append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "m$module_id=$down#minical$module_id") . '"><img src="' . $this->portal_root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/cal_icon_left_arrow.png' . '" title="' . $this->user->lang['VIEW_PREVIOUS_MONTH'] . '" height="16" width="16" alt="<<" /></a>';
|
||||
$next_month = '<a href="' . append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "m$module_id=$up#minical$module_id") . '"><img src="' . $this->portal_root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/cal_icon_right_arrow.png' . '" title="' . $this->user->lang['VIEW_NEXT_MONTH'] . '" height="16" width="16" alt=">>" /></a>';
|
||||
$prev_month = '<a href="' . $this->modules_helper->route('board3_portal_controller') . "?m$module_id=$down#minical$module_id" . '"><img src="' . $this->portal_root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/cal_icon_left_arrow.png' . '" title="' . $this->user->lang['VIEW_PREVIOUS_MONTH'] . '" height="16" width="16" alt="<<" /></a>';
|
||||
$next_month = '<a href="' . $this->modules_helper->route('board3_portal_controller') . "?m$module_id=$up#minical$module_id" . '"><img src="' . $this->portal_root_path . 'styles/' . $this->user->style['style_path'] . '/theme/images/portal/cal_icon_right_arrow.png' . '" title="' . $this->user->lang['VIEW_NEXT_MONTH'] . '" height="16" width="16" alt=">>" /></a>';
|
||||
|
||||
$this->template->assign_block_vars('minical', array(
|
||||
'S_SUNDAY_FIRST' => ($this->config['board3_sunday_first_' . $module_id]) ? true : false,
|
||||
|
||||
@@ -228,7 +228,7 @@ class news extends module_base
|
||||
// Create pagination if necessary
|
||||
if ($this->config['board3_news_archive_' . $module_id])
|
||||
{
|
||||
$pagination = generate_portal_pagination(append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"), $total_news, $this->config['board3_number_of_news_' . $module_id], $start, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $module_id);
|
||||
$pagination = generate_portal_pagination($this->modules_helper->route('board3_portal_controller'), $total_news, $this->config['board3_number_of_news_' . $module_id], $start, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $module_id);
|
||||
}
|
||||
|
||||
if ($this->config['board3_number_of_news_' . $module_id] <> 0 && $this->config['board3_news_archive_' . $module_id])
|
||||
@@ -338,7 +338,7 @@ class news extends module_base
|
||||
'U_VIEW_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_VIEW_UNREAD' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'),
|
||||
'U_POST_COMMENT' => append_sid("{$this->phpbb_root_path}posting.{$this->php_ext}", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
|
||||
'U_READ_FULL' => append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", $read_full_url),
|
||||
'U_READ_FULL' => $this->modules_helper->route('board3_portal_controller') . '?' . $read_full_url,
|
||||
'L_READ_FULL' => $read_full,
|
||||
'OPEN' => $open_bracket,
|
||||
'CLOSE' => $close_bracket,
|
||||
@@ -370,7 +370,7 @@ class news extends module_base
|
||||
$close_bracket = ' ]';
|
||||
$read_full = $this->user->lang['BACK'];
|
||||
|
||||
$read_full_url = ($this->request->is_set('np_' . $module_id)) ? append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "np_$module_id=$start#n_{$module_id}_$i") : append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal#n_{$module_id}_$i");
|
||||
$read_full_url = ($this->request->is_set('np_' . $module_id)) ? $this->modules_helper->route('board3_portal_controller') . "?np_$module_id=$start#n_{$module_id}_$i" : $this->modules_helper->route('board3_portal_controller') . "#n_{$module_id}_$i";
|
||||
$view_topic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
|
||||
|
||||
$this->template->assign_block_vars('news.news_row', array(
|
||||
|
||||
@@ -71,6 +71,9 @@ class poll extends module_base
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
/** @var \board3\portal\includes\modules_helper */
|
||||
protected $modules_helper;
|
||||
|
||||
/**
|
||||
* Construct a poll object
|
||||
*
|
||||
@@ -82,8 +85,9 @@ class poll extends module_base
|
||||
* @param string $phpEx php file extension
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param \phpbb\user $user phpBB user object
|
||||
* @param \board3\portal\includes\modules_helper $modules_helper Modules helper
|
||||
*/
|
||||
public function __construct($auth, $config, $db, $request, $template, $phpbb_root_path, $phpEx, $user)
|
||||
public function __construct($auth, $config, $db, $request, $template, $phpbb_root_path, $phpEx, $user, $modules_helper)
|
||||
{
|
||||
$this->auth = $auth;
|
||||
$this->config = $config;
|
||||
@@ -93,6 +97,7 @@ class poll extends module_base
|
||||
$this->php_ext = $phpEx;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->user = $user;
|
||||
$this->modules_helper = $modules_helper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,7 +236,7 @@ class poll extends module_base
|
||||
|
||||
if($s_can_up_vote)
|
||||
{
|
||||
$redirect_url = append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal");
|
||||
$redirect_url = $this->modules_helper->route('board3_portal_controller');
|
||||
|
||||
if (!sizeof($voted_id) || sizeof($voted_id) > $topic_data['poll_max_options'] || in_array(VOTE_CONVERTED, $cur_voted_id))
|
||||
{
|
||||
@@ -449,8 +454,8 @@ class poll extends module_base
|
||||
}
|
||||
|
||||
$poll_view_str = urlencode(implode(',', $make_poll_view));
|
||||
$portalpoll_url= append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "polls=$poll_view_str");
|
||||
$portalvote_url= append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "f=$forum_id&t=$topic_id");
|
||||
$portalpoll_url= $this->modules_helper->route('board3_portal_controller') . "polls=$poll_view_str";
|
||||
$portalvote_url= $this->modules_helper->route('board3_portal_controller') . "f=$forum_id&t=$topic_id";
|
||||
$viewtopic_url = append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", "f=$forum_id&t=$topic_id");
|
||||
$poll_end = $data['poll_length'] + $data['poll_start'];
|
||||
|
||||
|
||||
@@ -44,21 +44,18 @@ class stylechanger extends module_base
|
||||
/** @var \phpbb\config\config */
|
||||
protected $config;
|
||||
|
||||
/** @var \phpbb\template */
|
||||
/** @var \board3\portal\includes\modules_helper */
|
||||
protected $modules_helper;
|
||||
|
||||
/** @var \phpbb\template\template */
|
||||
protected $template;
|
||||
|
||||
/** @var \phpbb\db\driver */
|
||||
/** @var \phpbb\db\driver\driver_interface */
|
||||
protected $db;
|
||||
|
||||
/** @var \phpbb\request\request */
|
||||
/** @var \phpbb\request\request_interface */
|
||||
protected $request;
|
||||
|
||||
/** @var string PHP file extension */
|
||||
protected $php_ext;
|
||||
|
||||
/** @var string phpBB root path */
|
||||
protected $phpbb_root_path;
|
||||
|
||||
/** @var \phpbb\user */
|
||||
protected $user;
|
||||
|
||||
@@ -66,21 +63,19 @@ class stylechanger extends module_base
|
||||
* Construct a stylechanger object
|
||||
*
|
||||
* @param \phpbb\config\config $config phpBB config
|
||||
* @param \phpbb\template $template phpBB template
|
||||
* @param \phpbb\db\driver $db Database driver
|
||||
* @param \phpbb\request\request $request phpBB request
|
||||
* @param string $phpEx php file extension
|
||||
* @param string $phpbb_root_path phpBB root path
|
||||
* @param \board3\portal\includes\modules_helper $modules_helper Modules helper
|
||||
* @param \phpbb\template\template $template phpBB template
|
||||
* @param \phpbb\db\driver\driver_interface $db Database driver
|
||||
* @param \phpbb\request\request_interface $request phpBB request
|
||||
* @param \phpbb\user $user phpBB user object
|
||||
*/
|
||||
public function __construct($config, $template, $db, $request, $phpEx, $phpbb_root_path, $user)
|
||||
public function __construct($config, $modules_helper, $template, $db, $request, $user)
|
||||
{
|
||||
$this->config = $config;
|
||||
$this->modules_helper = $modules_helper;
|
||||
$this->template = $template;
|
||||
$this->db = $db;
|
||||
$this->request = $request;
|
||||
$this->php_ext = $phpEx;
|
||||
$this->phpbb_root_path = $phpbb_root_path;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
@@ -101,11 +96,11 @@ class stylechanger extends module_base
|
||||
$style = $this->request->variable('style', 0);
|
||||
if (!empty($style))
|
||||
{
|
||||
$url = str_replace('style=' . $style, 'style=' . $row['style_id'], append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal"));
|
||||
$url = str_replace('style=' . $style, 'style=' . $row['style_id'], $this->modules_helper->route('board3_portal_controller'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$url = append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", 'style=' . $row['style_id']);
|
||||
$url = $this->modules_helper->route('board3_portal_controller') . '?style=' . $row['style_id'];
|
||||
}
|
||||
++$style_count;
|
||||
$style_select .= '<option value="' . $url . '"' . ($row['style_id'] == $this->user->style['style_id'] ? ' selected="selected"' : '') . '>' . utf8_htmlspecialchars($row['style_name']) . '</option>';
|
||||
|
||||
Reference in New Issue
Block a user