From 97b8e6b21feee8da7ec0f0762bf3370b9965a147 Mon Sep 17 00:00:00 2001 From: monishdeb Date: Thu, 19 Feb 2015 15:13:53 +0530 Subject: [PATCH] CRM-13584 fix - Localising the CiviCRM installation https://issues.civicrm.org/jira/browse/CRM-13584 --- CRM/Core/Config.php | 12 ++++ install/civicrm.php | 6 -- install/index.php | 59 ++++++++++++++++--- install/template.html | 133 ++++++++++++++++++++++++------------------ 4 files changed, 141 insertions(+), 69 deletions(-) diff --git a/CRM/Core/Config.php b/CRM/Core/Config.php index b03664e68a..b942661615 100644 --- a/CRM/Core/Config.php +++ b/CRM/Core/Config.php @@ -877,4 +877,16 @@ AND return CRM_Financial_BAO_PaymentProcessor::hasPaymentProcessorSupporting(array('BackOffice')); } + /** + * Resets the singleton, so that the next call to CRM_Core_Config::singleton() + * reloads completely. + * + * While normally we could call the singleton function with $force = TRUE, + * this function addresses a very specific use-case in the CiviCRM installer, + * where we cannot yet force a reload, but we want to make sure that the next + * call to this object gets a fresh start (ex: to initialize the DAO). + */ + public function free() { + self::$_singleton = NULL; + } } diff --git a/install/civicrm.php b/install/civicrm.php index 6b622b0724..c66cdb94e5 100644 --- a/install/civicrm.php +++ b/install/civicrm.php @@ -36,12 +36,6 @@ function civicrm_setup($filesDirectory) { global $crmPath, $sqlPath, $pkgPath, $tplPath; global $compileDir; - $pkgPath = $crmPath . DIRECTORY_SEPARATOR . 'packages'; - set_include_path($crmPath . PATH_SEPARATOR . - $pkgPath . PATH_SEPARATOR . - get_include_path() - ); - $sqlPath = $crmPath . DIRECTORY_SEPARATOR . 'sql'; $tplPath = $crmPath . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'common' . DIRECTORY_SEPARATOR; diff --git a/install/index.php b/install/index.php index 2b675c9507..2189e15908 100644 --- a/install/index.php +++ b/install/index.php @@ -57,8 +57,10 @@ if (!in_array($installType, array('drupal', 'wordpress'))) { } global $crmPath; +global $pkgPath; global $installDirPath; global $installURLPath; + if ($installType == 'drupal') { $crmPath = dirname(dirname($_SERVER['SCRIPT_FILENAME'])); $installDirPath = $installURLPath = ''; @@ -66,11 +68,16 @@ if ($installType == 'drupal') { elseif ($installType == 'wordpress') { $crmPath = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR; $installDirPath = WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR; - $installURLPath = WP_PLUGIN_URL . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR; } -set_include_path(get_include_path() . PATH_SEPARATOR . $crmPath); +$pkgPath = $crmPath . DIRECTORY_SEPARATOR . 'packages'; + +set_include_path( + $crmPath . PATH_SEPARATOR . + $pkgPath . PATH_SEPARATOR . + get_include_path() +); require_once $crmPath . '/CRM/Core/ClassLoader.php'; CRM_Core_ClassLoader::singleton()->register(); @@ -138,11 +145,32 @@ foreach ($langs as $locale => $_) { } } +// Set the locale (required by CRM_Core_Config) +// This is mostly sympbolic, since nothing we do during the install +// really requires CIVICRM_UF to be defined. +$installTypeToUF = array( + 'wordpress' => 'WordPress', + 'drupal' => 'Drupal', +); + +$uf = (! isset($installTypeToUF[$installType]) ? $installTypeToUF[$installType] : 'Drupal'); +define('CIVICRM_UF', $uf); + +global $tsLocale; + +$tsLocale = 'en_US'; $seedLanguage = 'en_US'; + if (isset($_REQUEST['seedLanguage']) and isset($langs[$_REQUEST['seedLanguage']])) { $seedLanguage = $_REQUEST['seedLanguage']; + $tsLocale = $_REQUEST['seedLanguage']; } +$config = CRM_Core_Config::singleton(FALSE); +// The translation files are in the parent directory (l10n) +$config->gettextResourceDir = '..' . DIRECTORY_SEPARATOR . $config->gettextResourceDir; +$i18n = CRM_Core_I18n::singleton(); + global $cmsPath; if ($installType == 'drupal') { //CRM-6840 -don't force to install in sites/all/modules/ @@ -285,9 +313,9 @@ class InstallRequirements { public function checkdatabase($databaseConfig, $dbName) { if ($this->requireFunction('mysql_connect', array( - "PHP Configuration", - "MySQL support", - "MySQL support not included in PHP.", + ts("PHP Configuration"), + ts("MySQL support"), + ts("MySQL support not included in PHP."), ) ) ) { @@ -1249,6 +1277,7 @@ class Installer extends InstallRequirements { "; $output = NULL; + if ( $installType == 'drupal' && version_compare(VERSION, '7.0-rc1') >= 0 @@ -1285,6 +1314,11 @@ class Installer extends InstallRequirements { // relative / abosolute paths are not working for drupal, hence using chdir() chdir($cmsPath); + // Force the re-initialisation of the config singleton on the next call + // since so far, we had used the Config object without loading the DB. + $c = CRM_Core_Config::singleton(FALSE); + $c->free(); + include_once "./includes/bootstrap.inc"; include_once "./includes/unicode.inc"; @@ -1333,7 +1367,7 @@ class Installer extends InstallRequirements { $output .= ''; $output .= ''; $output .= ''; - $output .= '

