diff --git a/README.md b/README.md index b71a2aae..eb11b8cf 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,6 @@ The extension is currently under heavy development and not supported until furth We are starting to have unit and functional tests in order to prevent regressions. You can check our travis build below. 2.1.x - [![Build Status](https://travis-ci.org/board3/Board3-Portal.svg?branch=2.1.x)](https://travis-ci.org/board3/Board3-Portal) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/board3/Board3-Portal/badges/quality-score.png?b=develop-2.1.x)](https://scrutinizer-ci.com/g/board3/Board3-Portal/?branch=develop-2.1.x) -[![Code Coverage](https://scrutinizer-ci.com/g/board3/Board3-Portal/badges/coverage.png?b=develop-2.1.x)](https://scrutinizer-ci.com/g/board3/Board3-Portal/?branch=develop-2.1.x) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/board3/Board3-Portal/badges/quality-score.png?b=2.1.x)](https://scrutinizer-ci.com/g/board3/Board3-Portal/?branch=2.1.x) +[![Code Coverage](https://scrutinizer-ci.com/g/board3/Board3-Portal/badges/coverage.png?b=2.1.x)](https://scrutinizer-ci.com/g/board3/Board3-Portal/?branch=2.1.x) diff --git a/acp/portal_module.php b/acp/portal_module.php index b1ab4060..91aa680a 100644 --- a/acp/portal_module.php +++ b/acp/portal_module.php @@ -18,7 +18,7 @@ class portal_module protected $c_class; protected $db, $user, $cache, $template, $display_vars, $config, $phpbb_root_path, $phpbb_admin_path, $phpEx, $phpbb_container; - protected $root_path, $version_check, $request, $php_ext, $portal_helper, $modules_helper, $log, $portal_columns; + protected $root_path, $request, $php_ext, $portal_helper, $modules_helper, $log, $portal_columns; /** @var \board3\portal\portal\modules\manager */ protected $modules_manager; @@ -51,7 +51,6 @@ class portal_module $this->phpbb_admin_path = $phpbb_admin_path; $this->php_ext = $phpEx; $this->phpbb_container = $phpbb_container; - $this->version_check = $this->phpbb_container->get('board3.portal.version.check'); $this->portal_helper = $this->phpbb_container->get('board3.portal.helper'); $this->modules_helper = $this->phpbb_container->get('board3.portal.modules_helper'); $this->log = $phpbb_log; @@ -99,7 +98,6 @@ class portal_module 'board3_enable' => array('lang' => 'PORTAL_ENABLE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'board3_left_column' => array('lang' => 'PORTAL_LEFT_COLUMN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'board3_right_column' => array('lang' => 'PORTAL_RIGHT_COLUMN', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), - 'board3_version_check' => array('lang' => 'PORTAL_VERSION_CHECK', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => false), 'board3_display_jumpbox' => array('lang' => 'PORTAL_DISPLAY_JUMPBOX', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), 'legend2' => 'ACP_PORTAL_COLUMN_WIDTH_SETTINGS', @@ -168,11 +166,6 @@ class portal_module $this->template->assign_var('SHOW_MODULE_OPTIONS', true); } } - else - { - // only show the mod version check if we are on the General Settings page - $this->version_check->check(); - } $this->new_config = $this->config; $cfg_array = ($this->request->is_set('config')) ? $this->request->variable('config', array('' => ''), true) : $this->new_config; diff --git a/adm/style/portal/acp_portal_config.html b/adm/style/portal/acp_portal_config.html index 33bcf81f..206ae8a3 100644 --- a/adm/style/portal/acp_portal_config.html +++ b/adm/style/portal/acp_portal_config.html @@ -13,31 +13,6 @@ - - -
- {L_VERSION_CHECK} -

{mods.UP_TO_DATE}

-
-
-
{mods.CURRENT_VERSION}
-
-
-
-
{mods.LATEST_VERSION}
-
- -
-
-
{L_DOWNLOAD} {mods.TITLE} {mods.LATEST_VERSION}
-
-
-
-
{L_RELEASE_ANNOUNCEMENT}
-
- -
-
diff --git a/adm/style/portal/ajax.js b/adm/style/portal/ajax.js index e38c6157..eb85ac05 100644 --- a/adm/style/portal/ajax.js +++ b/adm/style/portal/ajax.js @@ -13,33 +13,39 @@ phpbb.addAjaxCallback('b3p_move_module_up', function(res) { return; } - var el = $(this).parents('tr:first'), - trSwap = el.prev(), - elClass = trSwap.attr('class'), - trSwapClass = el.attr('class'); + var $bottomRow = $(this).parents('tr:first'), + $topRow = $bottomRow.prev(), + topRowClass = $topRow.attr('class'), + bottomRowClass = $bottomRow.attr('class'); - el.insertBefore(trSwap); - el.attr('class', elClass); - trSwap.attr('class', trSwapClass); + $bottomRow.insertBefore($topRow); + if (bottomRowClass !== 'row3' && topRowClass !== 'row3') { + $bottomRow.attr('class', topRowClass); + $topRow.attr('class', bottomRowClass); + } else if (bottomRowClass === 'row3') { + $topRow.attr('class', (topRowClass === 'row1') ? 'row2' : 'row1'); + } else if (topRowClass === 'row3') { + $bottomRow.attr('class', (bottomRowClass === 'row1') ? 'row2' : 'row1'); + } // Swap images if swap element is first row - var swapIsFirstRow = trSwap.find('img[src*="icon_up_disabled"]').parents('span:first').is(':visible'); + var swapIsFirstRow = $topRow.find('img[src*="icon_up_disabled"]').parents('span:first').is(':visible'); if (swapIsFirstRow) { - trSwap.find('img[src*="icon_up_disabled"]').parents('span:first').toggle(); - trSwap.find('img[src*="icon_up."]').parents('span:first').toggle(); - el.find('img[src*="icon_up."]').parents('span:first').toggle(); - el.find('img[src*="icon_up_disabled"]').parents('span:first').toggle(); + $topRow.find('img[src*="icon_up_disabled"]').parents('span:first').toggle(); + $topRow.find('img[src*="icon_up."]').parents('span:first').toggle(); + $bottomRow.find('img[src*="icon_up."]').parents('span:first').toggle(); + $bottomRow.find('img[src*="icon_up_disabled"]').parents('span:first').toggle(); } // Swap images if move element is last row - var elIsLastRow = el.find('img[src*="icon_down_disabled"]').parents('span:first').is(':visible'); + var elIsLastRow = $bottomRow.find('img[src*="icon_down_disabled"]').parents('span:first').is(':visible'); if (elIsLastRow) { - trSwap.find('img[src*="icon_down_disabled"]').parents('span:first').toggle(); - trSwap.find('img[src*="icon_down."]').parents('span:first').toggle(); - el.find('img[src*="icon_down."]').parents('span:first').toggle(); - el.find('img[src*="icon_down_disabled"]').parents('span:first').toggle(); + $topRow.find('img[src*="icon_down_disabled"]').parents('span:first').toggle(); + $topRow.find('img[src*="icon_down."]').parents('span:first').toggle(); + $bottomRow.find('img[src*="icon_down."]').parents('span:first').toggle(); + $bottomRow.find('img[src*="icon_down_disabled"]').parents('span:first').toggle(); } }); @@ -48,33 +54,39 @@ phpbb.addAjaxCallback('b3p_move_module_down', function(res) { return; } - var el = $(this).parents('tr:first'), - trSwap = el.next(), - elClass = trSwap.attr('class'), - trSwapClass = el.attr('class'); + var $topRow = $(this).parents('tr:first'), + $bottomRow = $topRow.next(), + bottomRowClass = $bottomRow.attr('class'), + topRowClass = $topRow.attr('class'); - el.insertAfter(trSwap); - el.attr('class', elClass); - trSwap.attr('class', trSwapClass); + $topRow.insertAfter($bottomRow); + if (bottomRowClass !== 'row3' && topRowClass !== 'row3') { + $bottomRow.attr('class', topRowClass); + $topRow.attr('class', bottomRowClass); + } else if (bottomRowClass === 'row3') { + $topRow.attr('class', (topRowClass === 'row1') ? 'row2' : 'row1'); + } else if (topRowClass === 'row3') { + $bottomRow.attr('class', (bottomRowClass === 'row1') ? 'row2' : 'row1'); + } // Swap images if swap element is last row - var swapIsLastRow = trSwap.find('img[src*="icon_down_disabled"]').parents('span:first').is(':visible'); + var swapIsLastRow = $bottomRow.find('img[src*="icon_down_disabled"]').parents('span:first').is(':visible'); if (swapIsLastRow) { - trSwap.find('img[src*="icon_down_disabled"]').parents('span:first').toggle(); - trSwap.find('img[src*="icon_down."]').parents('span:first').toggle(); - el.find('img[src*="icon_down."]').parents('span:first').toggle(); - el.find('img[src*="icon_down_disabled"]').parents('span:first').toggle(); + $bottomRow.find('img[src*="icon_down_disabled"]').parents('span:first').toggle(); + $bottomRow.find('img[src*="icon_down."]').parents('span:first').toggle(); + $topRow.find('img[src*="icon_down."]').parents('span:first').toggle(); + $topRow.find('img[src*="icon_down_disabled"]').parents('span:first').toggle(); } // Swap images if move element is first row - var elIsFirstRow = el.find('img[src*="icon_up_disabled"]').parents('span:first').is(':visible'); + var elIsFirstRow = $topRow.find('img[src*="icon_up_disabled"]').parents('span:first').is(':visible'); if (elIsFirstRow) { - trSwap.find('img[src*="icon_up_disabled"]').parents('span:first').toggle(); - trSwap.find('img[src*="icon_up."]').parents('span:first').toggle(); - el.find('img[src*="icon_up."]').parents('span:first').toggle(); - el.find('img[src*="icon_up_disabled"]').parents('span:first').toggle(); + $bottomRow.find('img[src*="icon_up_disabled"]').parents('span:first').toggle(); + $bottomRow.find('img[src*="icon_up."]').parents('span:first').toggle(); + $topRow.find('img[src*="icon_up."]').parents('span:first').toggle(); + $topRow.find('img[src*="icon_up_disabled"]').parents('span:first').toggle(); } }); @@ -83,16 +95,20 @@ phpbb.addAjaxCallback('b3p_delete_module', function(res) { return; } - var el = $(this).parents('tr:first'), - nextEl = el.next(); + var $deletedRow = $(this).parents('tr:first'), + $nextRow = $deletedRow.next(); - el.remove(); + $deletedRow.remove(); // Fix classes of next elements - while (nextEl !== undefined && nextEl.is('tr')) { - var nextElClass = (nextEl.attr('class') === 'row1') ? 'row2' : 'row1'; - nextEl.attr('class', nextElClass); - nextEl = nextEl.next(); + while ($nextRow !== undefined && $nextRow.is('tr')) { + var nextRowClass = ($nextRow.attr('class') === 'row1') ? 'row2' : 'row1'; + + if ($nextRow.attr('class') !== 'row3') { + $nextRow.attr('class', nextRowClass); + } + + $nextRow = $nextRow.next(); } }); diff --git a/build.xml b/build.xml index efd4874f..8d309a84 100644 --- a/build.xml +++ b/build.xml @@ -41,7 +41,9 @@ - + + + @@ -59,19 +61,81 @@ passthru="true" /> - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + - -
-
- {L_INFORMATION}{L_COLON} {PORTAL_VERSION_CHECK} -
-
- -
@@ -71,7 +63,7 @@ -
+
diff --git a/styles/subsilver2/template/portal/portal_body.html b/styles/subsilver2/template/portal/portal_body.html index 6c1eba39..f0497227 100644 --- a/styles/subsilver2/template/portal/portal_body.html +++ b/styles/subsilver2/template/portal/portal_body.html @@ -1,20 +1,6 @@ - - - - - - - - -
- -
-
- - diff --git a/tests/unit/acp/move_module_test.php b/tests/unit/acp/move_module_test.php index 68e4e023..5b3bf2ce 100644 --- a/tests/unit/acp/move_module_test.php +++ b/tests/unit/acp/move_module_test.php @@ -38,11 +38,6 @@ class phpbb_acp_move_module_test extends \board3\portal\tests\testframework\data $user = new \board3\portal\tests\mock\user(); $request = new \phpbb_mock_request; $phpbb_container = new \phpbb_mock_container_builder(); - // Mock version check - $phpbb_container->set('board3.portal.version.check', - $this->getMockBuilder('\board3\portal\includes\version_check') - ->disableOriginalConstructor() - ->getMock()); // Mock module service collection $config = new \phpbb\config\config(array()); $auth = $this->getMock('\phpbb\auth\auth', array('acl_get')); diff --git a/tests/unit/functions/version_check_test.php b/tests/unit/functions/version_check_test.php deleted file mode 100644 index 03af4af4..00000000 --- a/tests/unit/functions/version_check_test.php +++ /dev/null @@ -1,86 +0,0 @@ -version_data = array( - 'author' => 'Marc', - 'version' => 'board3_portal_version', - 'title' => 'Board3 Portal', - 'file' => array('board3.de', '/updatecheck', 'board3_portal.json'), - ); - $this->config = new \phpbb\config\config(array()); - $this->user = new \board3\portal\tests\mock\user; - $this->user->set(array( - 'NO_INFO' => 'NO_INFO', - 'NOT_UP_TO_DATE' => 'NOT_UP_TO_DATE', - 'UP_TO_DATE' => 'UP_TO_DATE', - )); - $this->cache = $this->getMockBuilder('\phpbb\cache\service') - ->disableOriginalConstructor() - ->getMock(); - } - - protected function get_version_helper($version) - { - global $phpbb_root_path; - - $this->config->set('board3_portal_version', $version); - - $this->template = new \board3\portal\tests\mock\template($this); - $this->language_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, 'php'); - $this->language = new \phpbb\language\language($this->language_file_loader); - $version_helper = new \phpbb\version_helper($this->cache, $this->config, new \phpbb\file_downloader(), new \phpbb\user($this->language, '\phpbb\datetime')); - $this->version_check = new \board3\portal\includes\version_check($this->version_data, $this->config, $version_helper, $this->template, $this->user); - } - - public function data_version_check() - { - return array( - array('2.1.0', array( - 'CURRENT_VERSION' => '2.1.0', - 'TITLE' => 'Board3 Portal', - 'UP_TO_DATE' => 'UP_TO_DATE', - 'S_UP_TO_DATE' => true, - 'LATEST_VERSION' => '2.1.0', - )), - array('2.1.0-a1', array( - 'CURRENT_VERSION' => '2.1.0-a1', - 'TITLE' => 'Board3 Portal', - 'UP_TO_DATE' => 'NOT_UP_TO_DATE', - 'S_UP_TO_DATE' => false, - 'LATEST_VERSION' => '2.1.0-rc2', - )), - ); - } - - /** - * @dataProvider data_version_check - */ - public function test_version_up_to_date($version, $template_data) - { - $this->get_version_helper($version); - $this->assertEquals($version, $this->version_check->check(true)); - $this->assertFalse($this->version_check->check()); - $this->template->assert_equals($template_data, 'mods'); - } -} diff --git a/tests/unit/includes/helper_test.php b/tests/unit/includes/helper_test.php index 2489d3e3..01c0a4fa 100644 --- a/tests/unit/includes/helper_test.php +++ b/tests/unit/includes/helper_test.php @@ -7,7 +7,6 @@ * */ - class board3_includes_helper_test extends \board3\portal\tests\testframework\test_case { protected $portal_helper; diff --git a/tests/unit/includes/modules_helper_test.php b/tests/unit/includes/modules_helper_test.php index 407741af..42e95190 100644 --- a/tests/unit/includes/modules_helper_test.php +++ b/tests/unit/includes/modules_helper_test.php @@ -7,6 +7,7 @@ * */ +require_once dirname(__FILE__) . '/../../../../../../includes/functions_admin.php'; class board3_includes_modules_helper_test extends \board3\portal\tests\testframework\database_test_case {