diff --git a/config/modules.yml b/config/modules.yml
new file mode 100644
index 00000000..561227e9
--- /dev/null
+++ b/config/modules.yml
@@ -0,0 +1,292 @@
+services:
+ board3.module.announcements:
+ class: \board3\portal\modules\announcements
+ arguments:
+ - @auth
+ - @cache
+ - @config
+ - @template
+ - @dbal.conn
+ - %core.php_ext%
+ - %core.root_path%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.attachments:
+ class: \board3\portal\modules\attachments
+ arguments:
+ - @auth
+ - @config
+ - @template
+ - @dbal.conn
+ - %core.php_ext%
+ - %core.root_path%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.birthday_list:
+ class: \board3\portal\modules\birthday_list
+ arguments:
+ - @config
+ - @template
+ - @dbal.conn
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.calendar:
+ class: \board3\portal\modules\calendar
+ arguments:
+ - @config
+ - @template
+ - @dbal.conn
+ - %core.root_path%
+ - %core.php_ext%
+ - @user
+ - @path_helper
+ tags:
+ - { name: board3.module }
+
+ board3.module.clock:
+ class: \board3\portal\modules\clock
+ tags:
+ - { name: board3.module }
+
+ board3.module.custom:
+ class: \board3\portal\modules\custom
+ arguments:
+ - @config
+ - @template
+ - @dbal.conn
+ - %core.root_path%
+ - %core.php_ext%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.donation:
+ class: \board3\portal\modules\donation
+ arguments:
+ - @config
+ - @template
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.forumlist:
+ class: \board3\portal\modules\forumlist
+ arguments:
+ - @auth
+ - @config
+ - @template
+ - %core.root_path%
+ - %core.php_ext%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.friends:
+ class: \board3\portal\modules\friends
+ arguments:
+ - @auth
+ - @config
+ - @dbal.conn
+ - @template
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.latest_bots:
+ class: \board3\portal\modules\latest_bots
+ arguments:
+ - @config
+ - @dbal.conn
+ - @template
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.latest_members:
+ class: \board3\portal\modules\latest_members
+ arguments:
+ - @config
+ - @dbal.conn
+ - @template
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.leaders:
+ class: \board3\portal\modules\leaders
+ arguments:
+ - @auth
+ - @config
+ - @dbal.conn
+ - @template
+ - %core.root_path%
+ - %core.php_ext%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.link_us:
+ class: \board3\portal\modules\link_us
+ arguments:
+ - @config
+ - @template
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.links:
+ class: \board3\portal\modules\links
+ arguments:
+ - @config
+ - @dbal.conn
+ - @template
+ - %core.root_path%
+ - %core.php_ext%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.main_menu:
+ class: \board3\portal\modules\main_menu
+ arguments:
+ - @config
+ - @dbal.conn
+ - @template
+ - %core.root_path%
+ - %core.php_ext%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.news:
+ class: \board3\portal\modules\news
+ arguments:
+ - @auth
+ - @cache
+ - @config
+ - @dbal.conn
+ - @template
+ - %core.root_path%
+ - %core.php_ext%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.poll:
+ class: \board3\portal\modules\poll
+ arguments:
+ - @auth
+ - @config
+ - @dbal.conn
+ - @template
+ - %core.root_path%
+ - %core.php_ext%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.random_member:
+ class: \board3\portal\modules\random_member
+ arguments:
+ - @dbal.conn
+ - @template
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.recent:
+ class: \board3\portal\modules\recent
+ arguments:
+ - @auth
+ - @config
+ - @dbal.conn
+ - @template
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: board3.module }
+
+ board3.module.search:
+ class: \board3\portal\modules\search
+ arguments:
+ - @template
+ - %core.php_ext%
+ - %core.root_path%
+ tags:
+ - { name: board3.module }
+
+ board3.module.statistics:
+ class: \board3\portal\modules\statistics
+ arguments:
+ - @cache
+ - @config
+ - @dbal.conn
+ - @template
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.stylechanger:
+ class: \board3\portal\modules\stylechanger
+ arguments:
+ - @config
+ - @template
+ - @dbal.conn
+ - %core.php_ext%
+ - %core.root_path%
+ - @user
+ tags:
+ - { name: board3.module }
+
+ board3.module.topposters:
+ class: \board3\portal\modules\topposters
+ arguments:
+ - @config
+ - @dbal.conn
+ - @template
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: board3.module }
+
+ board3.module.user_menu:
+ class: \board3\portal\modules\user_menu
+ arguments:
+ - @auth
+ - @config
+ - @dbal.conn
+ - @template
+ - @user
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: board3.module }
+
+ board3.module.welcome:
+ class: \board3\portal\modules\welcome
+ arguments:
+ - @config
+ - @template
+ - @user
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: board3.module }
+
+ board3.module.whois_online:
+ class: \board3\portal\modules\whois_online
+ arguments:
+ - @auth
+ - @dbal.conn
+ - @template
+ - @user
+ - %core.root_path%
+ - %core.php_ext%
+ tags:
+ - { name: board3.module }
diff --git a/config/services.yml b/config/services.yml
index 1bbaaf91..e1635105 100644
--- a/config/services.yml
+++ b/config/services.yml
@@ -1,3 +1,6 @@
+imports:
+ - { resource: modules.yml }
+
parameters:
board3.version_data:
author: Marc
@@ -10,7 +13,6 @@ parameters:
- board3_portal.xml
services:
-
board3.portal.main:
class: \board3\portal\controller\main
arguments:
@@ -39,177 +41,3 @@ services:
- @service_container
tags:
- { name: service_collection, tag: board3.module }
-
- board3.module.announcements:
- class: \board3\portal\modules\announcements
- arguments:
- - @auth
- - @cache
- - @config
- - @template
- - @dbal.conn
- - %core.php_ext%
- - %core.root_path%
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.attachments:
- class: \board3\portal\modules\attachments
- arguments:
- - @auth
- - @config
- - @template
- - @dbal.conn
- - %core.php_ext%
- - %core.root_path%
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.birthday_list:
- class: \board3\portal\modules\birthday_list
- arguments:
- - @config
- - @template
- - @dbal.conn
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.calendar:
- class: \board3\portal\modules\calendar
- arguments:
- - @config
- - @template
- - @dbal.conn
- - %core.root_path%
- - %core.php_ext%
- - @user
- - @path_helper
- tags:
- - { name: board3.module }
-
- board3.module.custom:
- class: \board3\portal\modules\custom
- arguments:
- - @config
- - @template
- - @dbal.conn
- - %core.root_path%
- - %core.php_ext%
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.forumlist:
- class: \board3\portal\modules\forumlist
- arguments:
- - @auth
- - @config
- - @template
- - %core.root_path%
- - %core.php_ext%
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.friends:
- class: \board3\portal\modules\friends
- arguments:
- - @auth
- - @config
- - @dbal.conn
- - @template
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.latest_bots:
- class: \board3\portal\modules\latest_bots
- arguments:
- - @config
- - @dbal.conn
- - @template
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.latest_members:
- class: \board3\portal\modules\latest_members
- arguments:
- - @config
- - @dbal.conn
- - @template
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.leaders:
- class: \board3\portal\modules\leaders
- arguments:
- - @auth
- - @config
- - @dbal.conn
- - @template
- - %core.root_path%
- - %core.php_ext%
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.link_us:
- class: \board3\portal\modules\link_us
- arguments:
- - @config
- - @template
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.links:
- class: \board3\portal\modules\links
- arguments:
- - @config
- - @dbal.conn
- - @template
- - %core.root_path%
- - %core.php_ext%
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.search:
- class: \board3\portal\modules\search
- arguments:
- - @template
- - %core.php_ext%
- - %core.root_path%
- tags:
- - { name: board3.module }
-
- board3.module.stylechanger:
- class: \board3\portal\modules\stylechanger
- arguments:
- - @config
- - @template
- - @dbal.conn
- - %core.php_ext%
- - %core.root_path%
- - @user
- tags:
- - { name: board3.module }
-
- board3.module.clock:
- class: \board3\portal\modules\clock
- tags:
- - { name: board3.module }
-
- board3.module.donation:
- class: \board3\portal\modules\donation
- arguments:
- - @config
- - @template
- - @user
- tags:
- - { name: board3.module }
diff --git a/migrations/v210_beta1.php b/migrations/v210_beta1.php
index c612ab2c..be52e38a 100644
--- a/migrations/v210_beta1.php
+++ b/migrations/v210_beta1.php
@@ -303,7 +303,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
// Populate module table
$board3_sql_query = array(
array(
- 'module_classname' => 'main_menu',
+ 'module_classname' => '\board3\portal\modules\main_menu',
'module_column' => 1,
'module_order' => 1,
'module_name' => 'M_MENU',
@@ -369,7 +369,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
- 'module_classname' => 'topposters',
+ 'module_classname' => '\board3\portal\modules\topposters',
'module_column' => 1,
'module_order' => 7,
'module_name' => 'TOPPOSTERS',
@@ -402,7 +402,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
- 'module_classname' => 'welcome',
+ 'module_classname' => '\board3\portal\modules\welcome',
'module_column' => 2,
'module_order' => 1,
'module_name' => 'PORTAL_WELCOME',
@@ -413,7 +413,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
- 'module_classname' => 'recent',
+ 'module_classname' => '\board3\portal\modules\recent',
'module_column' => 2,
'module_order' => 2,
'module_name' => 'PORTAL_RECENT',
@@ -435,7 +435,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
- 'module_classname' => 'news',
+ 'module_classname' => '\board3\portal\modules\news',
'module_column' => 2,
'module_order' => 4,
'module_name' => 'LATEST_NEWS',
@@ -446,7 +446,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
- 'module_classname' => 'poll',
+ 'module_classname' => '\board3\portal\modules\poll',
'module_column' => 2,
'module_order' => 5,
'module_name' => 'PORTAL_POLL',
@@ -457,7 +457,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
- 'module_classname' => 'whois_online',
+ 'module_classname' => '\board3\portal\modules\whois_online',
'module_column' => 2,
'module_order' => 6,
'module_name' => 'PORTAL_WHOIS_ONLINE',
@@ -468,7 +468,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
- 'module_classname' => 'user_menu',
+ 'module_classname' => '\board3\portal\modules\user_menu',
'module_column' => 3,
'module_order' => 1,
'module_name' => 'USER_MENU',
@@ -479,7 +479,7 @@ class v210_beta1 extends \phpbb\db\migration\migration
'module_status' => 1,
),
array(
- 'module_classname' => 'statistics',
+ 'module_classname' => '\board3\portal\modules\statistics',
'module_column' => 3,
'module_order' => 2,
'module_name' => 'STATISTICS',
diff --git a/portal/modules/portal_main_menu.php b/modules/main_menu.php
similarity index 71%
rename from portal/modules/portal_main_menu.php
rename to modules/main_menu.php
index 6b514fc7..59cd954d 100644
--- a/portal/modules/portal_main_menu.php
+++ b/modules/main_menu.php
@@ -1,24 +1,18 @@
config = $config;
+ $this->db = $db;
+ $this->template = $template;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $phpEx;
+ $this->user = $user;
+ }
+
+ /**
+ * @inheritdoc
+ */
public function get_template_side($module_id)
{
- global $config, $template, $phpEx, $phpbb_root_path, $user, $db;
-
$links = array();
$portal_config = obtain_portal_config();
@@ -76,8 +109,8 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
{
if($links[$i]['type'] == self::LINK_CAT)
{
- $template->assign_block_vars('portalmenu', array(
- 'CAT_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'],
+ $this->template->assign_block_vars('portalmenu', array(
+ 'CAT_TITLE' => (isset($this->user->lang[$links[$i]['title']])) ? $this->user->lang[$links[$i]['title']] : $links[$i]['title'],
'MODULE_ID' => $module_id,
));
}
@@ -86,7 +119,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
if($links[$i]['type'] == self::LINK_INT)
{
$links[$i]['url'] = str_replace('&', '&', $links[$i]['url']); // we need to do this in order to prevent XHTML validation errors
- $cur_url = append_sid($phpbb_root_path . $links[$i]['url']); // the user should know what kind of file it is
+ $cur_url = append_sid($this->phpbb_root_path . $links[$i]['url']); // the user should know what kind of file it is
}
else
{
@@ -98,10 +131,10 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
if(!empty($permission_check) || $links[$i]['permission'] == '')
{
- $template->assign_block_vars('portalmenu.links', array(
- 'LINK_TITLE' => (isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title'],
+ $this->template->assign_block_vars('portalmenu.links', array(
+ 'LINK_TITLE' => (isset($this->user->lang[$links[$i]['title']])) ? $this->user->lang[$links[$i]['title']] : $links[$i]['title'],
'LINK_URL' => $cur_url,
- 'NEW_WINDOW' => ($links[$i]['type'] != self::LINK_INT && $config['board3_menu_url_new_window_' . $module_id]) ? true : false,
+ 'NEW_WINDOW' => ($links[$i]['type'] != self::LINK_INT && $this->config['board3_menu_url_new_window_' . $module_id]) ? true : false,
));
}
}
@@ -110,9 +143,11 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
return 'main_menu_side.html';
}
+ /**
+ * @inheritdoc
+ */
public function get_template_acp($module_id)
{
- // do not remove this as it is needed in order to run manage_links
return array(
'title' => 'ACP_PORTAL_MENU',
'vars' => array(
@@ -124,18 +159,16 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
}
/**
- * API functions
+ * @inheritdoc
*/
public function install($module_id)
{
- global $phpbb_root_path, $phpEx, $db;
-
// get the correct group IDs from the database
$in_ary = array('GUESTS', 'REGISTERED', 'REGISTERED_COPPA');
- $sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' WHERE ' . $db->sql_in_set('group_name', $in_ary);
- $result = $db->sql_query($sql);
- while($row = $db->sql_fetchrow($result))
+ $sql = 'SELECT group_id, group_name FROM ' . GROUPS_TABLE . ' WHERE ' . $this->db->sql_in_set('group_name', $in_ary);
+ $result = $this->db->sql_query($sql);
+ while($row = $this->db->sql_fetchrow($result))
{
$groups_ary[$row['group_name']] = $row['group_id'];
}
@@ -172,16 +205,16 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
$links_urls = array(
'',
- 'index.' . $phpEx,
- 'search.' . $phpEx,
- 'ucp.' . $phpEx . '?mode=register',
- 'memberlist.' . $phpEx,
- 'memberlist.' . $phpEx . '?mode=leaders',
+ 'index.' . $this->php_ext,
+ 'search.' . $this->php_ext,
+ 'ucp.' . $this->php_ext . '?mode=register',
+ 'memberlist.' . $this->php_ext,
+ 'memberlist.' . $this->php_ext . '?mode=leaders',
'',
- 'faq.' . $phpEx,
- 'faq.' . $phpEx . '?mode=bbcode',
- 'ucp.' . $phpEx . '?mode=terms',
- 'ucp.' . $phpEx . '?mode=privacy',
+ 'faq.' . $this->php_ext,
+ 'faq.' . $this->php_ext . '?mode=bbcode',
+ 'ucp.' . $this->php_ext . '?mode=terms',
+ 'ucp.' . $this->php_ext . '?mode=privacy',
);
$links_permissions = array(
@@ -216,6 +249,9 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
return true;
}
+ /**
+ * @inheritdoc
+ */
public function uninstall($module_id, $db)
{
$del_config = array(
@@ -235,11 +271,17 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
return $db->sql_query($sql);
}
- // Manage the menu links
+ /**
+ * Manage the menu links
+ *
+ * @param mixed $value Value of input
+ * @param string $key Key name
+ * @param int $module_id Module ID
+ *
+ * @return null
+ */
public function manage_links($value, $key, $module_id)
{
- global $config, $phpbb_admin_path, $user, $phpEx, $db, $template;
-
$action = request_var('action', '');
$action = (isset($_POST['add'])) ? 'add' : $action;
$action = (isset($_POST['save'])) ? 'save' : $action;
@@ -250,7 +292,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
$links = $this->utf_unserialize($portal_config['board3_menu_array_' . $module_id]);
- $u_action = append_sid($phpbb_admin_path . 'index.' . $phpEx, 'i=portal&mode=config&module_id=' . $module_id);
+ $u_action = append_sid('index.' . $this->php_ext, 'i=\board3\portal\modules\portal&mode=config&module_id=' . $module_id);
switch ($action)
{
@@ -258,7 +300,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
case 'save':
if (!check_form_key('acp_portal'))
{
- trigger_error($user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
+ trigger_error($this->user->lang['FORM_INVALID']. adm_back_link($u_action), E_USER_WARNING);
}
$link_title = utf8_normalize_nfc(request_var('link_title', ' ', true));
@@ -273,12 +315,12 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
$sql = 'SELECT group_id
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
- $result = $db->sql_query($sql);
- while($row = $db->sql_fetchrow($result))
+ $result = $this->db->sql_query($sql);
+ while($row = $this->db->sql_fetchrow($result))
{
$groups_ary[] = $row['group_id'];
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
$link_permissions = array_intersect($link_permission, $groups_ary);
$link_permissions = implode(',', $link_permissions);
@@ -286,18 +328,18 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
// Check for errors
if (!$link_title)
{
- trigger_error($user->lang['NO_LINK_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
+ trigger_error($this->user->lang['NO_LINK_TITLE'] . adm_back_link($u_action), E_USER_WARNING);
}
if (!$link_is_cat && !$link_url)
{
- trigger_error($user->lang['NO_LINK_URL'] . adm_back_link($u_action), E_USER_WARNING);
+ trigger_error($this->user->lang['NO_LINK_URL'] . adm_back_link($u_action), E_USER_WARNING);
}
// overwrite already existing links and make sure we don't try to save a link outside of the normal array size of $links
if (isset($link_id) && $link_id < sizeof($links))
{
- $message = $user->lang['LINK_UPDATED'];
+ $message = $this->user->lang['LINK_UPDATED'];
$links[$link_id] = array(
'title' => $link_title,
@@ -310,11 +352,11 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
}
else
{
- $message = $user->lang['LINK_ADDED'];
+ $message = $this->user->lang['LINK_ADDED'];
if($link_type != self::LINK_CAT && sizeof($links) < 1)
{
- trigger_error($user->lang['ACP_PORTAL_MENU_CREATE_CAT'] . adm_back_link($u_action), E_USER_WARNING);
+ trigger_error($this->user->lang['ACP_PORTAL_MENU_CREATE_CAT'] . adm_back_link($u_action), E_USER_WARNING);
}
$links[] = array(
'title' => $link_title,
@@ -337,7 +379,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
if (!isset($link_id) && $link_id >= sizeof($links))
{
- trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
+ trigger_error($this->user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
}
if (confirm_box(true))
@@ -354,7 +396,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
}
else
{
- confirm_box(false, $user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
+ confirm_box(false, $this->user->lang['CONFIRM_OPERATION'], build_hidden_fields(array(
'link_id' => $link_id,
'action' => 'delete',
)));
@@ -368,7 +410,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
if (!isset($link_id) && $link_id >= sizeof($links))
{
- trigger_error($user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
+ trigger_error($this->user->lang['MUST_SELECT_LINK'] . adm_back_link($u_action), E_USER_WARNING);
}
// make sure we don't try to move a link where it can't be moved
@@ -411,7 +453,7 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
// Edit or add menu item
case 'edit':
case 'add':
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'LINK_TITLE' => (isset($links[$link_id]['title']) && $action != 'add') ? $links[$link_id]['title'] : '',
'LINK_URL' => (isset($links[$link_id]['url']) && $links[$link_id]['type'] != self::LINK_CAT && $action != 'add') ? str_replace('&', '&', $links[$link_id]['url']) : '',
@@ -429,16 +471,16 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
$sql = 'SELECT group_id, group_name
FROM ' . GROUPS_TABLE . '
ORDER BY group_id ASC';
- $result = $db->sql_query($sql);
- while($row = $db->sql_fetchrow($result))
+ $result = $this->db->sql_query($sql);
+ while($row = $this->db->sql_fetchrow($result))
{
- $template->assign_block_vars('permission_setting_menu', array(
+ $this->template->assign_block_vars('permission_setting_menu', array(
'SELECTED' => (in_array($row['group_id'], $groups_ary)) ? true : false,
- 'GROUP_NAME' => (isset($user->lang['G_' . $row['group_name']])) ? $user->lang['G_' . $row['group_name']] : $row['group_name'],
+ 'GROUP_NAME' => (isset($this->user->lang['G_' . $row['group_name']])) ? $this->user->lang['G_' . $row['group_name']] : $row['group_name'],
'GROUP_ID' => $row['group_id'],
));
}
- $db->sql_freeresult($result);
+ $this->db->sql_freeresult($result);
return;
@@ -447,8 +489,8 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
for ($i = 0; $i < sizeof($links); $i++)
{
- $template->assign_block_vars('links', array(
- 'LINK_TITLE' => ($action != 'add') ? ((isset($user->lang[$links[$i]['title']])) ? $user->lang[$links[$i]['title']] : $links[$i]['title']) : '',
+ $this->template->assign_block_vars('links', array(
+ 'LINK_TITLE' => ($action != 'add') ? ((isset($this->user->lang[$links[$i]['title']])) ? $this->user->lang[$links[$i]['title']] : $links[$i]['title']) : '',
'LINK_URL' => ($action != 'add') ? str_replace('&', '&', $links[$i]['url']) : '',
'U_EDIT' => $u_action . '&action=edit&id=' . $i,
@@ -461,12 +503,26 @@ class portal_main_menu_module extends \board3\portal\modules\module_base
}
}
+ /**
+ * Update links
+ *
+ * @param string $key Key name
+ * @param int $module_id Module ID
+ *
+ * @return null
+ */
public function update_links($key, $module_id)
{
$this->manage_links('', $key, $module_id);
}
- // Unserialize links array
+ /**
+ * Unserialize links array
+ *
+ * @param string $serial_str Serialized string
+ *
+ * @return string Unserialized string
+ */
private function utf_unserialize($serial_str)
{
$out = preg_replace('!s:(\d+):"(.*?)";!se', "'s:'.strlen('$2').':\"$2\";'", $serial_str );
diff --git a/portal/modules/portal_news.php b/modules/news.php
similarity index 54%
rename from portal/modules/portal_news.php
rename to modules/news.php
index d8cd194b..7ea1ccb0 100644
--- a/portal/modules/portal_news.php
+++ b/modules/news.php
@@ -1,24 +1,18 @@
auth = $auth;
+ $this->cache = $cache;
+ $this->config = $config;
+ $this->db = $db;
+ $this->template = $template;
+ $this->phpbb_root_path = $phpbb_root_path;
+ $this->php_ext = $phpEx;
+ $this->user = $user;
+ }
+
+ /**
+ * @inheritdoc
+ */
public function get_template_center($module_id)
{
- global $config, $template, $db, $user, $auth, $cache, $phpEx, $phpbb_root_path;
-
$news = request_var('news', -1);
- $news = ($news > $config['board3_number_of_news_' . $module_id] -1) ? -1 : $news;
- $user->add_lang('viewforum');
+ $news = ($news > $this->config['board3_number_of_news_' . $module_id] -1) ? -1 : $news;
+ $this->user->add_lang('viewforum');
$start = request_var('np', 0);
$start = ($start < 0) ? 0 : $start;
// Fetch news from portal/includes/functions.php with check if "read full" is requested.
- $portal_news_length = ($news < 0) ? $config['board3_news_length_' . $module_id] : 0;
- $fetch_news = phpbb_fetch_posts($module_id, $config['board3_news_forum_' . $module_id], $config['board3_news_permissions_' . $module_id], $config['board3_number_of_news_' . $module_id], $portal_news_length, 0, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $start, $config['board3_news_exclude_' . $module_id]);
+ $portal_news_length = ($news < 0) ? $this->config['board3_news_length_' . $module_id] : 0;
+ $fetch_news = phpbb_fetch_posts($module_id, $this->config['board3_news_forum_' . $module_id], $this->config['board3_news_permissions_' . $module_id], $this->config['board3_number_of_news_' . $module_id], $portal_news_length, 0, ($this->config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news', $start, $this->config['board3_news_exclude_' . $module_id]);
// Any news present? If not terminate it here.
if (sizeof($fetch_news) == 0)
{
- $template->assign_block_vars('news_row', array(
+ $this->template->assign_block_vars('news_row', array(
'S_NO_TOPICS' => true,
'S_NOT_LAST' => false,
));
@@ -73,10 +116,10 @@ class portal_news_module extends \board3\portal\modules\module_base
else
{
// Count number of posts for news archive, considering if permission check is dis- or enabled.
- if ($config['board3_news_archive_' . $module_id])
+ if ($this->config['board3_news_archive_' . $module_id])
{
- $permissions = $config['board3_news_permissions_' . $module_id];
- $forum_from = $config['board3_news_forum_' . $module_id];
+ $permissions = $this->config['board3_news_permissions_' . $module_id];
+ $forum_from = $this->config['board3_news_forum_' . $module_id];
$forum_from = (strpos($forum_from, ',') !== false) ? explode(',', $forum_from) : (($forum_from != '') ? array($forum_from) : array());
@@ -84,14 +127,14 @@ class portal_news_module extends \board3\portal\modules\module_base
if($permissions == true)
{
- $disallow_access = array_unique(array_keys($auth->acl_getf('!f_read', true)));
+ $disallow_access = array_unique(array_keys($this->auth->acl_getf('!f_read', true)));
}
else
{
$disallow_access = array();
}
- if($config['board3_news_exclude_' . $module_id] == true)
+ if($this->config['board3_news_exclude_' . $module_id] == true)
{
$disallow_access = array_merge($disallow_access, $forum_from);
$forum_from = array();
@@ -122,7 +165,7 @@ class portal_news_module extends \board3\portal\modules\module_base
$str_where = (strlen($str_where) > 0) ? 'AND (' . trim(substr($str_where, 0, -4)) . ')' : '';
- $topic_type = ($config['board3_show_all_news_' . $module_id]) ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL;
+ $topic_type = ($this->config['board3_show_all_news_' . $module_id]) ? '(topic_type <> ' . POST_ANNOUNCE . ') AND (topic_type <> ' . POST_GLOBAL . ')' : 'topic_type = ' . POST_NORMAL;
$sql = 'SELECT COUNT(topic_id) AS num_topics
FROM ' . TOPICS_TABLE . '
@@ -130,9 +173,9 @@ class portal_news_module extends \board3\portal\modules\module_base
AND topic_visibility = ' . ITEM_APPROVED . '
AND topic_moved_id = 0
' . $str_where;
- $result = $db->sql_query($sql);
- $total_news = (int) $db->sql_fetchfield('num_topics');
- $db->sql_freeresult($result);
+ $result = $this->db->sql_query($sql);
+ $total_news = (int) $this->db->sql_fetchfield('num_topics');
+ $this->db->sql_freeresult($result);
}
$topic_tracking_info = get_portal_tracking_info($fetch_news);
@@ -147,7 +190,7 @@ class portal_news_module extends \board3\portal\modules\module_base
{
$open_bracket = '[ ';
$close_bracket = ' ]';
- $read_full = $user->lang['READ_FULL'];
+ $read_full = $this->user->lang['READ_FULL'];
}
else
{
@@ -161,13 +204,13 @@ class portal_news_module extends \board3\portal\modules\module_base
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$read_full_url = (isset($_GET['np'])) ? 'np='. $start . '&news=' . $i . '#n' . $i : 'news=' . $i . '#n' . $i;
- $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
- if ($config['board3_news_archive_' . $module_id])
+ $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);
+ if ($this->config['board3_news_archive_' . $module_id])
{
- $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news_' . $module_id], $start, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news');
+ $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');
}
- $replies = ($auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
+ $replies = ($this->auth->acl_get('m_approve', $forum_id)) ? $fetch_news[$i]['topic_replies_real'] : $fetch_news[$i]['topic_replies'];
$folder_img = $folder_alt = $topic_type = $folder = $folder_new = '';
switch ($fetch_news[$i]['topic_type'])
{
@@ -182,7 +225,7 @@ class portal_news_module extends \board3\portal\modules\module_base
default:
$folder = 'topic_read';
$folder_new = 'topic_unread';
- if ($config['hot_threshold'] && $replies >= $config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
+ if ($this->config['hot_threshold'] && $replies >= $this->config['hot_threshold'] && $fetch_news[$i]['topic_status'] != ITEM_LOCKED)
{
$folder .= '_hot';
$folder_new .= '_hot';
@@ -205,38 +248,38 @@ class portal_news_module extends \board3\portal\modules\module_base
$folder_alt = ($unread_topic) ? 'NEW_POSTS' : (($fetch_news[$i]['topic_status'] == ITEM_LOCKED) ? 'TOPIC_LOCKED' : 'NO_NEW_POSTS');
// Grab icons
- $icons = $cache->obtain_icons();
+ $icons = $this->cache->obtain_icons();
- phpbb_generate_template_pagination($template, $view_topic_url, 'pagination', 'np', $fetch_news[$i]['topic_replies'], $config['board3_number_of_news_' . $module_id], $start);
+ phpbb_generate_template_pagination($this->template, $view_topic_url, 'pagination', 'np', $fetch_news[$i]['topic_replies'], $this->config['board3_number_of_news_' . $module_id], $start);
- $template->assign_block_vars('news_row', array(
- 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
+ $this->template->assign_block_vars('news_row', array(
+ 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
'POSTER_FULL' => $fetch_news[$i]['username_full'],
'USERNAME_FULL_LAST' => $fetch_news[$i]['username_full_last'],
- 'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '',
+ 'U_USER_PROFILE' => (($fetch_news[$i]['user_type'] == USER_NORMAL || $fetch_news[$i]['user_type'] == USER_FOUNDER) && $fetch_news[$i]['user_id'] != ANONYMOUS) ? append_sid("{$this->phpbb_root_path}memberlist.{$this->php_ext}", 'mode=viewprofile&u=' . $fetch_news[$i]['user_id']) : '',
'TIME' => $fetch_news[$i]['topic_time'],
- 'LAST_POST_TIME' => $user->format_date($fetch_news[$i]['topic_last_post_time']),
+ 'LAST_POST_TIME' => $this->user->format_date($fetch_news[$i]['topic_last_post_time']),
'TEXT' => $fetch_news[$i]['post_text'],
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'N_ID' => $i,
- 'TOPIC_FOLDER_IMG' => $user->img($folder_img, $folder_alt),
+ 'TOPIC_FOLDER_IMG' => $this->user->img($folder_img, $folder_alt),
'TOPIC_IMG_STYLE' => $folder_img,
- 'TOPIC_FOLDER_IMG_SRC' => $user->img($folder_img, $folder_alt, false, '', 'src'),
- 'TOPIC_FOLDER_IMG_ALT' => $user->lang[$folder_alt],
+ 'TOPIC_FOLDER_IMG_SRC' => $this->user->img($folder_img, $folder_alt, false, '', 'src'),
+ 'TOPIC_FOLDER_IMG_ALT' => $this->user->lang[$folder_alt],
'TOPIC_ICON_IMG' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['img'] : '',
'TOPIC_ICON_IMG_WIDTH' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['width'] : '',
'TOPIC_ICON_IMG_HEIGHT' => (!empty($icons[$fetch_news[$i]['icon_id']])) ? $icons[$fetch_news[$i]['icon_id']]['height'] : '',
- 'FOLDER_IMG' => $user->img('topic_read', 'NO_NEW_POSTS'),
- 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
- 'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
- 'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
- 'U_VIEW_UNREAD' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&view=unread#unread'),
- 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
- 'U_READ_FULL' => append_sid("{$phpbb_root_path}portal.$phpEx", $read_full_url),
+ 'FOLDER_IMG' => $this->user->img('topic_read', 'NO_NEW_POSTS'),
+ 'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']),
+ 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id'] . '&p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
+ '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),
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
@@ -250,18 +293,18 @@ class portal_news_module extends \board3\portal\modules\module_base
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
- $template->assign_block_vars('news_row.attachment', array(
+ $this->template->assign_block_vars('news_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
- if ($config['board3_number_of_news_' . $module_id] <> 0 && $config['board3_news_archive_' . $module_id])
+ if ($this->config['board3_number_of_news_' . $module_id] <> 0 && $this->config['board3_news_archive_' . $module_id])
{
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'NP_PAGINATION' => $pagination,
- 'TOTAL_NEWS' => ($total_news == 1) ? sprintf($user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($user->lang['VIEW_FORUM_TOPICS'][2], $total_news),
- 'NP_PAGE_NUMBER' => phpbb_on_page($template, $user, $view_topic_url, $total_news, $config['board3_number_of_news_' . $module_id], $start))
+ 'TOTAL_NEWS' => ($total_news == 1) ? sprintf($this->user->lang['VIEW_FORUM_TOPICS'][1], $total_news) : sprintf($this->user->lang['VIEW_FORUM_TOPICS'][2], $total_news),
+ 'NP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, $view_topic_url, $total_news, $this->config['board3_number_of_news_' . $module_id], $start))
);
}
}
@@ -275,17 +318,17 @@ class portal_news_module extends \board3\portal\modules\module_base
$unread_topic = (isset($topic_tracking_info[$topic_id]) && $fetch_news[$i]['topic_last_post_time'] > $topic_tracking_info[$topic_id]) ? true : false;
$open_bracket = '[ ';
$close_bracket = ' ]';
- $read_full = $user->lang['BACK'];
+ $read_full = $this->user->lang['BACK'];
- $read_full_url = (isset($_GET['np'])) ? append_sid("{$phpbb_root_path}portal.$phpEx", "np=$start#n$i") : append_sid("{$phpbb_root_path}portal.$phpEx#n$i");
- $view_topic_url = append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . (($fetch_news[$i]['forum_id']) ? $fetch_news[$i]['forum_id'] : $forum_id) . '&t=' . $topic_id);
- if ($config['board3_news_archive_' . $module_id])
+ $read_full_url = (isset($_GET['np'])) ? append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal", "np=$start#n$i") : append_sid("{$this->phpbb_root_path}app.{$this->php_ext}/portal#n$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);
+ if ($this->config['board3_news_archive_' . $module_id])
{
- $pagination = generate_portal_pagination(append_sid("{$phpbb_root_path}portal.$phpEx"), $total_news, $config['board3_number_of_news_' . $module_id], $start, ($config['board3_show_all_news_' . $module_id]) ? 'news_all' : 'news');
+ $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');
}
- $template->assign_block_vars('news_row', array(
- 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $config['allow_attachments']) ? $user->img('icon_topic_attach', $user->lang['TOTAL_ATTACHMENTS']) : '',
+ $this->template->assign_block_vars('news_row', array(
+ 'ATTACH_ICON_IMG' => ($fetch_news[$i]['attachment'] && $this->config['allow_attachments']) ? $this->user->img('icon_topic_attach', $this->user->lang['TOTAL_ATTACHMENTS']) : '',
'FORUM_NAME' => ($forum_id) ? $fetch_news[$i]['forum_name'] : '',
'TITLE' => $fetch_news[$i]['topic_title'],
'POSTER' => $fetch_news[$i]['username'],
@@ -295,36 +338,37 @@ class portal_news_module extends \board3\portal\modules\module_base
'REPLIES' => $fetch_news[$i]['topic_replies'],
'TOPIC_VIEWS' => $fetch_news[$i]['topic_views'],
'N_ID' => $i,
- 'U_VIEWFORUM' => append_sid("{$phpbb_root_path}viewforum.$phpEx", 'f=' . $fetch_news[$i]['forum_id']),
- 'U_LAST_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
- 'U_VIEW_COMMENTS' => append_sid("{$phpbb_root_path}viewtopic.$phpEx", 'f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
- 'U_POST_COMMENT' => append_sid("{$phpbb_root_path}posting.$phpEx", 'mode=reply&f=' . $fetch_news[$i]['forum_id'] . '&t=' . $fetch_news[$i]['topic_id']),
+ 'U_VIEWFORUM' => append_sid("{$this->phpbb_root_path}viewforum.{$this->php_ext}", 'f=' . $fetch_news[$i]['forum_id']),
+ 'U_LAST_COMMENTS' => append_sid("{$this->phpbb_root_path}viewtopic.{$this->php_ext}", 'p=' . $fetch_news[$i]['topic_last_post_id'] . '#p' . $fetch_news[$i]['topic_last_post_id']),
+ '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_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']),
'S_POLL' => $fetch_news[$i]['poll'],
'S_UNREAD_INFO' => $unread_topic,
'U_READ_FULL' => $read_full_url,
'L_READ_FULL' => $read_full,
'OPEN' => $open_bracket,
'CLOSE' => $close_bracket,
- 'PAGINATION' => topic_generate_pagination($fetch_news[$i]['topic_replies'], $view_topic_url),
'S_HAS_ATTACHMENTS' => (!empty($fetch_news[$i]['attachments'])) ? true : false,
));
+ phpbb_generate_template_pagination($this->template, $view_topic_url, 'news_row.pagination', 'start', $fetch_news[$i]['topic_replies'] + 1, $this->config['posts_per_page'], 1, true, true);
+
if(!empty($fetch_news[$i]['attachments']))
{
foreach ($fetch_news[$i]['attachments'] as $attachment)
{
- $template->assign_block_vars('news_row.attachment', array(
+ $this->template->assign_block_vars('news_row.attachment', array(
'DISPLAY_ATTACHMENT' => $attachment)
);
}
}
- if ($config['board3_number_of_news_' . $module_id] <> 0 && $config['board3_news_archive_' . $module_id])
+ if ($this->config['board3_number_of_news_' . $module_id] <> 0 && $this->config['board3_news_archive_' . $module_id])
{
- $template->assign_vars(array(
+ $this->template->assign_vars(array(
'NP_PAGINATION' => $pagination,
- 'TOTAL_NEWS' => ($total_news == 1) ? $user->lang['VIEW_FORUM_TOPIC'] : sprintf($user->lang['VIEW_FORUM_TOPICS'], $total_news),
- 'NP_PAGE_NUMBER' => on_page($total_news, $config['board3_number_of_news_' . $module_id], $start))
+ 'TOTAL_NEWS' => ($total_news == 1) ? $this->user->lang['VIEW_FORUM_TOPIC'] : $this->user->lang('VIEW_FORUM_TOPICS', $total_news),
+ 'NP_PAGE_NUMBER' => phpbb_on_page($this->template, $this->user, '', $total_news, $this->config['board3_number_of_news_' . $module_id], $start))
);
}
}
@@ -336,17 +380,17 @@ class portal_news_module extends \board3\portal\modules\module_base
$topic_icons = true;
}
- $template->assign_vars(array(
- 'NEWEST_POST_IMG' => $user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
- 'READ_POST_IMG' => $user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
- 'GOTO_PAGE_IMG' => $user->img('icon_post_target', 'GOTO_PAGE'),
- 'S_NEWEST_OR_FIRST' => ($config['board3_news_show_last_' . $module_id]) ? $user->lang['JUMP_NEWEST'] : $user->lang['JUMP_FIRST'],
- 'POSTED_BY_TEXT' => ($config['board3_news_show_last_' . $module_id]) ? $user->lang['LAST_POST'] : $user->lang['POSTED'],
- 'S_DISPLAY_NEWS_RVS' => ($config['board3_show_news_replies_views_' . $module_id]) ? true : false,
+ $this->template->assign_vars(array(
+ 'NEWEST_POST_IMG' => $this->user->img('icon_topic_newest', 'VIEW_NEWEST_POST'),
+ 'READ_POST_IMG' => $this->user->img('icon_topic_latest', 'VIEW_LATEST_POST'),
+ 'GOTO_PAGE_IMG' => $this->user->img('icon_post_target', 'GOTO_PAGE'),
+ 'S_NEWEST_OR_FIRST' => ($this->config['board3_news_show_last_' . $module_id]) ? $this->user->lang['JUMP_NEWEST'] : $this->user->lang['JUMP_FIRST'],
+ 'POSTED_BY_TEXT' => ($this->config['board3_news_show_last_' . $module_id]) ? $this->user->lang['LAST_POST'] : $this->user->lang['POSTED'],
+ 'S_DISPLAY_NEWS_RVS' => ($this->config['board3_show_news_replies_views_' . $module_id]) ? true : false,
'S_TOPIC_ICONS' => $topic_icons,
));
- if($config['board3_news_style_' . $module_id])
+ if($this->config['board3_news_style_' . $module_id])
{
return 'news_compact_center.html';
}
@@ -356,6 +400,9 @@ class portal_news_module extends \board3\portal\modules\module_base
}
}
+ /**
+ * @inheritdoc
+ */
public function get_template_acp($module_id)
{
return array(
@@ -377,7 +424,7 @@ class portal_news_module extends \board3\portal\modules\module_base
}
/**
- * API functions
+ * @inheritdoc
*/
public function install($module_id)
{
@@ -394,6 +441,9 @@ class portal_news_module extends \board3\portal\modules\module_base
return true;
}
+ /**
+ * @inheritdoc
+ */
public function uninstall($module_id, $db)
{
$del_config = array(
@@ -413,17 +463,23 @@ class portal_news_module extends \board3\portal\modules\module_base
return $db->sql_query($sql);
}
- // Create forum select box
+ /**
+ * Create forum select box
+ *
+ * @param mixed $value Value of input
+ * @param string $key Key name
+ * @param int $module_id Module ID
+ *
+ * @return null
+ */
public function select_forums($value, $key, $module_id)
{
- global $user, $config;
-
$forum_list = make_forum_select(false, false, true, true, true, false, true);
$selected = array();
- if(isset($config[$key]) && strlen($config[$key]) > 0)
+ if(isset($this->config[$key]) && strlen($this->config[$key]) > 0)
{
- $selected = explode(',', $config[$key]);
+ $selected = explode(',', $this->config[$key]);
}
// Build forum options
$s_forum_options = '