Skip to content

Commit

Permalink
Merge pull request #422 from marc1706/ticket/334
Browse files Browse the repository at this point in the history
[ticket/334] Allow overriding the HTML5 clock with flash files
  • Loading branch information
marc1706 committed Nov 26, 2014
2 parents c07de94 + 876e0e9 commit c6896d5
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 4 deletions.
16 changes: 14 additions & 2 deletions acp/portal_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,20 @@ public function main($id, $mode)
{
if (!is_array($null['submit']))
{
$func = array($this->c_class, $null['submit']);
$args = ($module_id != 0) ? array($config_name, $module_id) : $config_name;
if (method_exists($this->c_class, $null['submit']))
{
$func = array($this->c_class, $null['submit']);
$args = ($module_id != 0) ? array($config_name, $module_id) : $config_name;
}
else if (function_exists($null['submit']))
{
$func = $null['submit'];
$args = ($module_id != 0) ? array($cfg_array[$config_name], $config_name, $module_id) : $config_name;
}
else
{
throw new \RuntimeException($this->user->lang('UNKNOWN_MODULE_METHOD', $module_data['module_classname']));
}
}
else
{
Expand Down
3 changes: 3 additions & 0 deletions config/modules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ services:

board3.portal.module.clock:
class: board3\portal\modules\clock
arguments:
- @config
- @template
tags:
- { name: board3.portal.module }

Expand Down
1 change: 1 addition & 0 deletions language/de/portal_acp.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
'MODULE_STATUS' => 'Aktiviere Modul',
'MODULE_ADD_ONCE' => 'Diese Modul kann nur ein Mal hinzugefügt werden.',
'MODULE_IMAGE_ERROR' => 'Während dem Prüfen des Modul Bildes sind ein oder mehrere Fehler aufgetreten:',
'UNKNOWN_MODULE_METHOD' => 'Die Modul Methode des %1$s Moduls konnte nicht gefunden werden.',

// general
'ACP_PORTAL_CONFIG_INFO' => 'Allgemeine Einstellungen',
Expand Down
1 change: 1 addition & 0 deletions language/en/portal_acp.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
'MODULE_STATUS' => 'Enable module',
'MODULE_ADD_ONCE' => 'This module can only be added once.',
'MODULE_IMAGE_ERROR' => 'There was an error while checking for the module image:',
'UNKNOWN_MODULE_METHOD' => 'The %1$s module’s module method couldn’t be resolved.',

// general
'ACP_PORTAL_CONFIG_INFO' => 'General settings',
Expand Down
1 change: 1 addition & 0 deletions language/nl/portal_acp.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
'MODULE_STATUS' => 'Module inschakelen',
'MODULE_ADD_ONCE' => 'Deze module kan maar één keer worden toegevoegd.',
'MODULE_IMAGE_ERROR' => 'Er is een fout opgetreden tijdens het controleren van de module afbeelding:',
'UNKNOWN_MODULE_METHOD' => 'De methode van de %1$s module kan niet worden gevonden.',
// general
'ACP_PORTAL_CONFIG_INFO' => 'Algemene instellingen',
'ACP_PORTAL_GENERAL_TITLE' => 'Portaal beheer',
Expand Down
17 changes: 17 additions & 0 deletions migrations/v210_rc1.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,23 @@ public function update_data()
return array(
array('config.remove', array('board3_phpbb_menu')),
array('config.update', array('board3_portal_version', '2.1.0-rc1')),
array('custom', array(array($this, 'add_clock_setting'))),
);
}

/**
* Adds clock settings to already installed clock modules
*/
public function add_clock_setting()
{
$sql = 'SELECT module_id
FROM ' . $this->table_prefix . "portal_modules
WHERE module_classname = '\\\board3\\\portal\\\modules\\\clock'";
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
$this->config->set('board3_clock_src_' . $row['module_id'], '');
}
$this->db->sql_freeresult($result);
}
}
45 changes: 44 additions & 1 deletion modules/clock.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,33 @@ class clock extends module_base
*/
public $language = 'portal_clock_module';

/** @var \phpbb\config\config */
protected $config;

/** @var \phpbb\template\template */
protected $template;

/**
* Constructor for clock module
*
* @param \phpbb\config\config $config phpBB config
* @param \phpbb\template\template $template phpBB template
*/
public function __construct($config, $template)
{
$this->config = $config;
$this->template = $template;
}

