Skip to content

Commit

Permalink
Merge pull request #16618 from totten/master-setup
Browse files Browse the repository at this point in the history
dev/core#1615 - Import civicrm-setup
  • Loading branch information
eileenmcnaughton authored Feb 23, 2020
2 parents d1eb262 + cfb4875 commit fa762be
Show file tree
Hide file tree
Showing 89 changed files with 4,300 additions and 39 deletions.
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
"PHPUnit_": ["packages/"],
"Civi": "",
"Civi\\": [".", "tests/phpunit/"]
},
"psr-4": {
"Civi\\": ["setup/src/"]
}
},
"include-path": ["vendor/tecnickcom"],
Expand Down Expand Up @@ -63,7 +66,6 @@
"pear/net_smtp": "1.9.*",
"pear/net_socket": "1.0.*",
"pear/mail": "^1.4",
"civicrm/civicrm-setup": "~0.4.0",
"guzzlehttp/guzzle": "^6.3",
"psr/simple-cache": "~1.0.1",
"cweagans/composer-patches": "~1.0",
Expand Down
39 changes: 1 addition & 38 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions setup/plugins/blocks/advanced.civi-setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php
if (!defined('CIVI_SETUP')) {
exit("Installation plugins must only be loaded by the installer.\n");
}

\Civi\Setup::dispatcher()
->addListener('civi.setupui.run', function (\Civi\Setup\UI\Event\UIBootEvent $e) {

\Civi\Setup::log()->info(sprintf('[%s] Parse inputs', basename(__FILE__)));

/**
* @var \Civi\Setup\UI\SetupController $ctrl
*/
$ctrl = $e->getCtrl();
$values = $e->getField('advanced', array());

$placeholderDb = 'mysql://USER:PASS@HOST/DB';

if (empty($values['db']) || $values['db'] === $placeholderDb) {
$e->getModel()->extras['advanced']['db'] = $placeholderDb;
}
else {
$e->getModel()->extras['advanced']['db'] = trim($values['db']);
$e->getModel()->db = \Civi\Setup\DbUtil::parseDsn(trim($values['db']));
}

}, \Civi\Setup::PRIORITY_LATE);

\Civi\Setup::dispatcher()
->addListener('civi.setupui.boot', function (\Civi\Setup\UI\Event\UIBootEvent $e) {
\Civi\Setup::log()->info(sprintf('[%s] Register blocks', basename(__FILE__)));

/**
* @var \Civi\Setup\UI\SetupController $ctrl
*/
$ctrl = $e->getCtrl();

$ctrl->blocks['advanced'] = array(
'is_active' => TRUE,
'file' => __DIR__ . DIRECTORY_SEPARATOR . 'advanced.tpl.php',
'class' => '',
'weight' => 60,
);
}, \Civi\Setup::PRIORITY_PREPARE);
60 changes: 60 additions & 0 deletions setup/plugins/blocks/advanced.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php if (!defined('CIVI_SETUP')): exit("Installation plugins must only be loaded by the installer.\n");
endif; ?>
<h2 id="environment"><?php echo ts('Environment'); ?></h2>

<p>
<?php echo ts('The system settings were auto-detected. CiviCRM will be installed with:'); ?>
</p>

<div style="">
<table class="settingsTable">
<tbody>
<tr>
<th><?php echo ts('CMS Database'); ?></th>
<td>
<code><?php echo htmlentities('mysql://' . $model->cmsDb['username'] . ':HIDDEN@' . $model->cmsDb['server'] . '/' . $model->cmsDb['database']); ?></code>
</td>
</tr>
<tr>
<th><?php echo ts('CiviCRM Database'); ?></th>
<td class="advanced-db">
<div class="ro">
<code><?php echo htmlentities('mysql://' . $model->db['username'] . ':HIDDEN@' . $model->db['server'] . '/' . $model->db['database']); ?></code>
<a href="" onclick="csj$('.advanced-db .ro').hide(); csj$('.advanced-db .rw').show(); return false;" title="<?php echo htmlentities(ts('Edit')) ?>"><i class="fa fa-pencil"></i></a>
</div>
<div class="rw" style="display: none;">
<div>

