diff --git a/acp/portal_module.php b/acp/portal_module.php index e2b0e97b..93afc893 100644 --- a/acp/portal_module.php +++ b/acp/portal_module.php @@ -107,6 +107,9 @@ class portal_module 'legend3' => 'ACP_PORTAL_SHOW_ALL', 'board3_show_all_pages' => array('lang' => 'ACP_PORTAL_SHOW_ALL', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'board3_show_all_side' => array('lang' => 'PORTAL_SHOW_ALL_SIDE', 'validate' => 'bool', 'type' => 'custom', 'method' => array('board3.portal.modules_helper', 'display_left_right'), 'submit' => array('board3.portal.modules_helper', 'store_left_right'), 'explain' => true), + + 'legend4' => 'ACP_FA', + 'board3_fa_styles' => array('lang' => 'ACP_FA', 'validate' => 'string', 'type' => 'custom', 'method' => array('board3.portal.modules_helper', 'display_fa_styles'), 'submit' => array('board3.portal.modules_helper', 'store_fa_styles'), 'explain' => true), ) ); @@ -139,6 +142,8 @@ class portal_module 'MODULE_IMAGE_WIDTH' => $module_data['module_image_width'], 'MODULE_IMAGE_HEIGHT' => $module_data['module_image_height'], 'MODULE_IMAGE_SRC' => ($module_data['module_image_src']) ? $this->root_path . 'styles/all/theme/images/portal/' . $module_data['module_image_src'] : '', + 'MODULE_FA' => $module_data['module_fa_icon'], + 'MODULE_FA_SIZE' => $module_data['module_fa_size'], 'MODULE_ENABLED' => ($module_data['module_status']) ? true : false, 'MODULE_SHOW_IMAGE' => (in_array($this->portal_columns->number_to_string($module_data['module_column']), array('center', 'top', 'bottom'))) ? false : true, )); @@ -272,6 +277,8 @@ class portal_module 'module_image_src' => $this->request->variable('module_image', ''), 'module_image_width' => $this->request->variable('module_img_width', 0), 'module_image_height' => $this->request->variable('module_img_height', 0), + 'module_fa_icon' => $this->request->variable('module_fa', ''), + 'module_fa_size' => $this->request->variable('module_fa_size', 16), 'module_group_ids' => $module_permission, 'module_status' => $this->request->variable('module_status', self::B3_MODULE_ENABLED), ); diff --git a/adm/style/portal/acp_portal_calendar.html b/adm/style/portal/acp_portal_calendar.html index f703502a..d7bfcd78 100644 --- a/adm/style/portal/acp_portal_calendar.html +++ b/adm/style/portal/acp_portal_calendar.html @@ -104,6 +104,14 @@
px
+
+

{L_MODULE_FA_EXP}
+
+
+
+

{L_MODULE_FA_SIZE_EXP}
+
 {L_PIXEL}
+

{L_MODULE_RESET_EXP}
diff --git a/adm/style/portal/acp_portal_config.html b/adm/style/portal/acp_portal_config.html index 206ae8a3..3b537f2a 100644 --- a/adm/style/portal/acp_portal_config.html +++ b/adm/style/portal/acp_portal_config.html @@ -39,6 +39,14 @@
px
+
+

{L_MODULE_FA_EXP}
+
+
+
+

{L_MODULE_FA_SIZE_EXP}
+
 {L_PIXEL}
+

{L_MODULE_RESET_EXP}
@@ -98,4 +106,4 @@ - \ No newline at end of file + diff --git a/adm/style/portal/acp_portal_custom.html b/adm/style/portal/acp_portal_custom.html index 3a9159be..23fbab34 100644 --- a/adm/style/portal/acp_portal_custom.html +++ b/adm/style/portal/acp_portal_custom.html @@ -107,6 +107,14 @@ function change_palette()
px
+
+

{L_MODULE_FA_EXP}
+
+
+
+

{L_MODULE_FA_SIZE_EXP}
+
 {L_PIXEL}
+

{L_MODULE_RESET_EXP}
diff --git a/adm/style/portal/acp_portal_links.html b/adm/style/portal/acp_portal_links.html index 8fb0934c..c71d78d0 100644 --- a/adm/style/portal/acp_portal_links.html +++ b/adm/style/portal/acp_portal_links.html @@ -88,6 +88,14 @@
px
+
+

{L_MODULE_FA_EXP}
+
+
+
+

{L_MODULE_FA_SIZE_EXP}
+
 {L_PIXEL}
+

{L_MODULE_RESET_EXP}
diff --git a/adm/style/portal/acp_portal_menu.html b/adm/style/portal/acp_portal_menu.html index 3c4a3957..02c1ac26 100644 --- a/adm/style/portal/acp_portal_menu.html +++ b/adm/style/portal/acp_portal_menu.html @@ -95,6 +95,14 @@
px
+
+