CiviCRM has been successfully installed

'; + $output .= '

' . ts("CiviCRM has been successfully installed") . '

'; $output .= '
    '; $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki"); if (!function_exists('ts')) { @@ -1376,7 +1410,7 @@ class Installer extends InstallRequirements { } elseif ($installType == 'wordpress') { echo '

    CiviCRM Installed

    '; - echo '

    CiviCRM has been successfully installed

    '; + echo '

    ' . ts("CiviCRM has been successfully installed") . '

    '; echo '
      '; $docLinkConfig = CRM_Utils_System::docURL2('Configuring a New Site', FALSE, 'here', NULL, NULL, "wiki"); if (!function_exists('ts')) { @@ -1396,6 +1430,17 @@ class Installer extends InstallRequirements { echo '
    '; echo '
    '; } + + //change the default language to one chosen + if (isset($config['seedLanguage']) && $config['seedLanguage'] != 'en_US') { + $domain = new CRM_Core_DAO_Domain(); + $domain->id = CRM_Core_Config::domainID(); + $domain->find(TRUE); + $configSettings = unserialize($domain->config_backend); + $configSettings['lcMessages'] = $config['seedLanguage']; + $domain->config_backend = serialize($configSettings); + $domain->save(); + } } return $this->errors; diff --git a/install/template.html b/install/template.html index 6202e9ff29..76364df0cc 100644 --- a/install/template.html +++ b/install/template.html @@ -2,81 +2,63 @@ -CiviCRM Installer +<?php echo ts('CiviCRM Installer'); ?> /> +
    -
    Version
    +
    Version
    /> -
    -

    CiviCRM Installer

    -
    Thanks for choosing to use CiviCRM! Please follow the instructions below to get CiviCRM installed.
    -

    -
    - -

    We are not able to install the software. Please see below for details.

    - -hasWarnings()) { ?> -

    There are some issues that we recommend you look at before installing, however, you are still able to install the software. Please see below for details.

    +
    -hasErrors()) { ?> -

    You're ready to install!    -

    +

    +

    - + -

    - + +

    see below for details.'); ?>

    + + hasWarnings()) { ?> +

    + hasErrors()) { ?> +

    + + +

    + -

    +

    +

    - - -

    Database Version and Connection Settings

    -

    -CiviCRM stores its content in a MySQL database. Please provide the username -and password to connect to the server here. If this account has permission to create databases, then we will -create the database for you; otherwise, you must give the name of a database that already exists. -

    +

    Learn more about using CiviCRM in other languages.', array(1 => 'http://wiki.civicrm.org/confluence/pages/viewpage.action?pageId=88408149')); ?>

    -hasErrors()) { ?> -

    Your database settings don't appear to be correct. Please check the Database Details below for specific errors.

    - -

    Database version and connection settings have been verified and look correct!

    - + - -

    Other Settings

    -

    - - $language) { $selected = ($locale == $seedLanguage) ? 'selected="selected"' : ''; @@ -84,13 +66,52 @@ create the database for you; otherwise, you must give the name of a database tha } ?> + -
    + +

    + +

    + + +

    + +

    + +hasErrors()) { ?> +

    Database Details below for specific errors.", array(1 => '#dbDetails')); ?>

    + +

    + + +

    +
    +
    +
    +
    +

    + + +

    +

    +
    +
    +
    +
    +

    + + + +

    + +


    Check this box to pre-populate CiviCRM with sample English contact records, online contribution pages, profile forms, etc. These examples can help you learn about CiviCRM features.

    -- 2.25.1