<input type="text" name="civisetup[advanced][db]" value="<?php echo htmlentities($model->extras['advanced']['db']); ?>" data-original="<?php echo htmlentities($model->extras['advanced']['db']); ?>">
<input id="db_apply_button" type="submit" name="civisetup[action][Start]" value="<?php echo htmlentities(ts('Apply')); ?>" />
<a href="" onclick="civisetupAdvancedDbCancel(); return false;" title="<?php echo htmlentities(ts('Cancel')) ?>"><i class="fa fa-close"></i></a>
<script type="text/javascript">
function civisetupAdvancedDbCancel() {
csj$('.advanced-db .rw').hide();
csj$('.advanced-db .ro').show();
csj$('.advanced-db .rw input[type=text]').val(csj$('.advanced-db .rw input[type=text]').attr('data-original'));
}
</script>
</div>
<p><?php echo ts('By default, CiviCRM uses the same database as your website. You may install on a separate database if you need more fine-grained control over permissions, replication, hardware capacity, etc.'); ?></p>
<p><?php echo ts('<strong>Example</strong>: <code>%1</code>', array(1 => 'mysql://admin:secret@localhost/civicrm')); ?></p>
<p><?php echo ts('<strong>Example</strong>: <code>%1</code>', array(1 => 'mysql://admin:[email protected]:3306/otherdb')); ?></p>
</div>
</td>
</tr>
<tr>
<th><?php echo ts('CiviCRM Settings File'); ?></th>
<td><code><?php echo htmlentities($model->settingsPath); ?></code></td>
</tr>
<tr>
<th><?php echo ts('CiviCRM Source Code'); ?></th>
<td><code><?php echo htmlentities($model->srcPath); ?></code></td>
</tr>
</tbody>
</table>
</div>

<p class="tip">
<strong><?php echo ts('Tip'); ?></strong>:
<?php echo ts('Need more advanced control? You may alternatively use the <a href="%1" target="%2">command-line installer</a>.', array(1 => 'https://github.com/civicrm/cv', 2 => '_blank')); ?>
</p>
37 changes: 37 additions & 0 deletions setup/plugins/blocks/components.civi-setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
if (!defined('CIVI_SETUP')) {
exit("Installation plugins must only be loaded by the installer.\n");
}

\Civi\Setup::dispatcher()
->addListener('civi.setupui.boot', function (\Civi\Setup\UI\Event\UIBootEvent $e) {
\Civi\Setup::log()->info(sprintf('[%s] Register blocks', basename(__FILE__)));

/**
* @var \Civi\Setup\UI\SetupController $ctrl
*/
$ctrl = $e->getCtrl();

$ctrl->blocks['components'] = array(
'is_active' => TRUE,
'file' => __DIR__ . DIRECTORY_SEPARATOR . 'components.tpl.php',
'class' => 'if-no-errors',
'weight' => 50,
'component_labels' => array(
'CiviContribute' => ts('Accept donations and payments'),
'CiviEvent' => ts('Accept event registrations'),
'CiviMail' => ts('Send email blasts and newsletters'),
'CiviMember' => ts('Manage recurring memberships'),
'CiviCase' => ts('Track case histories'),
'CiviPledge' => ts('Accept pledges'),
'CiviReport' => ts('Generate reports'),
'CiviCampaign' => ts('Organize campaigns, surveys, and petitions'),
'CiviGrant' => ts('Receive grant applications'),
),
);

if ($e->getMethod() === 'POST' || is_array($e->getField('components'))) {
$e->getModel()->components = array_keys($e->getField('components'));
}

}, \Civi\Setup::PRIORITY_PREPARE);
18 changes: 18 additions & 0 deletions setup/plugins/blocks/components.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php if (!defined('CIVI_SETUP')): exit("Installation plugins must only be loaded by the installer.\n");
endif; ?>
<h2 id="components"><?php echo ts('Components'); ?></h2>

<div>
<?php foreach ($model->getField('components', 'options') as $comp => $label): ?>
<input class="comp-cb sr-only" style="display: none;" type="checkbox" name="civisetup[components][<?php echo $comp; ?>]" id="civisetup[components][<?php echo $comp; ?>]" <?php echo in_array($comp, $model->components) ? 'checked' : '' ?>>
<label class="comp-box" for="civisetup[components][<?php echo $comp; ?>]">
<span class="comp-label"><?php echo $label; ?></span>
<span class="comp-desc"><?php echo $_tpl_block['component_labels'][$comp] ?></span>
</label>
<?php endforeach; ?>
</div>

<p class="tip">
<strong><?php echo ts('Tip'); ?></strong>:
<?php echo ts('Not sure? That\'s OK. After installing, you can enable and disable components at any time.'); ?>
</p>
21 changes: 21 additions & 0 deletions setup/plugins/blocks/header.civi-setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
if (!defined('CIVI_SETUP')) {
exit("Installation plugins must only be loaded by the installer.\n");
}

\Civi\Setup::dispatcher()
->addListener('civi.setupui.boot', function (\Civi\Setup\UI\Event\UIBootEvent $e) {
\Civi\Setup::log()->info(sprintf('[%s] Register blocks', basename(__FILE__)));

/**
* @var \Civi\Setup\UI\SetupController $ctrl
*/
$ctrl = $e->getCtrl();

$ctrl->blocks['header'] = array(
'is_active' => TRUE,
'file' => __DIR__ . DIRECTORY_SEPARATOR . 'header.tpl.php',
'class' => '',
'weight' => 10,
);
}, \Civi\Setup::PRIORITY_PREPARE);
17 changes: 17 additions & 0 deletions setup/plugins/blocks/header.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php if (!defined('CIVI_SETUP')): exit("Installation plugins must only be loaded by the installer.\n");
endif; ?>
<div class="civicrm-setup-header">
<div class="title">
<h1><?php echo ts("Thanks for choosing CiviCRM. You're nearly there!"); ?><hr></h1>
</div>
<div class="civicrm-logo"><strong><?php echo ts('Version %1', array(1 => "{$civicrm_version} {$model->cms}")); ?></strong>
<span><img src=<?php echo $installURLPath . "updated-logo.jpg"?> /></span>
</div>
</div>
<h2><?php echo ts("CiviCRM Installer"); ?></h2>

