Skip to content

Remove outdated code #160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 29, 2025
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
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
],
"require": {
"php": ">=5.6",
"composer/installers": "~1.0"
"composer/installers": "~1.0",
"ext-zip": "*"
},
"require-dev": {
"phing/phing": "~2.4"
Expand Down
31 changes: 19 additions & 12 deletions helper/packager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use phpbb\config\config;
use phpbb\di\service_collection;
use phpbb\filesystem\filesystem;
use phpbb\path_helper;
use phpbb\skeleton\ext;
use phpbb\skeleton\template\twig\extension\skeleton_version_compare;
use phpbb\template\context;
Expand Down Expand Up @@ -115,17 +116,14 @@ public function create_extension($data)
$filesystem->remove($this->root_path . 'store/tmp-ext');
$filesystem->mkdir($ext_path);

$phpbb31 = (bool) preg_match('/^[\D]*3\.1.*$/', $data['requirements']['phpbb_version_min']);

$template = $this->get_template_engine();
$template->set_custom_style('skeletonextension', $this->root_path . 'ext/phpbb/skeleton/skeleton');
$template->assign_vars([
'COMPONENT' => $data['components'],
'EXTENSION' => $data['extension'],
'REQUIREMENTS' => $data['requirements'],
'AUTHORS' => $data['authors'],
'LANGUAGE' => $this->get_language_version_data($phpbb31),
'S_PHPBB_31' => $phpbb31,
'LANGUAGE' => $this->get_language_version_data($data),
]);

$component_data = $this->get_component_dialog_values();
Expand Down Expand Up @@ -201,10 +199,13 @@ protected function get_template_engine()
'assets_version' => null,
]);