{L_MODULE_FA_EXP}
+
+
+
+

{L_MODULE_FA_SIZE_EXP}
+
 {L_PIXEL}
+

{L_MODULE_RESET_EXP}
diff --git a/adm/style/portal/acp_portal_welcome.html b/adm/style/portal/acp_portal_welcome.html index 814d0682..cc4037ca 100644 --- a/adm/style/portal/acp_portal_welcome.html +++ b/adm/style/portal/acp_portal_welcome.html @@ -107,6 +107,14 @@ function change_palette()
px
+
+

{L_MODULE_FA_EXP}
+
+
+
+

{L_MODULE_FA_SIZE_EXP}
+
 {L_PIXEL}
+

{L_MODULE_RESET_EXP}
diff --git a/config/services.yml b/config/services.yml index 64e5b52c..1198d358 100644 --- a/config/services.yml +++ b/config/services.yml @@ -51,7 +51,9 @@ services: - '@auth' - '@config' - '@controller.helper' + - '@dbal.conn' - '@request' + - '%tables.styles%' board3.portal.columns: class: board3\portal\portal\columns diff --git a/controller/helper.php b/controller/helper.php index 2a0f8694..6c3198ae 100644 --- a/controller/helper.php +++ b/controller/helper.php @@ -230,6 +230,9 @@ class helper */ public function assign_module_vars($row, $template_module) { + $fa_styles = json_decode($this->config['board3_portal_fa_styles']); + $use_fa = !empty($fa_styles) && in_array($this->user->style['style_name'], $fa_styles); + if (is_array($template_module)) { $this->template->assign_block_vars('modules_' . $this->portal_columns->number_to_string($row['module_column']), array( @@ -240,6 +243,9 @@ class helper 'MODULE_ID' => $row['module_id'], 'IMAGE_WIDTH' => $row['module_image_width'], 'IMAGE_HEIGHT' => $row['module_image_height'], + 'FA_ICON' => isset($row['module_fa_icon']) ? utf8_htmlspecialchars($row['module_fa_icon']) : '', + 'FA_SIZE' => $row['module_fa_size'] ?? '', + 'FA_ENABLED' => $use_fa, )); } else @@ -251,6 +257,9 @@ class helper 'IMAGE_HEIGHT' => $row['module_image_height'], 'MODULE_ID' => $row['module_id'], 'TITLE' => (isset($this->user->lang[$row['module_name']])) ? $this->user->lang[$row['module_name']] : utf8_normalize_nfc($row['module_name']), + 'FA_ICON' => isset($row['module_fa_icon']) ? utf8_htmlspecialchars($row['module_fa_icon']) : '', + 'FA_SIZE' => $row['module_fa_size'] ?? '', + 'FA_ENABLED' => $use_fa, )); } } diff --git a/includes/modules_helper.php b/includes/modules_helper.php index c5c1d656..96e0f93a 100644 --- a/includes/modules_helper.php +++ b/includes/modules_helper.php @@ -25,6 +25,9 @@ class modules_helper */ protected $config; + /** @var \phpbb\db\driver\driver_interface */ + protected $db; + /** @var \phpbb\controller\helper Controller helper */ protected $controller_helper; @@ -34,6 +37,9 @@ class modules_helper */ protected $request; + /** @var string Styles table */ + protected $styles_table; + /** * Constructor * NOTE: The parameters of this method must match in order and type with @@ -41,14 +47,18 @@ class modules_helper * @param \phpbb\auth\auth $auth Auth object * @param \phpbb\config\config $config phpBB config * @param \phpbb\controller\helper $controller_helper Controller helper + * @param \phpbb\db\driver\driver_interface $db Dbal connection * @param \phpbb\request\request $request phpBB request + * @param string $styles_table Styles table */ - public function __construct($auth, $config, $controller_helper, $request) + public function __construct($auth, $config, $controller_helper, $db, $request, string $styles_table) { $this->auth = $auth; $this->config = $config; $this->controller_helper = $controller_helper; + $this->db = $db; $this->request = $request; + $this->styles_table = $styles_table; } /** @@ -188,4 +198,44 @@ class modules_helper $this->config->set($key, $value); } + + /** + * Show available styles + * + * @return string Select with available styles + */ + public function display_fa_styles(): string + { + $portal_fa_styles = json_decode($this->config->offsetGet('board3_portal_fa_styles')); + if (!$portal_fa_styles) + { + $portal_fa_styles = []; + } + $options = ''; + $query = 'SELECT style_name + FROM ' . $this->styles_table; + $result = $this->db->sql_query($query); + while ($row = $this->db->sql_fetchrow($result)) + { + $options .= '