<noscript>
<p class="error"><?php echo ts("Error: Javascipt appears to be disabled. The CiviCRM web-based installer requires Javascript.");?></p>
</noscript>

<p><?php echo ts("Thanks for choosing CiviCRM! Please follow the instructions below to install CiviCRM."); ?></p>
21 changes: 21 additions & 0 deletions setup/plugins/blocks/install.civi-setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
if (!defined('CIVI_SETUP')) {
exit("Installation plugins must only be loaded by the installer.\n");
}

\Civi\Setup::dispatcher()
->addListener('civi.setupui.boot', function (\Civi\Setup\UI\Event\UIBootEvent $e) {
\Civi\Setup::log()->info(sprintf('[%s] Register blocks', basename(__FILE__)));

/**
* @var \Civi\Setup\UI\SetupController $ctrl
*/
$ctrl = $e->getCtrl();

$ctrl->blocks['install'] = array(
'is_active' => TRUE,
'file' => __DIR__ . DIRECTORY_SEPARATOR . 'install.tpl.php',
'class' => 'if-no-errors',
'weight' => 70,
);
}, \Civi\Setup::PRIORITY_PREPARE);
11 changes: 11 additions & 0 deletions setup/plugins/blocks/install.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php if (!defined('CIVI_SETUP')): exit("Installation plugins must only be loaded by the installer.\n");
endif; ?>
<div class="action-box">
<input id="install_button" type="submit" name="civisetup[action][Install]"
value="<?php echo htmlentities(ts('Install CiviCRM')); ?>"
onclick="document.getElementById('saving_top').style.display = ''; this.value = '<?php echo ts('Installing CiviCRM...', array('escape' => 'js')); ?>'"/>
<div id="saving_top" style="display: none;">
&nbsp; <img src="<?php echo htmlentities($installURLPath . "network-save.gif") ?>"/>
<?php echo ts('(this will take a few minutes)'); ?>
</div>
</div>
21 changes: 21 additions & 0 deletions setup/plugins/blocks/l10n.civi-setup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
if (!defined('CIVI_SETUP')) {
exit("Installation plugins must only be loaded by the installer.\n");
}

\Civi\Setup::dispatcher()
->addListener('civi.setupui.boot', function (\Civi\Setup\UI\Event\UIBootEvent $e) {
\Civi\Setup::log()->info(sprintf('[%s] Register blocks', basename(__FILE__)));

/**
* @var \Civi\Setup\UI\SetupController $ctrl
*/
$ctrl = $e->getCtrl();

$ctrl->blocks['l10n'] = array(
'is_active' => TRUE,
'file' => __DIR__ . DIRECTORY_SEPARATOR . 'l10n.tpl.php',
'class' => 'if-no-errors',
'weight' => 30,
);
}, \Civi\Setup::PRIORITY_PREPARE);
39 changes: 39 additions & 0 deletions setup/plugins/blocks/l10n.tpl.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php if (!defined('CIVI_SETUP')): exit("Installation plugins must only be loaded by the installer.\n");
endif; ?>
<h2><?php echo ts('Localization'); ?></h2>

<p><?php echo ts('CiviCRM has been translated to many languages, thanks to its community of translators. By selecting another language, the installer may be available in that language. The initial configuration of the basic data will also be set to that language (ex: individual prefixes, suffixes, activity types, etc.). <a href="%1" target="%2">Learn more about using CiviCRM in other languages.</a>', array(1 => 'http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=88408149', 2 => '_blank')); ?></p>

<script>
function civicrmInstallerSetLanguage(language) {
var location = window.location.toString();

if (location.match(/lang=.._../)) {
location = location.replace(/lang=.._../, 'lang=' + language);
window.location = location;
}
else {
window.location += (location.indexOf('?') < 0 ? '?' : '&') + 'lang=' + language;
}
}
</script>

<p style="margin-left: 2em" id="locale">
<label for="lang"><span><?php echo ts('Language of basic data:'); ?></span></label>
<select id="lang" name="lang" onchange="civicrmInstallerSetLanguage(this.value);">
<?php
foreach ($model->getField('lang', 'options') as $locale => $language):
$selected = ($locale == $model->lang) ? 'selected="selected"' : '';
echo "<option value='$locale' $selected>$language</option>";
endforeach;
?>
</select>

<span class="advancedTip">
<?php
if (count($model->getField('lang', 'options')) < 2):
echo "(download the civicrm-{$civicrm_version}-l10n.tar.gz file and unzip into CiviCRM’s directory to add languages here)";
endif;
?>
</span>
</p>
Loading

0 comments on commit fa762be

Please sign in to comment.