/**
* {@inheritdoc}
*/
public function get_template_side($module_id)
{
if (isset($this->config['board3_clock_src_' . $module_id]) && !empty($this->config['board3_clock_src_' . $module_id]))
{
$this->template->assign_var('B3P_CLOCK_SRC', $this->config['board3_clock_src_' . $module_id]);
}
return 'clock_side.html';
}

Expand All @@ -56,7 +78,28 @@ public function get_template_acp($module_id)
{
return array(
'title' => 'ACP_PORTAL_CLOCK_SETTINGS',
'vars' => array(),
'vars' => array(
'legend1' => 'ACP_PORTAL_CLOCK_SETTINGS',
'board3_clock_src_' . $module_id => array('lang' => 'ACP_PORTAL_CLOCK_SRC', 'validate' => 'string', 'type' => 'text:50:200', 'explain' => true, 'submit_type' => 'custom', 'submit' => 'check_file_src'),
),
);
}

/**
* {@inheritdoc}
*/
public function install($module_id)
{
$this->config->set('board3_clock_src_' . $module_id, '');
return true;
}

/**
* {@inheritdoc}
*/
public function uninstall($module_id, $db)
{
$this->config->delete('board3_clock_src_' . $module_id);
return true;
}
}
10 changes: 10 additions & 0 deletions styles/prosilver/template/portal/modules/clock_side.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="{$IMAGE_WIDTH}" height="{$IMAGE_HEIGHT}" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R}
<!-- IF not B3P_CLOCK_SRC -->
<div class="portal-clock-wrapper">
<div class="portal-clock">
<div class="portal-clock-back">
Expand Down Expand Up @@ -29,4 +30,13 @@
</div>
<!-- INCLUDEJS portal/assets/jquery_easing_1_3.js -->
<!-- INCLUDEJS portal/assets/portal_clock.js -->
<!-- ELSE -->
<div style="text-align: center;">
<br />
<object type="application/x-shockwave-flash" data="{T_THEME_PATH}/images/portal/{B3P_CLOCK_SRC}" width="140">
<param name="wmode" value="transparent" />
<param name="movie" value="{T_THEME_PATH}/images/portal/{B3P_CLOCK_SRC}" />
</object>
</div>
<!-- ENDIF -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
12 changes: 12 additions & 0 deletions styles/subsilver2/template/portal/modules/clock_side.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{$LR_BLOCK_H_L}<!-- IF $S_BLOCK_ICON --><img src="{$IMAGE_SRC}" width="{$IMAGE_WIDTH}" height="{$IMAGE_HEIGHT}" alt="" />&nbsp;<!-- ENDIF -->{$TITLE}{$LR_BLOCK_H_R}
<table class="tablebg" cellspacing="1" width="100%">
<tr class="row1" style="height: 5em;">
<!-- IF not B3P_CLOCK_SRC -->
<td style="text-align: center; height: 5em; margin: 0 auto;">
<div id="portal-clock">
<div id="portal-clock-back">
Expand Down Expand Up @@ -29,8 +30,19 @@
</div>
</div>
</td>
<!-- ELSE -->
<td style="text-align:center;">
<br />
<object type="application/x-shockwave-flash" data="{T_THEME_PATH}/images/portal/{B3P_CLOCK_SRC}" width="140">
<param name="wmode" value="transparent" />
<param name="movie" value="{T_THEME_PATH}/images/portal/{B3P_CLOCK_SRC}" />
</object>
</td>
<!-- ENDIF -->
</tr>
</table>
<!-- IF not B3P_CLOCK_SRC -->
<!-- INCLUDEJS portal/modules/jquery_easing_1_3.js -->
<!-- INCLUDEJS portal/modules/portal_clock.js -->
<!-- ENDIF -->
{$LR_BLOCK_F_L}{$LR_BLOCK_F_R}
2 changes: 1 addition & 1 deletion tests/unit/acp/move_module_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function setUp()
$config = new \phpbb\config\config(array());
$phpbb_container->set('board3.portal.module_collection',
array(
new \board3\portal\modules\clock(),
new \board3\portal\modules\clock($config, $template),
new \board3\portal\modules\birthday_list($config, $template, $this->db, $user),
new \board3\portal\modules\welcome($config, new \phpbb_mock_request, $this->db, $user, $phpbb_root_path, $phpEx),
new \board3\portal\modules\donation($config, $template, $user),
Expand Down

0 comments on commit c6896d5

Please sign in to comment.