diff --git a/phpBB/adm/style/acp_ext_gallery.html b/phpBB/adm/style/acp_ext_gallery.html index 9be59429f6..f9cdad34ff 100644 --- a/phpBB/adm/style/acp_ext_gallery.html +++ b/phpBB/adm/style/acp_ext_gallery.html @@ -45,7 +45,7 @@ {{ extension.name }}
- {{ lang('DETAILS') }}{{ lang('INSTALL') }} + {{ lang('DETAILS') }}{{ lang('INSTALL') }} {{ extension.version }} {{ extension.description }} diff --git a/phpBB/ext/index.htm b/phpBB/ext/index.htm old mode 100644 new mode 100755 diff --git a/phpBB/includes/acp/acp_extensions.php b/phpBB/includes/acp/acp_extensions.php index 01e0b5e245..9506a168a4 100644 --- a/phpBB/includes/acp/acp_extensions.php +++ b/phpBB/includes/acp/acp_extensions.php @@ -405,14 +405,56 @@ class acp_extensions { global $phpbb_container; - /** @var \phpbb\composer\extension_manager $manager */ - $manager = $phpbb_container->get('ext.composer.manager'); - $this->page_title = 'ACP_EXTENSIONS_GALLERY'; - $this->tpl_name = 'acp_ext_gallery'; + $action = $this->request->variable('action', 'list'); - $this->request->enable_super_globals(); - $this->template->assign_var('extensions', $manager->get_available_packages()); - $this->request->disable_super_globals(); + /** @var \phpbb\language\language $language */ + $language = $phpbb_container->get('language'); + + /** @var \phpbb\composer\manager $composer_manager */ + $composer_manager = $phpbb_container->get('ext.composer.manager'); + + switch ($action) + { + case 'install': + $extension = $this->request->variable('extension', ''); + + if (empty($extension)) + { + redirect($this->u_action); + } + + $formatter = new \Composer\Console\HtmlOutputFormatter([ + 'warning' => new \Symfony\Component\Console\Formatter\OutputFormatterStyle('black', 'yellow') + ]); + + $composer_io = new \phpbb\composer\io\web_io($language, '', \Symfony\Component\Console\Output\OutputInterface::VERBOSITY_NORMAL, $formatter); + + try + { + $composer_manager->install((array) $extension, $composer_io); + } + catch (\phpbb\exception\runtime_exception $e) + { + trigger_error($language->lang_array($e->getMessage(), $e->get_parameters()) . '

' . $composer_io->getOutput() . adm_back_link($this->u_action), E_USER_WARNING); + } + + trigger_error($language->lang('EXTENSIONS_INSTALLED') . '

' . $composer_io->getOutput() . adm_back_link($this->u_action)); + + break; + case 'remove': + break; + case 'list': + default: + /** @var \phpbb\composer\extension_manager $manager */ + $manager = $phpbb_container->get('ext.composer.manager'); + $this->page_title = 'ACP_EXTENSIONS_GALLERY'; + $this->tpl_name = 'acp_ext_gallery'; + + $this->request->enable_super_globals(); + $this->template->assign_var('extensions', $manager->get_available_packages()); + $this->request->disable_super_globals(); + break; + } } /** diff --git a/phpBB/phpbb/composer/installer.php b/phpBB/phpbb/composer/installer.php index 1135e13c8e..442dcc3f43 100644 --- a/phpBB/phpbb/composer/installer.php +++ b/phpBB/phpbb/composer/installer.php @@ -119,7 +119,7 @@ class installer ->setDumpAutoloader(false) ->setPreferStable(true) ->setRunScripts(false) - ->setDryRun(false); + ->setDryRun(true); try { @@ -282,6 +282,7 @@ class installer // Generates the entry $available[$name] = []; $available[$name]['name'] = $highest_version->getPrettyName(); + $available[$name]['composer_name'] = $highest_version->getName(); $available[$name]['version'] = $highest_version->getPrettyVersion(); if ($version instanceof CompletePackage) diff --git a/phpBB/phpbb/composer/io/console_io.php b/phpBB/phpbb/composer/io/console_io.php index 33ac77ba4e..14c1ef29e9 100644 --- a/phpBB/phpbb/composer/io/console_io.php +++ b/phpBB/phpbb/composer/io/console_io.php @@ -29,6 +29,7 @@ class console_io extends ConsoleIO * @param InputInterface $input The input instance * @param OutputInterface $output The output instance * @param HelperSet $helperSet The helperSet instance + * @param language $language Language object */ public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet, language $language) { diff --git a/phpBB/phpbb/composer/io/web_io.php b/phpBB/phpbb/composer/io/web_io.php index 9e8aa6ec76..e7927c7233 100644 --- a/phpBB/phpbb/composer/io/web_io.php +++ b/phpBB/phpbb/composer/io/web_io.php @@ -15,25 +15,23 @@ namespace phpbb\composer\io; use Composer\IO\BufferIO; use phpbb\language\language; -use Symfony\Component\Console\Helper\HelperSet; -use Symfony\Component\Console\Input\InputInterface; -use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Formatter\OutputFormatterInterface; +use Symfony\Component\Console\Output\StreamOutput; class web_io extends BufferIO { use translate_composer_trait; /** - * Constructor. - * - * @param InputInterface $input The input instance - * @param OutputInterface $output The output instance - * @param HelperSet $helperSet The helperSet instance + * @param language $language Language object + * @param string $input Input string + * @param int $verbosity Verbosity level + * @param OutputFormatterInterface $formatter Output formatter */ - public function __construct(InputInterface $input, OutputInterface $output, HelperSet $helperSet, language $language) + public function __construct(language $language, $input = '', $verbosity = StreamOutput::VERBOSITY_NORMAL, OutputFormatterInterface $formatter = null) { $this->language = $language; - parent::__construct($input, $output, $helperSet); + parent::__construct($input, $verbosity, $formatter); } }