Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ A simple dropdown navigation menu for your board; the links are edited by hand i

## Requirements

- phpBB 3.3.0 or later
- phpBB 3.3.19 or later
- PHP 7.4 or later

## Installation
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"extra": {
"display-name": "phpBB Modders Menu",
"soft-require": {
"phpbb/phpbb": ">=3.3.0,<4.0.0@dev"
"phpbb/phpbb": ">=3.3.19,<4.0.0@dev"
}
}
}
32 changes: 31 additions & 1 deletion ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,23 @@ class ext extends \phpbb\extension\base
const OLD_EXT_NAME = 'modders/menu';

/**
* Refuse to enable below the minimum phpBB and PHP versions.
*
* Refuse to enable while the old copy is still enabled, otherwise both
* would add the menu to every page.
*
* @return bool|array True if enableable, otherwise an array of reasons
* @return bool|string|array True if enableable, otherwise a reason string or array of reasons
*/
public function is_enableable()
{
if (!$this->check_phpbb_version() || !$this->check_php_version())
{
$language = $this->container->get('language');
$language->add_lang('install_menu', 'phpbbmodders/menu');

return $language->lang('MENU_NOT_ENABLEABLE');
}

$ext_manager = $this->container->get('ext.manager');

if ($ext_manager->is_enabled(self::OLD_EXT_NAME))
Expand All @@ -38,6 +48,26 @@ public function is_enableable()
return true;
}

/**
* Require phpBB 3.3.19
*
* @return bool
*/
public function check_phpbb_version()
{
return phpbb_version_compare(PHPBB_VERSION, '3.3.19', '>=');
}

/**
* Require PHP 7.4
*
* @return bool
*/
public function check_php_version()
{
return PHP_VERSION_ID >= 70400;
}

/**
* Remove the disabled old "modders/menu" record so it doesn't linger in
* the extension list after the rename, then enable as usual.
Expand Down
42 changes: 42 additions & 0 deletions language/en/install_menu.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
*
* phpBB Modders Menu extension for the phpBB Forum Software package
*
* @copyright (c) 2024, phpBB Modders, https://www.phpbbmodders.com/
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/

/**
* DO NOT CHANGE
*/
if (!defined('IN_PHPBB'))
{
exit;
}

if (empty($lang) || !is_array($lang))
{
$lang = [];
}

// DEVELOPERS PLEASE NOTE
//
// All language files should use UTF-8 as their encoding and the files must not contain a BOM.
//
// Placeholders can now contain order information, e.g. instead of
// 'Page %s of %s' you can (and should) write 'Page %1$s of %2$s', this allows
// translators to re-order the output of data while ensuring it remains correct
//
// You do not need this where single placeholders are used, e.g. 'Message %d' is fine
// equally where a string contains only two placeholders which are used to wrap text
// in a url you again do not need to specify an order e.g., 'Click %sHERE%s' is fine
//
// Some characters you may want to copy&paste:
// ’ » “ ” …
//

$lang = array_merge($lang, [
'MENU_NOT_ENABLEABLE' => 'phpBB Modders Menu could not be enabled. The minimum requirements of phpBB 3.3.19 and/or PHP 7.4.0 were not satisfied.',
]);
Loading