Skip to content

Commit e0a3495

Browse files
committed
Merge pull request #14 from VSEphpbb/updates-fixes
General fixes and updates for the Skeleton
2 parents 85f1a70 + f03915c commit e0a3495

26 files changed

Lines changed: 233 additions & 263 deletions

config/skeletons.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ services:
3232
- 'acp'
3333
- true
3434
- []
35-
- ['acp/main_info.php', 'acp/main_module.php', 'adm/style/demo_body.html', 'language/en/info_acp_demo.php']
35+
- ['acp/main_info.php', 'acp/main_module.php', 'adm/style/acp_demo_body.html', 'language/en/info_acp_demo.php']
3636
tags:
3737
- { name: phpbb.skeleton.ext.skeleton }
3838

@@ -42,7 +42,7 @@ services:
4242
- 'migration'
4343
- true
4444
- []
45-
- ['migrations/release_1_0_0.php', 'migrations/release_1_0_1.php']
45+
- ['migrations/install_module.php', 'migrations/install_user_schema.php']
4646
tags:
4747
- { name: phpbb.skeleton.ext.skeleton }
4848

@@ -66,13 +66,23 @@ services:
6666
tags:
6767
- { name: phpbb.skeleton.ext.skeleton }
6868

69+
phpbb.skeleton.ext.skeleton.ext:
70+
class: phpbb\skeleton\skeleton
71+
arguments:
72+
- 'ext'
73+
- true
74+
- []
75+
- ['ext.php']
76+
tags:
77+
- { name: phpbb.skeleton.ext.skeleton }
78+
6979
phpbb.skeleton.ext.skeleton.tests:
7080
class: phpbb\skeleton\skeleton
7181
arguments:
7282
- 'tests'
7383
- true
7484
- []
75-
- ['tests/controller/main_test.php', 'tests/dbal/fixtures/config.xml', 'tests/dbal/simple_test.php', 'tests/functional/demo_test.php', 'tests/mock/controller_helper.php', 'tests/mock/template.php', 'tests/mock/user.php', 'phpunit.xml.dist']
85+
- ['tests/controller/main_test.php', 'tests/dbal/fixtures/config.xml', 'tests/dbal/simple_test.php', 'tests/functional/demo_test.php', 'phpunit.xml.dist']
7686
tags:
7787
- { name: phpbb.skeleton.ext.skeleton }
7888

console/create.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ protected function configure()
5959
}
6060

6161
/**
62-
* Executes the command config:delete.
62+
* Executes the command extension:create.
6363
*
64-
* Removes a configuration option
64+
* Creates an extension skeleton
6565
*
6666
* @param InputInterface $input An InputInterface instance
6767
* @param OutputInterface $output An OutputInterface instance
@@ -70,16 +70,28 @@ protected function configure()
7070
* @see \phpbb\config\config::delete()
7171
*/
7272
protected function execute(InputInterface $input, OutputInterface $output)
73+
{
74+
$this->packager->create_extension($this->data);
75+
76+
$output->writeln($this->user->lang('EXTENSION_CLI_SKELETON_SUCCESS'));
77+
}
78+
79+
/**
80+
* Interacts with the user.
81+
*
82+
* @param InputInterface $input An InputInterface instance
83+
* @param OutputInterface $output An OutputInterface instance
84+
*/
85+
protected function interact(InputInterface $input, OutputInterface $output)
7386
{
7487
/** @var DialogHelper $dialog */
7588
$dialog = $this->getHelper('dialog');
7689

90+
$output->writeln($this->user->lang('SKELETON_CLI_COMPOSER_QUESTIONS'));
7791
$this->get_composer_data($dialog, $output);
78-
$this->get_component_data($dialog, $output);
7992

80-
$this->packager->create_extension($this->data);
81-
82-
$output->writeln($this->user->lang('EXTENSION_SKELETON_SUCCESS'));
93+
$output->writeln($this->user->lang('SKELETON_CLI_COMPONENT_QUESTIONS'));
94+
$this->get_component_data($dialog, $output);
8395
}
8496

