// small changes on php cli installer

This commit is contained in:
Rémi Gaillard
2013-04-02 17:28:45 +02:00
parent 5642ffb8ee
commit bc5e93ba20
5 changed files with 100 additions and 96 deletions
+28 -21
View File
@@ -58,38 +58,44 @@ abstract class InstallControllerConsole
*/
public $language;
/**
* @var bool If false, disable next button access
*/
public $next_button = true;
/**
* @var bool If false, disable previous button access
*/
public $previous_button = true;
/**
* @var InstallAbstractModel
*/
public $model;
/**
* @var array Magic vars
*/
protected $__vars = array();
/**
* Process form to go to next step
*/
abstract public function processNextStep();
/**
* Validate current step
*/
abstract public function validate();
final public static function execute()
final public static function execute($argc, $argv)
{
if (!($argc-1))
{
$available_arguments = Datas::getInstance()->getArgs();
echo 'Arguments available:'."\n";
foreach ($available_arguments as $key => $arg)
{
$name = isset($arg['name']) ? $arg['name'] : $key;
echo '--'.$name."\t".(isset($arg['help']) ? $arg['help'] : '').(isset($arg['default']) ? "\t".'(Default: '.$arg['default'].')' : '')."\n";
}
exit;
}
$errors = Datas::getInstance()->getAndCheckArgs($argv);
if (Datas::getInstance()->show_license)
{
echo strip_tags(file_get_contents(_PS_INSTALL_PATH_.'theme/views/license_content.phtml'));
exit;
}
if ($errors !== true)
{
if (count($errors))
foreach ($errors as $error)
echo $error."\n";
exit;
}
// Include all controllers
foreach (self::$steps as $step)
@@ -119,6 +125,7 @@ abstract class InstallControllerConsole
{
$this->step = $step;
$this->datas = Datas::getInstance();
// Set current language
$this->language = InstallLanguages::getInstance();
if (!$this->datas->language)
+16 -1
View File
@@ -46,6 +46,7 @@ class Datas
'http_host' => array(
'name' => 'domain',
'validate' => 'isGenericName',
'default' => 'localhost',
),
'database_server' => array(
'name' => 'db_server',
@@ -122,6 +123,16 @@ class Datas
'validate' => 'isEmail',
'default' => 'pub@prestashop.com'
),
'show_license' => array(
'name' => 'license',
'default' => 0,
'help' => 'show PrestaShop license'
),
'newsletter' => array(
'name' => 'newsletter',
'default' => 1,
'help' => 'get news from PrestaShop',
),
);
protected $datas = array();
@@ -155,11 +166,15 @@ class Datas
{
if (!$argv)
return false;
$args_ok = array();
foreach ($argv as $arg)
{
if (!preg_match('/^--([^=\'"><|`]+)=([^=\'"><|`]+)/i', trim($arg), $res))
if (!preg_match('/^--([^=\'"><|`]+)(?:=([^=\'"><|`]+)|(?!license))/i', trim($arg), $res))
continue;
if ($res[1] == 'license' && !isset($res[2]))
$res[2] = 1;
$args_ok[$res[1]] = $res[2];
}