Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
3e43fb6
Public folder
dgrammatiko Aug 25, 2023
e5aafd8
CS
dgrammatiko Aug 25, 2023
83ed856
Use a helper to reduce duplicate code -cli install
dgrammatiko Aug 25, 2023
8d72e34
$folder -> destinationPath
dgrammatiko Aug 25, 2023
d17762b
CLI Installation
dgrammatiko Aug 25, 2023
33728e2
one helper
dgrammatiko Aug 25, 2023
74de659
consistent error text
dgrammatiko Aug 25, 2023
47bbc65
wrong expected default value
dgrammatiko Aug 25, 2023
0a87bf5
text
dgrammatiko Aug 25, 2023
73c01d4
Draw the rest of the horse (kinda)
dgrammatiko Aug 25, 2023
be5b4f3
update
dgrammatiko Sep 3, 2023
bdc29a6
CS
dgrammatiko Sep 3, 2023
10f6d6b
cs
dgrammatiko Sep 3, 2023
58c47d9
Update InstallCommand.php
dgrammatiko Sep 4, 2023
9817ab6
cleanup
dgrammatiko Sep 4, 2023
e602e8a
Simplify
dgrammatiko Sep 4, 2023
86a5b53
entropy
dgrammatiko Sep 4, 2023
c0ccdd5
useless
dgrammatiko Sep 4, 2023
5192199
typehint
dgrammatiko Sep 4, 2023
ab8c0f1
simplify more
dgrammatiko Sep 4, 2023
a6feb17
move the unset
dgrammatiko Sep 4, 2023
0821e04
oops
dgrammatiko Sep 4, 2023
a3e6b73
code docs
dgrammatiko Sep 4, 2023
4d61960
well that path doesn't resolve
dgrammatiko Sep 4, 2023
5f8fbc8
Update SetupModel.php
dgrammatiko Sep 4, 2023
3555276
Fix the paths
dgrammatiko Sep 4, 2023
55f8786
Merge branch '5.0-dev' into 5.0-dev-expose-public-folder-cli
HLeithner Sep 4, 2023
c14ef32
Fix the installation cli skipping images
dgrammatiko Sep 4, 2023
7622fed
Merge branch '5.0-dev' into 5.0-dev-expose-public-folder-cli
dgrammatiko Sep 4, 2023
6fe810b
cs
dgrammatiko Sep 4, 2023
2c485d4
Fix the defines path
dgrammatiko Sep 4, 2023
0bd8bdf
Use full paths
dgrammatiko Sep 4, 2023
0b3dce7
Merge branch '5.0-dev' into 5.0-dev-expose-public-folder-cli
HLeithner Sep 4, 2023
1cf2d13
Make the public folder input optional
dgrammatiko Sep 4, 2023
1d75c1a
No reason to limit this to cli.
HLeithner Sep 4, 2023
e385db0
Allow public folder creation to use relative path
HLeithner Sep 4, 2023
520c47e
cs
HLeithner Sep 4, 2023
5cf3cb1
cs
HLeithner Sep 5, 2023
2e382d6
allow empty value for public folder input
dgrammatiko Sep 5, 2023
f771697
Some typos
dgrammatiko Sep 5, 2023
3af3baa
Merge branch '5.0-dev' into 5.0-dev-expose-public-folder-cli
dgrammatiko Sep 5, 2023
5c98da1
Update installation/src/Model/SetupModel.php
HLeithner Sep 5, 2023
7cbdb09
Update libraries/src/Helper/PublicFolderGeneratorHelper.php
dgrammatiko Sep 5, 2023
a613616
Update libraries/src/Helper/PublicFolderGeneratorHelper.php
dgrammatiko Sep 5, 2023
69b3794
Update installation/language/en-GB/joomla.ini
dgrammatiko Sep 5, 2023
f73031e
Update installation/language/en-GB/joomla.cli.ini
dgrammatiko Sep 5, 2023
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
4 changes: 0 additions & 4 deletions includes/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
11 changes: 11 additions & 0 deletions installation/forms/setup.xml
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,15 @@
/>

</fieldset>

<fieldset name="expert">
<field
name="public_folder"
type="text"
label="INSTL_PUBLIC_FOLDER_LABEL"
description="INSTL_PUBLIC_FOLDER_DESCRIPTION"
default=""
filter="string"
/>
</fieldset>
</form>
2 changes: 2 additions & 0 deletions installation/language/en-GB/joomla.cli.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 4 additions & 0 deletions installation/language/en-GB/joomla.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
16 changes: 13 additions & 3 deletions installation/src/Console/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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(
Expand All @@ -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 '';
}
}
Expand Down
5 changes: 5 additions & 0 deletions installation/src/Model/SetupModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions libraries/src/Application/ConsoleApplication.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ protected function getDefaultCommands(): array
new Console\DeleteUserCommand($this->getDatabase()),
new Console\ChangeUserPasswordCommand(),
new Console\ListUserCommand($this->getDatabase()),
new Console\SiteCreatePublicFolderCommand(),
]
);
}
Expand Down
151 changes: 151 additions & 0 deletions libraries/src/Console/SiteCreatePublicFolderCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
<?php

/**
* Joomla! Content Management System
*
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @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 = "<info>%command.name%</info> will create a public folder
\nUsage: <info>php %command.full_name%</info>";

$this->addOption('public-folder', null, InputOption::VALUE_REQUIRED, 'public folder absolute path');
$this->setDescription('Create a public folder');
$this->setHelp($help);
}
}
Loading