Closed joomlapl-bot closed 7 months ago
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/41446 Poniżej zmiany w oryginale:
PR w związku ze zmianą oryginału https://github.com/joomla/joomla-cms/pull/41446 Poniżej zmiany w oryginale:
Click to expand the diff!
```diff diff --git a/includes/app.php b/includes/app.php index 7a34a062e99f3..649a588260712 100644 --- a/includes/app.php +++ b/includes/app.php @@ -19,10 +19,6 @@ require_once __DIR__ . '/defines.php'; -if (!defined('JPATH_PUBLIC')) { - define('JPATH_PUBLIC', JPATH_ROOT); -} - // Check for presence of vendor dependencies not included in the git repository if (!file_exists(JPATH_LIBRARIES . '/vendor/autoload.php') || !is_dir(JPATH_PUBLIC . '/media/vendor')) { echo file_get_contents(JPATH_ROOT . '/templates/system/build_incomplete.html'); diff --git a/installation/forms/setup.xml b/installation/forms/setup.xml index 7ac9f35ba3133..8f67ce3a2cc78 100644 --- a/installation/forms/setup.xml +++ b/installation/forms/setup.xml @@ -176,4 +176,15 @@ /> + + diff --git a/installation/language/en-GB/joomla.cli.ini b/installation/language/en-GB/joomla.cli.ini index ffd4d80956e74..8004df891c0ce 100644 --- a/installation/language/en-GB/joomla.cli.ini +++ b/installation/language/en-GB/joomla.cli.ini @@ -31,5 +31,7 @@ INSTL_DATABASE_TYPE_DESC="Database type. Supported: mysql, mysqli, pgsql" INSTL_DATABASE_TYPE_DESC_SHORT="Database type. Supported by Joomla: mysql (=MySQL (PDO)), mysqli (=MySQLi), pgsql (=PostgreSQL (PDO))" INSTL_DATABASE_USER_DESC="Database username" INSTL_DATABASE_USER_DESC_SHORT="Database username" +INSTL_PUBLIC_FOLDER_DESC_SHORT="Relative or absolute path to the public folder" +INSTL_PUBLIC_FOLDER_LABEL="Relative or absolute path to the public folder" INSTL_SITE_NAME_DESC="Enter the name of your Joomla site" INSTL_SITE_NAME_DESC_SHORT="Name of the website" diff --git a/installation/language/en-GB/joomla.ini b/installation/language/en-GB/joomla.ini index 07a4509346294..73c3387e35291 100644 --- a/installation/language/en-GB/joomla.ini +++ b/installation/language/en-GB/joomla.ini @@ -114,6 +114,10 @@ INSTL_SITE="Main Configuration" INSTL_SITE_DEVMODE_LABEL="We detected development mode" INSTL_SITE_NAME_DESC="Enter the name of your Joomla site." +; Expert View +INSTL_PUBLIC_FOLDER_DESC_SHORT="Relative or absolute path to the public folder" +INSTL_PUBLIC_FOLDER_LABEL="Relative or absolute path to the public folder" + ; Complete view INSTL_COMPLETE_ERROR_FOLDER_DELETE="The \"%s\" folder could not be deleted. Please manually delete the folder." INSTL_COMPLETE_REMOVE_FOLDER="Remove \"%s\" folder" diff --git a/installation/src/Console/InstallCommand.php b/installation/src/Console/InstallCommand.php index 4833037c4c10e..36be6e4e31ce5 100644 --- a/installation/src/Console/InstallCommand.php +++ b/installation/src/Console/InstallCommand.php @@ -12,7 +12,7 @@ use Joomla\CMS\Factory; use Joomla\CMS\Form\FormField; use Joomla\CMS\Form\FormHelper; -use Joomla\CMS\Installation\Application\CliInstallationApplication; +use Joomla\CMS\Helper\PublicFolderGeneratorHelper; use Joomla\CMS\Installation\Model\ChecksModel; use Joomla\CMS\Installation\Model\CleanupModel; use Joomla\CMS\Installation\Model\DatabaseModel; @@ -181,6 +181,16 @@ protected function doExecute(InputInterface $input, OutputInterface $output): in $this->ioStyle->writeln('OK'); } + if (!empty($cfg['public_folder'])) { + $this->ioStyle->write('Creating the public folder...'); + + if (!(new PublicFolderGeneratorHelper())->createPublicFolder($cfg['public_folder'])) { + return Command::FAILURE; + } + + $this->ioStyle->writeln('OK'); + } + $this->ioStyle->success('Joomla has been installed'); return Command::SUCCESS; @@ -363,7 +373,7 @@ protected function getStringFromOption($option, $question, FormField $field): st // We don't have a CLI option and now interactively get that from the user. while (\is_null($answer) || $answer === false) { - if (in_array($option, ['admin-password', 'db-pass'])) { + if (in_array($option, ['admin-password', 'db-pass', 'public_folder'])) { $answer = $this->ioStyle->askHidden($question); } else { $answer = $this->ioStyle->ask( @@ -379,7 +389,7 @@ protected function getStringFromOption($option, $question, FormField $field): st $answer = false; } - if ($option == 'db-pass' && $valid && $answer == null) { + if (($option == 'db-pass' || $option == 'public_folder') && $valid && $answer == null) { return ''; } } diff --git a/installation/src/Model/SetupModel.php b/installation/src/Model/SetupModel.php index e9c4ea9a11e6e..9cb32473d9c7e 100644 --- a/installation/src/Model/SetupModel.php +++ b/installation/src/Model/SetupModel.php @@ -109,6 +109,11 @@ public function getForm($view = null) return false; } + /** @todo make this available in web installer too */ + if (!Factory::getApplication()->isClient('cli_installation')) { + $form->removeField('public_folder'); + } + // Check the session for previously entered form data. $data = (array) $this->getOptions(); diff --git a/libraries/src/Application/ConsoleApplication.php b/libraries/src/Application/ConsoleApplication.php index 7553cbfcc566e..68cdcf30ee1f4 100644 --- a/libraries/src/Application/ConsoleApplication.php +++ b/libraries/src/Application/ConsoleApplication.php @@ -310,6 +310,7 @@ protected function getDefaultCommands(): array new Console\DeleteUserCommand($this->getDatabase()), new Console\ChangeUserPasswordCommand(), new Console\ListUserCommand($this->getDatabase()), + new Console\SiteCreatePublicFolderCommand(), ] ); } diff --git a/libraries/src/Console/SiteCreatePublicFolderCommand.php b/libraries/src/Console/SiteCreatePublicFolderCommand.php new file mode 100644 index 0000000000000..5810ffe0ff0f0 --- /dev/null +++ b/libraries/src/Console/SiteCreatePublicFolderCommand.php @@ -0,0 +1,151 @@ + + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace Joomla\CMS\Console; + +use Joomla\CMS\Helper\PublicFolderGeneratorHelper; +use Joomla\Console\Command\AbstractCommand; +use Joomla\Filter\InputFilter; +use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Style\SymfonyStyle; + +// phpcs:disable PSR1.Files.SideEffects +\defined('_JEXEC') or die; +// phpcs:enable PSR1.Files.SideEffects + +/** + * Console command for creating a public folder + * + * @since __DEPLOY_VERSION__ + */ +class SiteCreatePublicFolderCommand extends AbstractCommand +{ + /** + * The default command name + * + * @var string + * @since __DEPLOY_VERSION__ + */ + protected static $defaultName = 'site:create-public-folder'; + + /** + * SymfonyStyle Object + * @var object + * @since __DEPLOY_VERSION__ + */ + private $ioStyle; + + /** + * Stores the Input Object + * @var object + * @since __DEPLOY_VERSION__ + */ + private $cliInput; + + /** + * The public folder path (absolute) + * + * @var string + * + * @since __DEPLOY_VERSION__ + */ + private $publicFolder; + + /** + * Internal function to execute the command. + * + * @param InputInterface $input The input to inject into the command. + * @param OutputInterface $output The output to inject into the command. + * + * @return integer The command exit code + * + * @since __DEPLOY_VERSION__ + */ + protected function doExecute(InputInterface $input, OutputInterface $output): int + { + $this->configureIO($input, $output); + $this->ioStyle->title('Create a public folder'); + + $this->publicFolder = $this->getStringFromOption('public-folder', 'Please enter the absolute path to the public folder', true); + + // Remove the last (Windows || NIX) slash + $this->publicFolder = rtrim((new InputFilter())->clean($this->publicFolder, 'PATH'), '/'); + $this->publicFolder = rtrim($this->publicFolder, '\\'); + + if (!((new PublicFolderGeneratorHelper())->createPublicFolder($this->publicFolder))) { + return Command::FAILURE; + } + + $this->ioStyle->success("Public folder created! \nAdjust your server configuration to serve from the public folder."); + + return Command::SUCCESS; + } + + /** + * Method to get a value from option + * + * @param string $option set the option name + * @param string $question set the question if user enters no value to option + * @param bool $required is it required + * + * @return string + * + * @since __DEPLOY_VERSION__ + */ + public function getStringFromOption($option, $question, $required = true): string + { + $answer = (string) $this->cliInput->getOption($option); + + while (!$answer && $required) { + $answer = (string) $this->ioStyle->ask($question); + } + + if (!$required) { + $answer = (string) $this->ioStyle->ask($question); + } + + return $answer; + } + + /** + * Configure the IO. + * + * @param InputInterface $input The input to inject into the command. + * @param OutputInterface $output The output to inject into the command. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + private function configureIO(InputInterface $input, OutputInterface $output) + { + $this->cliInput = $input; + $this->ioStyle = new SymfonyStyle($input, $output); + } + + /** + * Configure the command. + * + * @return void + * + * @since __DEPLOY_VERSION__ + */ + protected function configure(): void + { + $help = "