8597
/**
@@ -96,7 +108,7 @@ protected function get_composer_data(DialogHelper $dialog, OutputInterface $outp
96108

97109
$num_authors = $dialog->askAndValidate(
98110
$output,
99-
$this->user->lang('SKELETON_QUESTION_NUM_AUTHORS'),
111+
$this->user->lang('SKELETON_QUESTION_NUM_AUTHORS') . $this->user->lang('COLON'),
100112
array($this->validator, 'validate_num_authors'),
101113
false,
102114
1
@@ -152,7 +164,7 @@ protected function get_user_input(DialogHelper $dialog, OutputInterface $output,
152164
{
153165
$return_value = $dialog->askAndValidate(
154166
$output,
155-
$this->user->lang('SKELETON_QUESTION_' . strtoupper($value)),
167+
$this->user->lang('SKELETON_QUESTION_' . strtoupper($value)) . $this->user->lang('COLON'),
156168
array($this->validator, 'validate_' . $value),
157169
false,
158170
$default
@@ -162,15 +174,15 @@ protected function get_user_input(DialogHelper $dialog, OutputInterface $output,
162174
{
163175
$return_value = $dialog->askConfirmation(
164176
$output,
165-
$this->user->lang('SKELETON_QUESTION_' . strtoupper($value)),
177+
$this->user->lang('SKELETON_QUESTION_' . strtoupper($value)) . $this->user->lang('COLON'),
166178
$default
167179
);
168180
}
169181
else
170182
{
171183
$return_value = $dialog->ask(
172184
$output,
173-
$this->user->lang('SKELETON_QUESTION_' . strtoupper($value)),
185+
$this->user->lang('SKELETON_QUESTION_' . strtoupper($value)) . $this->user->lang('COLON'),
174186
$default
175187
);
176188
}

controller/main.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,8 @@ public function handle()
149149
foreach ($components as $component => $details)
150150
{
151151
$this->template->assign_block_vars('component', array(
152-
'NAME' => $component,
152+
'NAME' => 'component_' . $component,
153153
'DESC' => $this->user->lang('SKELETON_QUESTION_COMPONENT_' . strtoupper($component) . '_UI'),
154-
'DESC_EXPLAIN' => isset($this->user->lang['SKELETON_QUESTION_COMPONENT_' . strtoupper($component) . '_EXPLAIN']) ? $this->user->lang('SKELETON_QUESTION_COMPONENT_' . strtoupper($component) . '_EXPLAIN') : '',
155154
'VALUE' => $this->request->variable('component_' . $component, $details['default']),
156155
));
157156

event/main_listener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ class main_listener implements EventSubscriberInterface
2626
static public function getSubscribedEvents()
2727
{
2828
return array(
29-
'core.user_setup' => 'load_language_on_setup',
30-
'core.page_header' => 'add_page_header_link',
29+
'core.user_setup' => 'load_language_on_setup',
30+
'core.page_header' => 'add_page_header_link',
3131
);
3232
}
3333

ext.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
*
4+
* @package phpBB Extension - Acme Demo
5+
* @copyright (c) 2013 phpBB Group
6+
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7+
*
8+
*/
9+
namespace phpbb\skeleton;
10+
11+
/**
12+
* Class ext
13+
*
14+
* It is recommended to remove this file from
15+
* an extension if it is not going to be used.
16+
*/
17+
class ext extends \phpbb\extension\base
18+
{
19+
/**
20+
* Check whether or not the extension can be enabled.
21+
* The current phpBB version should meet or exceed
22+
* the minimum version required by this extension:
23+
*
24+
* Requires phpBB 3.1.4
25+
*
26+
* @return bool
27+
* @access public
28+
*/
29+
public function is_enableable()
30+
{
31+
return phpbb_version_compare(PHPBB_VERSION, '3.1.4', '>=');
32+
}
33+
}
34+

helper/packager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ public function create_zip($data)
208208
{
209209
$zip_archive->addFile(
210210
$file->getRealPath(),
211-
$file->getRelativePath() . '/' . $file->getFilename()
211+
"{$data['extension']['vendor_name']}/{$data['extension']['extension_name']}/" . $file->getRelativePath() . '/' . $file->getFilename()
212212
);
213213
}
214214

language/en/common.php

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,34 @@
2222
}
2323

