Add Font Awesome functionality
This commit is contained in:
committed by
Marc Alexander
parent
158e3e6954
commit
d0a74065c0
@@ -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),
|
||||
);
|
||||
|
||||
@@ -104,6 +104,14 @@
|
||||
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_fa">{L_MODULE_FA}{L_COLON}</label><br/><span>{L_MODULE_FA_EXP}</span></dt>
|
||||
<dd><input id="module_fa" type="text" value="{MODULE_FA}" name="module_fa" maxlength="255" size="64"/></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="module_fa_size">{L_MODULE_FA_SIZE}{L_COLON}</label><br/><span>{L_MODULE_FA_SIZE_EXP}</span></dt>
|
||||
<dd><input id="module_fa_size" type="number" value="{MODULE_FA_SIZE}" name="module_fa_size" min="1"/> {L_PIXEL}</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_reset">{L_MODULE_RESET}{L_COLON}</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
|
||||
|
||||
@@ -39,6 +39,14 @@
|
||||
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_fa">{L_MODULE_FA}{L_COLON}</label><br/><span>{L_MODULE_FA_EXP}</span></dt>
|
||||
<dd><input id="module_fa" type="text" value="{MODULE_FA}" name="module_fa" maxlength="255" size="64"/></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="module_fa_size">{L_MODULE_FA_SIZE}{L_COLON}</label><br/><span>{L_MODULE_FA_SIZE_EXP}</span></dt>
|
||||
<dd><input id="module_fa_size" type="number" value="{MODULE_FA_SIZE}" name="module_fa_size" min="1"/> {L_PIXEL}</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_reset">{L_MODULE_RESET}{L_COLON}</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
|
||||
|
||||
@@ -107,6 +107,14 @@ function change_palette()
|
||||
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_fa">{L_MODULE_FA}{L_COLON}</label><br/><span>{L_MODULE_FA_EXP}</span></dt>
|
||||
<dd><input id="module_fa" type="text" value="{MODULE_FA}" name="module_fa" maxlength="255" size="64"/></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="module_fa_size">{L_MODULE_FA_SIZE}{L_COLON}</label><br/><span>{L_MODULE_FA_SIZE_EXP}</span></dt>
|
||||
<dd><input id="module_fa_size" type="number" value="{MODULE_FA_SIZE}" name="module_fa_size" min="1"/> {L_PIXEL}</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_reset">{L_MODULE_RESET}{L_COLON}</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
|
||||
|
||||
@@ -88,6 +88,14 @@
|
||||
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_fa">{L_MODULE_FA}{L_COLON}</label><br/><span>{L_MODULE_FA_EXP}</span></dt>
|
||||
<dd><input id="module_fa" type="text" value="{MODULE_FA}" name="module_fa" maxlength="255" size="64"/></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="module_fa_size">{L_MODULE_FA_SIZE}{L_COLON}</label><br/><span>{L_MODULE_FA_SIZE_EXP}</span></dt>
|
||||
<dd><input id="module_fa_size" type="number" value="{MODULE_FA_SIZE}" name="module_fa_size" min="1"/> {L_PIXEL}</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_reset">{L_MODULE_RESET}{L_COLON}</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
|
||||
|
||||
@@ -95,6 +95,14 @@
|
||||
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_fa">{L_MODULE_FA}{L_COLON}</label><br/><span>{L_MODULE_FA_EXP}</span></dt>
|
||||
<dd><input id="module_fa" type="text" value="{MODULE_FA}" name="module_fa" maxlength="255" size="64"/></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="module_fa_size">{L_MODULE_FA_SIZE}{L_COLON}</label><br/><span>{L_MODULE_FA_SIZE_EXP}</span></dt>
|
||||
<dd><input id="module_fa_size" type="number" value="{MODULE_FA_SIZE}" name="module_fa_size" min="1"/> {L_PIXEL}</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_reset">{L_MODULE_RESET}{L_COLON}</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
|
||||
|
||||
@@ -107,6 +107,14 @@ function change_palette()
|
||||
<dd><input id="module_img_height" type="text" value="{MODULE_IMAGE_HEIGHT}" name="module_img_height" maxlength="3" size="3" />px</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_fa">{L_MODULE_FA}{L_COLON}</label><br/><span>{L_MODULE_FA_EXP}</span></dt>
|
||||
<dd><input id="module_fa" type="text" value="{MODULE_FA}" name="module_fa" maxlength="255" size="64"/></dd>
|
||||
</dl>
|
||||
<dl>
|
||||
<dt><label for="module_fa_size">{L_MODULE_FA_SIZE}{L_COLON}</label><br/><span>{L_MODULE_FA_SIZE_EXP}</span></dt>
|
||||
<dd><input id="module_fa_size" type="number" value="{MODULE_FA_SIZE}" name="module_fa_size" min="1"/> {L_PIXEL}</dd>
|
||||
</dl>
|
||||
<!-- ENDIF -->
|
||||
<dl>
|
||||
<dt><label for="module_reset">{L_MODULE_RESET}{L_COLON}</label><br /><span style="color: #BC2A4D;">{L_MODULE_RESET_EXP}</span></dt>
|
||||
|
||||
@@ -230,6 +230,16 @@ class helper
|
||||
*/
|
||||
public function assign_module_vars($row, $template_module)
|
||||
{
|
||||
$use_fa = 0;
|
||||
$fa_styles = explode(';', $this->config['board3_portal_fa_styles']);
|
||||
foreach ($fa_styles as $fa_style)
|
||||
{
|
||||
if ($this->user->style['style_name'] == $fa_style)
|
||||
{
|
||||
$use_fa = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (is_array($template_module))
|
||||
{
|
||||
$this->template->assign_block_vars('modules_' . $this->portal_columns->number_to_string($row['module_column']), array(
|
||||
@@ -240,6 +250,9 @@ class helper
|
||||
'MODULE_ID' => $row['module_id'],
|
||||
'IMAGE_WIDTH' => $row['module_image_width'],
|
||||
'IMAGE_HEIGHT' => $row['module_image_height'],
|
||||
'FA_ICON' => utf8_htmlspecialchars($row['module_fa_icon']),
|
||||
'FA_SIZE' => $row['module_fa_size'],
|
||||
'FA_ENABLED' => $use_fa,
|
||||
));
|
||||
}
|
||||
else
|
||||
@@ -251,6 +264,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' => utf8_htmlspecialchars($row['module_fa_icon']),
|
||||
'FA_SIZE' => $row['module_fa_size'],
|
||||
'FA_ENABLED' => $use_fa,
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,4 +188,53 @@ class modules_helper
|
||||
|
||||
$this->config->set($key, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show available styles
|
||||
*
|
||||
* @return string Select with available styles
|
||||
*/
|
||||
public function display_fa_styles()
|
||||
{
|
||||
global $phpbb_container;
|
||||
$table_prefix = $phpbb_container->getParameter('core.table_prefix');
|
||||
$db = $phpbb_container->get('dbal.conn');
|
||||
$selected = explode(';', $this->config['board3_portal_fa_styles']);
|
||||
$options = '';
|
||||
$query = 'SELECT style_name
|
||||
FROM ' . $table_prefix . 'styles';
|
||||
$result = $db->sql_query($query);
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$options .= '<option value="' . $row['style_name'] . '"';
|
||||
foreach ($selected as $style)
|
||||
{
|
||||
if ($style == $row['style_name'])
|
||||
{
|
||||
$options .= ' selected';
|
||||
break;
|
||||
}
|
||||
}
|
||||
$options .= '>' . $row['style_name'] . '</option>';
|
||||
}
|
||||
$db->sql_freeresult($result);
|
||||
return '<select id="board3_fa_styles" name="board3_fa_styles[]" multiple>' . $options . '</select>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Save styles that have been set as Font Awesome styles
|
||||
*
|
||||
* @param string $key Key of the parameter
|
||||
*/
|
||||
public function store_fa_styles($key)
|
||||
{
|
||||
$style_array = $this->request->variable($key, array(''));
|
||||
$styles = '';
|
||||
foreach ($style_array as $style)
|
||||
{
|
||||
$styles .= ($styles == '' ? '' : ';') . $style;
|
||||
}
|
||||
var_dump($styles);
|
||||
$this->config->set('board3_portal_fa_styles', $styles);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,4 +106,12 @@ $lang = array_merge($lang, array(
|
||||
// Install
|
||||
'PORTAL_BASIC_INSTALL' => 'Füge Basismodule hinzu',
|
||||
'PORTAL_BASIC_UNINSTALL' => 'Entferne Module von Datenbank',
|
||||
|
||||
// Font Awesome
|
||||
'ACP_FA' => 'Font Awesome Styles',
|
||||
'ACP_FA_EXP' => 'Hier kannst du einstellen welche Styles Font Awesome Icons nutzen sollen.',
|
||||
'MODULE_FA' => 'Font Awesome Icon',
|
||||
'MODULE_FA_EXP' => 'Hier kannst du ein Font Awesome Icon einstellen. Dieses wird verwendet wenn der Style Font Awesome verwendet.',
|
||||
'MODULE_FA_SIZE' => 'Font Awesome Icongröße',
|
||||
'MODULE_FA_SIZE_EXP' => 'Hier kannst du die Größe des Font Awesome Icons einstellen (in Pixel).',
|
||||
));
|
||||
|
||||
@@ -106,4 +106,12 @@ $lang = array_merge($lang, array(
|
||||
// Install
|
||||
'PORTAL_BASIC_INSTALL' => 'Adding basic set of modules',
|
||||
'PORTAL_BASIC_UNINSTALL' => 'Removing modules from database',
|
||||
|
||||
// Font Awesome
|
||||
'ACP_FA' => 'Font Awesome styles',
|
||||
'ACP_FA_EXP' => 'Here you can define which styles should use the Font Awesome icons.',
|
||||
'MODULE_FA' => 'Font Awesome icon',
|
||||
'MODULE_FA_EXP' => 'Here you can select a Font Awesome icon. This will be used when your selected style uses Font Awesome icons.',
|
||||
'MODULE_FA_SIZE' => 'Font Awesome icon size',
|
||||
'MODULE_FA_SIZE_EXP' => 'Here you can change the size of the Font Awesome icon in pixel.',
|
||||
));
|
||||
|
||||
65
migrations/v220_fa.php
Normal file
65
migrations/v220_fa.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package Board3 Portal v2.2
|
||||
* @copyright 2015 Board3 Group ( www.board3.de )
|
||||
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||
*/
|
||||
|
||||
namespace board3\portal\migrations;
|
||||
|
||||
use phpbb\db\migration\migration;
|
||||
|
||||
class v220_fa extends migration
|
||||
{
|
||||
static public function depends_on()
|
||||
{
|
||||
return array('\board3\portal\migrations\v210_rc3');
|
||||
}
|
||||
|
||||
public function update_schema()
|
||||
{
|
||||
return array(
|
||||
'add_columns' => array(
|
||||
$this->table_prefix . 'portal_modules' => array(
|
||||
'module_fa_icon' => array('VCHAR', ''),
|
||||
'module_fa_size' => array('INT:1', 16),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return array(
|
||||
array('config.add', array('board3_portal_fa_styles', '')),
|
||||
array('custom', array(array(&$this, 'insert_defaults'))),
|
||||
);
|
||||
}
|
||||
|
||||
public function insert_defaults()
|
||||
{
|
||||
$fa_icons = array(
|
||||
'\board3\portal\modules\main_menu' => 'fa-bars',
|
||||
'\board3\portal\modules\stylechanger' => 'fa-paint-brush',
|
||||
'\board3\portal\modules\birthday_list' => 'fa-birthday-cake',
|
||||
'\board3\portal\modules\clock' => 'fa-clock-o',
|
||||
'\board3\portal\modules\search' => 'fa-search',
|
||||
'\board3\portal\modules\attachments' => 'fa-paperclip',
|
||||
'\board3\portal\modules\topposters' => 'fa-pencil-square-o',
|
||||
'\board3\portal\modules\latest_members' => 'fa-users',
|
||||
'\board3\portal\modules\link_us' => 'fa-external-link',
|
||||
'\board3\portal\modules\user_menu' => 'fa-user',
|
||||
'\board3\portal\modules\statistics' => 'fa-bar-chart',
|
||||
'\board3\portal\modules\calendar' => 'fa-calendar',
|
||||
'\board3\portal\modules\leaders' => 'fa-users',
|
||||
'\board3\portal\modules\latest_bots' => 'fa-android',
|
||||
'\board3\portal\modules\links' => 'fa-link',
|
||||
);
|
||||
foreach ($fa_icons as $key => $value)
|
||||
{
|
||||
$query = 'UPDATE ' . $this->table_prefix . "portal_modules SET module_fa_icon = '" . $value . "' WHERE module_classname = '" . $this->db->sql_escape($key) . "'";
|
||||
$this->db->sql_query($query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,6 +75,8 @@ class database_handler
|
||||
'module_group_ids' => '',
|
||||
'module_image_height' => 16,
|
||||
'module_image_width' => 16,
|
||||
'module_fa_icon' => '',
|
||||
'module_fa_size' => 1,
|
||||
'module_status' => self::B3_MODULE_ENABLED,
|
||||
);
|
||||
$sql = 'UPDATE ' . PORTAL_MODULES_TABLE . '
|
||||
|
||||
Reference in New Issue
Block a user