/** @var path_helper $path_helper */
$path_helper = $this->phpbb_container->get('path_helper');
/** @var filesystem $filesystem */
$filesystem = $this->phpbb_container->get('filesystem');
$environment = new environment(
$config,
$this->phpbb_container->get('filesystem'),
$filesystem,
$path_helper,
$this->phpbb_container->getParameter('core.cache_dir'),
$this->phpbb_container->get('ext.manager'),
Expand Down Expand Up @@ -236,19 +237,25 @@ protected function get_template_engine()
* Get an array of language class and methods depending on 3.1 or 3.2
* compatibility, for use in the skeleton twig templates.
*
* @param bool $phpbb31 Is phpBB 3.1 support requested?
* @param array $data Extension data
*
* @return array An array of language data
*/
protected function get_language_version_data($phpbb31)
protected function get_language_version_data($data)
{
$phpbb_31 = false;
if (isset($data['requirements']['phpbb_version_min']))
{
$phpbb_31 = (bool) preg_match('/^\D*3\.1.*$/', $data['requirements']['phpbb_version_min']);
}

return [
'class' => $phpbb31 ? '\phpbb\user' : '\phpbb\language\language',
'object' => $phpbb31 ? 'user' : 'language',
'function' => $phpbb31 ? 'add_lang_ext' : 'add_lang',
'class' => $phpbb_31 ? '\phpbb\user' : '\phpbb\language\language',
'object' => $phpbb_31 ? 'user' : 'language',
'function' => $phpbb_31 ? 'add_lang_ext' : 'add_lang',
'indent' => [
'class' => $phpbb31 ? "\t\t\t" : '',
'object' => $phpbb31 ? "\t" : '',
'class' => $phpbb_31 ? "\t\t\t" : '',
'object' => $phpbb_31 ? "\t" : '',
],
];
}
Expand Down
2 changes: 1 addition & 1 deletion language/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_EXPLAIN' => 'Creates a GitHub Actions workflow that uses a reusable, phpBB-maintained framework to run PHPUnit tests on your repository. The workflow file is saved in .github/workflows and runs automatically on each commit and pull request.',
'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM' => 'Create a standalone GitHub Actions workflow [Deprecated: not recommended unless you plan to modify jobs or steps]',
'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM_UI' => 'GitHub Actions Workflow (Standalone – Deprecated)',
'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM_EXPLAIN' => 'Deprecated: Creates a fully standalone workflow to run PHPUnit tests without using the shared phpBB framework. This overrides the reusable workflow and is no longer recommended. The file is saved in .github/workflows and runs on each commit and pull request.',
'SKELETON_QUESTION_COMPONENT_GITHUBACTIONS_CUSTOM_EXPLAIN' => 'Deprecated: Creates a standalone workflow for PHPUnit tests without the shared phpBB framework. Will be overridden if the reusable workflow is also selected. Saved in .github/workflows and runs on each commit and pull request.',
'SKELETON_QUESTION_COMPONENT_BUILD' => 'Create a sample build script for phing',
'SKELETON_QUESTION_COMPONENT_BUILD_UI' => 'Build script (phing)',
'SKELETON_QUESTION_COMPONENT_BUILD_EXPLAIN' => 'A phing build script is generated for your extension which can be used to generate build packages to help simplify the release or deployment processes.',
Expand Down
72 changes: 36 additions & 36 deletions skeleton/.github/workflows/tests.yml.twig
Original file line number Diff line number Diff line change
@@ -1,6 +1,41 @@
name: Tests

{% if COMPONENT.githubactions_custom %}
{% if COMPONENT.githubactions %}
# For most extensions, this workflow should not need changing;
# simply commit it to your repository.
#
# See the README for full details and configuration instructions:
# - https://github.com/phpbb-extensions/test-framework
#
on:
push:
# Run tests when commits are pushed to these branches in your repo,
# or remove this branches section to run tests on all your branches
branches:
- main # Main production branch
- master # Legacy or alternative main branch
- dev/* # Any feature branches under "dev/", e.g., dev/new-feature
- release-* # Any release branches under "release-", e.g., release-1.0.0

pull_request:
# Run tests when pull requests are made on these branches in your repo,
# or remove this branches section to run tests on all your branches
branches:
- main
- master
- dev/*

jobs:
call-tests:
name: Extension tests
# Set the phpBB branch to test your extension with after the @ symbol
# - 3.3.x: Targets the phpBB 3.3.x release line
# - master: Targets the latest development version of phpBB (master branch)
uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@{{ skeleton_version_compare(REQUIREMENTS.phpbb_version_min, "4.0", "<") ? '3.3.x' : 'master' }}
with:
# Your extension vendor/package name
EXTNAME: {{ EXTENSION.vendor_name }}/{{ EXTENSION.extension_name }}
{% elseif COMPONENT.githubactions_custom %}
env:
EXTNAME: {{ EXTENSION.vendor_name }}/{{ EXTENSION.extension_name }} # Your extension vendor/package name
SNIFF: 1 # Run code sniffer on your code? 1 or 0
Expand Down Expand Up @@ -425,39 +460,4 @@ jobs:
run: phpBB/vendor/bin/phpunit --configuration phpBB/ext/$EXTNAME/.github/phpunit-$DB-github.xml --bootstrap ./tests/bootstrap.php
working-directory: ./phpBB3
# END Other Tests Job
{% else %}
# For most extensions, this workflow should not need changing;
# simply commit it to your repository.
#
# See the README for full details and configuration instructions:
# - https://github.com/phpbb-extensions/test-framework
#
on:
push:
# Run tests when commits are pushed to these branches in your repo,
# or remove this branches section to run tests on all your branches
branches:
- main # Main production branch
- master # Legacy or alternative main branch
- dev/* # Any feature branches under "dev/", e.g., dev/new-feature
- release-* # Any release branches under "release-", e.g., release-1.0.0

pull_request:
# Run tests when pull requests are made on these branches in your repo,
# or remove this branches section to run tests on all your branches
branches:
- main
- master
- dev/*

jobs:
call-tests:
name: Extension tests
# Set the phpBB branch to test your extension with after the @ symbol
# - 3.3.x: Targets the phpBB 3.3.x release line
# - master: Targets the latest development version of phpBB (master branch)
uses: phpbb-extensions/test-framework/.github/workflows/tests.yml@{{ skeleton_version_compare(REQUIREMENTS.phpbb_version_min, "4.0", "<") ? '3.3.x' : 'master' }}
with:
# Your extension vendor/package name
EXTNAME: {{ EXTENSION.vendor_name }}/{{ EXTENSION.extension_name }}
{% endif %}
29 changes: 9 additions & 20 deletions skeleton/README.md.twig
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
# {{ EXTENSION.extension_display_name }}

## Installation

Copy the extension to phpBB/ext/{{ EXTENSION.vendor_name }}/{{ EXTENSION.extension_name }}

Go to "ACP" > "Customise" > "Extensions" and enable the "{{ EXTENSION.extension_display_name }}" extension.

{% if COMPONENT.tests %}
## Tests and Continuous Integration
This is a basic skeleton to help you start building a phpBB extension. Customise it as needed.

{% if COMPONENT.githubactions %}We use GitHub Actions as a continuous integration server and phpunit for our unit testing..{% endif %}
To run the tests locally, you need to install phpBB from its Git repository. Afterward run the following command from the phpBB Git repository's root:

Windows:

phpBB\vendor\bin\phpunit.bat -c phpBB\ext\{{ EXTENSION.vendor_name }}\{{ EXTENSION.extension_name }}\phpunit.xml.dist

others:
## Installation

phpBB/vendor/bin/phpunit -c phpBB/ext/{{ EXTENSION.vendor_name }}/{{ EXTENSION.extension_name }}/phpunit.xml.dist
1. Copy the extension to: `phpBB/ext/{{ EXTENSION.vendor_name }}/{{ EXTENSION.extension_name }}`
2. In the ACP, go to: **Customise → Manage extensions**
3. Enable the **{{ EXTENSION.extension_display_name }}** extension

## Extension Development Guide

See more information on the [phpBB Developer Docs](https://area51.phpbb.com/docs/dev/master/testing/index.html)
New to phpBB extension development?
Start here: [phpBB Extension Development Guide](https://area51.phpbb.com/docs/dev/3.3.x/extensions/index.html)

{% endif %}
## License

[GNU General Public License v2](license.txt)
Licensed under the [GNU General Public License v2](license.txt)
10 changes: 6 additions & 4 deletions skeleton/adm/style/acp_demo_body.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
<legend>{{ '{{' }} lang('SETTINGS') }}</legend>
<dl>
<dt><label for="{{ EXTENSION.vendor_name|lower }}_{{ EXTENSION.extension_name|lower }}_goodbye">{{ '{{' }} lang('ACP_{{ EXTENSION.extension_name|upper }}_GOODBYE') ~ lang('COLON') }}</label></dt>
<dd><label><input type="radio" class="radio" name="{{ EXTENSION.vendor_name|lower }}_{{ EXTENSION.extension_name|lower }}_goodbye" value="1"{{ '{' }}% if {{ EXTENSION.vendor_name|upper }}_{{ EXTENSION.extension_name|upper }}_GOODBYE %} checked="checked"{{ '{' }}% endif %} /> {{ '{{' }} lang('YES') }}</label>
<label><input type="radio" class="radio" name="{{ EXTENSION.vendor_name|lower }}_{{ EXTENSION.extension_name|lower }}_goodbye" value="0"{{ '{' }}% if not {{ EXTENSION.vendor_name|upper }}_{{ EXTENSION.extension_name|upper }}_GOODBYE %} checked="checked"{{ '{' }}% endif %} /> {{ '{{' }} lang('NO') }}</label></dd>
<dd>
<label><input type="radio" class="radio" name="{{ EXTENSION.vendor_name|lower }}_{{ EXTENSION.extension_name|lower }}_goodbye" value="1"{{ '{' }}% if {{ EXTENSION.vendor_name|upper }}_{{ EXTENSION.extension_name|upper }}_GOODBYE %} checked="checked"{{ '{' }}% endif %}> {{ '{{' }} lang('YES') }}</label>
<label><input type="radio" class="radio" name="{{ EXTENSION.vendor_name|lower }}_{{ EXTENSION.extension_name|lower }}_goodbye" value="0"{{ '{' }}% if not {{ EXTENSION.vendor_name|upper }}_{{ EXTENSION.extension_name|upper }}_GOODBYE %} checked="checked"{{ '{' }}% endif %}> {{ '{{' }} lang('NO') }}</label>
</dd>
</dl>
</fieldset>

<fieldset class="submit-buttons">
<input class="button1" type="submit" id="submit" name="submit" value="{{ '{{' }} lang('SUBMIT') }}" />&nbsp;
<input class="button2" type="submit" id="preview" name="preview" value="{{ '{{' }} lang('PREVIEW') }}" />
<input class="button1" type="submit" id="submit" name="submit" value="{{ '{{' }} lang('SUBMIT') }}">&nbsp;
<input class="button2" type="submit" id="preview" name="preview" value="{{ '{{' }} lang('PREVIEW') }}">
{{ '{{' }} S_FORM_TOKEN }}
</fieldset>

Expand Down
2 changes: 1 addition & 1 deletion skeleton/controller/acp_controller.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class acp_controller
// Set output variables for display in the template
$this->template->assign_vars([
'S_ERROR' => $s_errors,
'ERROR_MSG' => $s_errors ? implode('<br />', $errors) : '',
'ERROR_MSG' => $s_errors ? implode('<br>', $errors) : '',

'U_ACTION' => $this->u_action,

Expand Down
2 changes: 1 addition & 1 deletion skeleton/controller/mcp_controller.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class mcp_controller
// Set output variables for display in the template
$this->template->assign_vars([
'S_ERROR' => $s_errors,
'ERROR_MSG' => $s_errors ? implode('<br />', $errors) : '',
'ERROR_MSG' => $s_errors ? implode('<br>', $errors) : '',

'U_MCP_ACTION' => $this->u_action,
]);
Expand Down
4 changes: 2 additions & 2 deletions skeleton/controller/ucp_controller.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class ucp_controller
// Option settings have been updated
// Confirm this to the user and provide (automated) link back to previous page
meta_refresh(3, $this->u_action);
$message = $this->{{ LANGUAGE.object }}->lang('UCP_{{ EXTENSION.extension_name|upper }}_SAVED') . '<br /><br />' . $this->{{ LANGUAGE.object }}->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
$message = $this->{{ LANGUAGE.object }}->lang('UCP_{{ EXTENSION.extension_name|upper }}_SAVED') . '<br><br>' . $this->{{ LANGUAGE.object }}->lang('RETURN_UCP', '<a href="' . $this->u_action . '">', '</a>');
trigger_error($message);
}
}
Expand All @@ -106,7 +106,7 @@ class ucp_controller
// Set output variables for display in the template
$this->template->assign_vars([
'S_ERROR' => $s_errors,
'ERROR_MSG' => $s_errors ? implode('<br />', $errors) : '',
'ERROR_MSG' => $s_errors ? implode('<br>', $errors) : '',

'U_UCP_ACTION' => $this->u_action,

Expand Down
7 changes: 6 additions & 1 deletion skeleton/event/main_listener.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
*/
class main_listener implements EventSubscriberInterface
{
/**
* Map phpBB core events to the listener methods that should handle those events
*
* @return array
*/
public static function getSubscribedEvents()
{
return [
Expand All @@ -34,7 +39,7 @@ class main_listener implements EventSubscriberInterface
'core.display_forums_modify_template_vars' => 'display_forums_modify_template_vars',
{% endif %}
{% if COMPONENT.permissions %}
'core.permissions' => 'add_permissions',
'core.permissions' => 'add_permissions',
{% endif %}
];
}
Expand Down
4 changes: 2 additions & 2 deletions skeleton/migrations/install_sample_data.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class install_sample_data extends \phpbb\db\migration\migration
/**
* Add, update or delete data stored in the database during extension installation.
*
* https://area51.phpbb.com/docs/dev/3.2.x/migrations/data_changes.html
* https://area51.phpbb.com/docs/dev/3.3.x/migrations/data_changes.html
{% if COMPONENT.migration %}
* config.add: Add config data.
* config.update: Update config data.
Expand Down Expand Up @@ -99,7 +99,7 @@ class install_sample_data extends \phpbb\db\migration\migration
* and only needs to be used to perform custom un-installation changes, such as to revert
* changes made by custom functions called in update_data.
*
* https://area51.phpbb.com/docs/dev/3.2.x/migrations/data_changes.html
* https://area51.phpbb.com/docs/dev/3.3.x/migrations/data_changes.html
* config.add: Add config data.
* config.update: Update config data.
* config.remove: Remove config.
Expand Down
4 changes: 2 additions & 2 deletions skeleton/migrations/install_sample_schema.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class install_sample_schema extends \phpbb\db\migration\migration
/**
* Update database schema.
*
* https://area51.phpbb.com/docs/dev/3.2.x/migrations/schema_changes.html
* https://area51.phpbb.com/docs/dev/3.3.x/migrations/schema_changes.html
* add_tables: Add tables
* drop_tables: Drop tables
* add_columns: Add columns to a table
Expand Down Expand Up @@ -69,7 +69,7 @@ class install_sample_schema extends \phpbb\db\migration\migration
* Revert database schema changes. This method is almost always required
* to revert the changes made above by update_schema.
*
* https://area51.phpbb.com/docs/dev/3.2.x/migrations/schema_changes.html
* https://area51.phpbb.com/docs/dev/3.3.x/migrations/schema_changes.html
* add_tables: Add tables
* drop_tables: Drop tables
* add_columns: Add columns to a table
Expand Down
6 changes: 3 additions & 3 deletions skeleton/styles/prosilver/template/mcp_demo_body.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@

<dl>
<dt><label for="username">{{ '{{' }} lang('SELECT_USER') ~ lang('COLON') }}</label></dt>
<dd><input name="username" id="username" type="text" class="inputbox" /></dd>
<dd><input name="username" id="username" type="text" class="inputbox"></dd>
</dl>
</fieldset>
</div>
</div>

<fieldset class="submit-buttons">
<input type="reset" name="reset" value="{{ '{{' }} lang('RESET') }}" class="button2" />&nbsp;
<input type="submit" name="submit" value="{{ '{{' }} lang('SUBMIT') }}" class="button1" />
<input type="reset" name="reset" value="{{ '{{' }} lang('RESET') }}" class="button2">&nbsp;
<input type="submit" name="submit" value="{{ '{{' }} lang('SUBMIT') }}" class="button1">
{{ '{{' }} S_FORM_TOKEN }}
</fieldset>
</form>
Expand Down
14 changes: 9 additions & 5 deletions skeleton/styles/prosilver/template/ucp_demo_body.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,22 @@
{{ '{' }}% endif %}

<dl>
<dt><label for="user_{{ EXTENSION.extension_name|lower }}0">{{ '{{' }} lang('UCP_{{ EXTENSION.extension_name|upper }}_USER') ~ lang('COLON') }}</label><br /><span>{{ '{{' }} lang('UCP_{{ EXTENSION.extension_name|upper }}_USER_EXPLAIN') }}</span></dt>
<dd><label for="user_{{ EXTENSION.extension_name|lower }}1"><input type="radio" name="user_{{ EXTENSION.extension_name|lower }}" id="user_{{ EXTENSION.extension_name|lower }}1" value="1"{{ '{' }}% if S_USER_{{ EXTENSION.extension_name|upper }} %} checked="checked"{{ '{' }}% endif %} /> {{ '{{' }} lang('YES') }}</label>
<label for="user_{{ EXTENSION.extension_name|lower }}0"><input type="radio" name="user_{{ EXTENSION.extension_name|lower }}" id="user_{{ EXTENSION.extension_name|lower }}0" value="0"{{ '{' }}% if not S_USER_{{ EXTENSION.extension_name|upper }} %} checked="checked"{{ '{' }}% endif %} /> {{ '{{' }} lang('NO') }}</label></dd>
<dt><label for="user_{{ EXTENSION.extension_name|lower }}0">{{ '{{' }} lang('UCP_{{ EXTENSION.extension_name|upper }}_USER') ~ lang('COLON') }}</label><br><span>{{ '{{' }} lang('UCP_{{ EXTENSION.extension_name|upper }}_USER_EXPLAIN') }}</span></dt>
<dd>
<label for="user_{{ EXTENSION.extension_name|lower }}1"><input type="radio" name="user_{{ EXTENSION.extension_name|lower }}" id="user_{{ EXTENSION.extension_name|lower }}1" value="1"{{ '{' }}% if S_USER_{{ EXTENSION.extension_name|upper }} %} checked="checked"{{ '{' }}% endif %}> {{ '{{' }} lang('YES') }}</label>
<label for="user_{{ EXTENSION.extension_name|lower }}0"><input type="radio" name="user_{{ EXTENSION.extension_name|lower }}" id="user_{{ EXTENSION.extension_name|lower }}0" value="0"{{ '{' }}% if not S_USER_{{ EXTENSION.extension_name|upper }} %} checked="checked"{{ '{' }}% endif %}> {{ '{{' }} lang('NO') }}</label>
</dd>
</dl>
</fieldset>
</div>
</div>
<fieldset>
<dl>
<dt>&nbsp;</dt>
<dd><input type="submit" name="submit" id="submit" class="button1" value="{{ '{{' }} lang('SUBMIT') }}" tabindex="2" />&nbsp;
<input type="reset" name="reset" class="button2" value="{{ '{{' }} lang('RESET') }}" /></dd>
<dd>
<input type="submit" name="submit" id="submit" class="button1" value="{{ '{{' }} lang('SUBMIT') }}" tabindex="2">&nbsp;
<input type="reset" name="reset" class="button2" value="{{ '{{' }} lang('RESET') }}">
</dd>
</dl>
{{ '{{' }} S_HIDDEN_FIELDS }}
{{ '{{' }} S_FORM_TOKEN }}
Expand Down
8 changes: 4 additions & 4 deletions skeleton/tests/controller/main_test.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class main_test extends \phpbb_test_case
->getMock();

// Set the expected output of the controller_helper->render() method
$controller_helper->expects(self::once())
$controller_helper->expects($this->once())
->method('render')
->willReturnCallback(function ($template_file, $page_title = '', $status_code = 200, $display_online_list = false) {
return new \Symfony\Component\HttpFoundation\Response($template_file, $status_code);
Expand All @@ -70,8 +70,8 @@ class main_test extends \phpbb_test_case
);

$response = $controller->handle('test');
self::assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response);
self::assertEquals($status_code, $response->getStatusCode());
self::assertEquals($page_content, $response->getContent());
$this->assertInstanceOf('\Symfony\Component\HttpFoundation\Response', $response);
$this->assertEquals($status_code, $response->getStatusCode());
$this->assertEquals($page_content, $response->getContent());
}
}
Loading