2424
$lang = array_merge($lang, array(
25-
'CLI_DESCRIPTION_SKELETON_CREATE' => 'A console command to create a basic extension',
25+
'CLI_DESCRIPTION_SKELETON_CREATE' => 'Create a basic skeleton extension',
2626
'PHPBB_SKELETON_EXT' => 'Create skeleton extension',
27-
'EXTENSION_SKELETON_SUCCESS' => 'Extension created successfully',
27+
28+
'EXTENSION_CLI_SKELETON_SUCCESS' => "<info>Extension created successfully.\nCopy the extension from `store/tmp-ext/` into the `ext/` folder.</info>",
29+
'SKELETON_CLI_COMPOSER_QUESTIONS' => '<comment>Enter the composer.json details (hit enter to leave an option empty)</comment>',
30+
'SKELETON_CLI_COMPONENT_QUESTIONS' => '<comment>Choose the components you’d like installed. Default: y; [y/n]</comment>',
2831

2932
'SKELETON_ADD_AUTHOR' => 'Add author',
3033
'SKELETON_QUESTION_VENDOR_NAME' => 'Please enter the vendor name',
3134
'SKELETON_QUESTION_VENDOR_NAME_UI' => 'Vendor name',
3235
'SKELETON_QUESTION_VENDOR_NAME_EXPLAIN' => 'Starting with a letter, letters and numbers only',
33-
'SKELETON_QUESTION_EXTENSION_DISPLAY_NAME' => 'Please enter the display (readable) name of your extension',
36+
'SKELETON_QUESTION_EXTENSION_DISPLAY_NAME' => 'Please enter the display (readable) name of the extension',
3437
'SKELETON_QUESTION_EXTENSION_DISPLAY_NAME_UI' => 'Display (readable) extension name',
35-
'SKELETON_QUESTION_EXTENSION_NAME' => 'Please enter the folder name of your extension',
36-
'SKELETON_QUESTION_EXTENSION_NAME_UI' => 'Folder name',
38+
'SKELETON_QUESTION_EXTENSION_NAME' => 'Please enter the folder (package) name of the extension',
39+
'SKELETON_QUESTION_EXTENSION_NAME_UI' => 'Folder (package) name',
3740
'SKELETON_QUESTION_EXTENSION_NAME_EXPLAIN' => 'Starting with a letter, letters and numbers only',
38-
'SKELETON_QUESTION_EXTENSION_DESCRIPTION' => 'Please enter the Description of your extension',
41+
'SKELETON_QUESTION_EXTENSION_DESCRIPTION' => 'Please enter the Description of the extension',
3942
'SKELETON_QUESTION_EXTENSION_DESCRIPTION_UI'=> 'Description',
40-
'SKELETON_QUESTION_EXTENSION_VERSION' => 'Please enter the version of your extension',
43+
'SKELETON_QUESTION_EXTENSION_VERSION' => 'Please enter the version of the extension',
4144
'SKELETON_QUESTION_EXTENSION_VERSION_UI' => 'Version',
4245
'SKELETON_QUESTION_EXTENSION_VERSION_EXPLAIN' => 'e.g. 1.0.0-dev',
43-
'SKELETON_QUESTION_EXTENSION_HOMEPAGE' => 'Please enter the homepage of your extension',
44-
'SKELETON_QUESTION_EXTENSION_HOMEPAGE_UI' => 'Homepage of your extension',
45-
'SKELETON_QUESTION_EXTENSION_TIME' => 'Please enter the date of your extension',
46-
'SKELETON_QUESTION_EXTENSION_TIME_UI' => 'Date of your extension',
46+
'SKELETON_QUESTION_EXTENSION_HOMEPAGE' => 'Please enter the homepage of the extension',
47+
'SKELETON_QUESTION_EXTENSION_HOMEPAGE_UI' => 'Homepage of the extension',
48+
'SKELETON_QUESTION_EXTENSION_TIME' => 'Please enter the date of the extension',
49+
'SKELETON_QUESTION_EXTENSION_TIME_UI' => 'Date of the extension',
4750
'SKELETON_QUESTION_EXTENSION_TIME_EXPLAIN' => 'YYYY-MM-DD, default: today',
4851

49-
'SKELETON_QUESTION_NUM_AUTHORS' => 'How many authors does your extension have',
52+
'SKELETON_QUESTION_NUM_AUTHORS' => 'How many authors does the extension have',
5053
'SKELETON_QUESTION_NUM_AUTHORS_EXPLAIN' => 'default: 1',
5154

5255
'SKELETON_QUESTION_AUTHOR_NAME' => 'Please enter the author name',
@@ -59,43 +62,41 @@
5962
'SKELETON_QUESTION_AUTHOR_ROLE' => 'Please enter the author role',
6063
'SKELETON_QUESTION_AUTHOR_ROLE_UI' => 'Author role',
6164

62-
'SKELETON_QUESTION_PHP_VERSION' => 'Please enter the php requirement of your extension',
63-
'SKELETON_QUESTION_PHP_VERSION_UI' => 'php requirement of your extension',
64-
'SKELETON_QUESTION_PHP_VERSION_EXPLAIN' => 'default: >=5.3.3',
65-
'SKELETON_QUESTION_PHPBB_VERSION_MIN' => 'Please enter the minimum phpBB requirement of your extension',
66-
'SKELETON_QUESTION_PHPBB_VERSION_MIN_UI' => 'Minimum phpBB requirement of your extension',
67-
'SKELETON_QUESTION_PHPBB_VERSION_MIN_EXPLAIN' => 'default: >=3.1.4',
68-
'SKELETON_QUESTION_PHPBB_VERSION_MAX' => 'Please enter the maximum phpBB requirement of your extension',
69-
'SKELETON_QUESTION_PHPBB_VERSION_MAX_UI' => 'Maximum phpBB requirement of your extension',
70-
'SKELETON_QUESTION_PHPBB_VERSION_MAX_EXPLAIN' => 'default: <3.2.0@dev',
65+
'SKELETON_QUESTION_PHP_VERSION' => 'Please enter the PHP requirement of the extension',
66+
'SKELETON_QUESTION_PHP_VERSION_UI' => 'PHP requirement of the extension',
67+
'SKELETON_QUESTION_PHP_VERSION_EXPLAIN' => 'default: &gt;=5.3.3',
68+
'SKELETON_QUESTION_PHPBB_VERSION_MIN' => 'Please enter the minimum phpBB requirement of the extension',
69+
'SKELETON_QUESTION_PHPBB_VERSION_MIN_UI' => 'Minimum phpBB requirement of the extension',
70+
'SKELETON_QUESTION_PHPBB_VERSION_MIN_EXPLAIN' => 'default: &gt;=3.1.4',
71+
'SKELETON_QUESTION_PHPBB_VERSION_MAX' => 'Please enter the maximum phpBB requirement of the extension',
72+
'SKELETON_QUESTION_PHPBB_VERSION_MAX_UI' => 'Maximum phpBB requirement of the extension',
73+
'SKELETON_QUESTION_PHPBB_VERSION_MAX_EXPLAIN' => 'default: &lt;3.2.0@dev',
7174

72-
'SKELETON_QUESTION_COMPONENT_PHPLISTENER' => 'Should we add a sample for php listeners',
73-
'SKELETON_QUESTION_COMPONENT_PHPLISTENER_UI' => 'php listeners',
74-
'SKELETON_QUESTION_COMPONENT_PHPLISTENER_EXPLAIN' => 'default: y; [y/n]',
75-
'SKELETON_QUESTION_COMPONENT_HTMLLISTENER' => 'Should we add a sample for styles listeners',
75+
'SKELETON_QUESTION_COMPONENT_PHPLISTENER' => 'Create sample PHP listeners?',
76+
'SKELETON_QUESTION_COMPONENT_PHPLISTENER_UI' => 'PHP listeners',
77+
'SKELETON_QUESTION_COMPONENT_HTMLLISTENER' => 'Create sample styles listeners?',
7678
'SKELETON_QUESTION_COMPONENT_HTMLLISTENER_UI' => 'Styles listeners',
77-
'SKELETON_QUESTION_COMPONENT_HTMLLISTENER_EXPLAIN' => 'default: y; [y/n]',
78-
'SKELETON_QUESTION_COMPONENT_ACP' => 'Should we add a sample for a administration module',
79+
'SKELETON_QUESTION_COMPONENT_ACP' => 'Create a sample ACP administration module?',
7980
'SKELETON_QUESTION_COMPONENT_ACP_UI' => 'Administration module (ACP)',
80-
'SKELETON_QUESTION_COMPONENT_ACP_EXPLAIN' => 'default: y; [y/n]',
81-
'SKELETON_QUESTION_COMPONENT_MIGRATION' => 'Should we add a sample for a database migration',
81+
'SKELETON_QUESTION_COMPONENT_MIGRATION' => 'Create sample database migrations?',
8282
'SKELETON_QUESTION_COMPONENT_MIGRATION_UI' => 'Database migration',
83-
'SKELETON_QUESTION_COMPONENT_MIGRATION_EXPLAIN' => 'default: y; [y/n]',
84-
'SKELETON_QUESTION_COMPONENT_SERVICE' => 'Should we add a sample for a service',
83+
'SKELETON_QUESTION_COMPONENT_SERVICE' => 'Create a sample service?',
8584
'SKELETON_QUESTION_COMPONENT_SERVICE_UI' => 'Service',
86-
'SKELETON_QUESTION_COMPONENT_SERVICE_EXPLAIN' => 'default: y; [y/n]',
87-
'SKELETON_QUESTION_COMPONENT_CONTROLLER' => 'Should we add a sample for a controller',
85+
'SKELETON_QUESTION_COMPONENT_CONTROLLER' => 'Create a sample controller?',
8886
'SKELETON_QUESTION_COMPONENT_CONTROLLER_UI' => 'Controller (frontpage)',
89-
'SKELETON_QUESTION_COMPONENT_CONTROLLER_EXPLAIN'=> 'default: y; [y/n]',
90-
'SKELETON_QUESTION_COMPONENT_TESTS' => 'Should we add a sample for a phpunit tests',
91-
'SKELETON_QUESTION_COMPONENT_TESTS_UI' => 'phpunit tests',
92-
'SKELETON_QUESTION_COMPONENT_TESTS_EXPLAIN' => 'default: y; [y/n]',
93-
'SKELETON_QUESTION_COMPONENT_TRAVIS' => 'Should we add a sample for test execution on Travis CI',
94-
'SKELETON_QUESTION_COMPONENT_TRAVIS_UI' => 'Test execution on Travis CI',
95-
'SKELETON_QUESTION_COMPONENT_TRAVIS_EXPLAIN' => 'default: y; [y/n]',
96-
'SKELETON_QUESTION_COMPONENT_BUILD' => 'Should we add a sample script to building packages for the customisation database',
97-
'SKELETON_QUESTION_COMPONENT_BUILD_UI' => 'Script to building packages for the customisation database',
98-
'SKELETON_QUESTION_COMPONENT_BUILD_EXPLAIN' => 'default: n; [y/n]',
87+
'SKELETON_QUESTION_COMPONENT_EXT' => 'Create a sample ext.php?',
88+
'SKELETON_QUESTION_COMPONENT_EXT_UI' => 'Extension base (ext.php)',
89+
'SKELETON_QUESTION_COMPONENT_TESTS' => 'Create sample PHPUnit tests?',
90+
'SKELETON_QUESTION_COMPONENT_TESTS_UI' => 'PHPUnit tests',
91+
'SKELETON_QUESTION_COMPONENT_TRAVIS' => 'Create a sample for test execution on Travis-CI?',
92+
'SKELETON_QUESTION_COMPONENT_TRAVIS_UI' => 'Test execution on Travis-CI',
93+
'SKELETON_QUESTION_COMPONENT_BUILD' => 'Create a sample script to build packages for the customisation database?',
94+
'SKELETON_QUESTION_COMPONENT_BUILD_UI' => 'Script to build packages for the customisation database',
95+
96+
'SKELETON_TITLE_EXTENSION_INFO' => 'Extension packaging',
97+
'SKELETON_TITLE_AUTHOR_INFO' => 'Authors',
98+
'SKELETON_TITLE_REQUIREMENT_INFO' => 'Requirements',
99+
'SKELETON_TITLE_COMPONENT_INFO' => 'Components',
99100

100101
'SKELETON_INVALID_EXTENSION_NAME' => 'The extension name you provided is invalid',
101102
'SKELETON_INVALID_EXTENSION_TIME' => 'The extension date you provided is invalid',

skeleton/.travis.yml.tpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
sudo: required
2+
13
language: php
24

35
matrix:

skeleton/acp/main_info.php.tpl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,12 @@ class main_info
2020
return array(
2121
'filename' => '\{EXTENSION.vendor_name}\{EXTENSION.extension_name}\acp\main_module',
2222
'title' => 'ACP_DEMO_TITLE',
23-
'version' => '1.0.0',
2423
'modes' => array(
25-
'settings' => array('title' => 'ACP_DEMO', 'auth' => 'ext_{EXTENSION.vendor_name}/{EXTENSION.extension_name} && acl_a_board', 'cat' => array('ACP_DEMO_TITLE')),
24+
'settings' => array(
25+
'title' => 'ACP_DEMO',
26+
'auth' => 'ext_{EXTENSION.vendor_name}/{EXTENSION.extension_name} && acl_a_board',
27+
'cat' => array('ACP_DEMO_TITLE')
28+
),
2629
),
2730
);
2831
}

skeleton/acp/main_module.php.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class main_module
1919
2020
function main($id, $mode)
2121
{
22-
global $user, $template, $request, $config;
22+
global $config, $request, $template, $user;
2323
2424
$user->add_lang('acp/common');
25-
$this->tpl_name = 'demo_body';
25+
$this->tpl_name = 'acp_demo_body';
2626
$this->page_title = $user->lang('ACP_DEMO_TITLE');
2727
add_form_key('acme/demo');
2828

0 commit comments

Comments
 (0)