Minor - WIP use iso code in order to get the platform language

- Add po.* translation files for the installation
pull/2487/head
jmontoyaa 7 years ago
parent 22000923ad
commit 4d218ea3b7
  1. 4
      main/admin/course_add.php
  2. 2
      main/admin/legal_list.php
  3. 2
      main/auth/profile.php
  4. 4
      main/create_course/add_course.php
  5. 45
      main/inc/lib/api.lib.php
  6. 2
      main/inc/lib/chamilo_session.class.php
  7. 142
      main/inc/lib/database.lib.php
  8. 140
      main/inc/lib/events.lib.php
  9. 10
      main/inc/lib/formvalidator/Element/SelectLanguage.php
  10. 60
      main/inc/lib/internationalization.lib.php
  11. 7
      main/inc/lib/usermanager.lib.php
  12. BIN
      main/install/header-logo.png
  13. 113
      main/install/index.php
  14. 120
      main/install/install.lib.php
  15. 8
      plugin/vchamilo/lib/Virtual.php
  16. 4
      plugin/vchamilo/views/manage.testcnx.php
  17. 4
      translations/installation.en.po
  18. 9
      translations/installation.fr.po

@ -129,9 +129,9 @@ $form->applyFilter('department_url', 'html_filter');
// Course language.
$languages = api_get_languages();
if (count($languages['name']) === 1) {
if (count($languages) === 1) {
// If there's only one language available, there's no point in asking
$form->addElement('hidden', 'course_language', $languages['folder'][0]);
$form->addElement('hidden', 'course_language', $languages[0]);
} else {
$form->addSelectLanguage(
'course_language',

@ -24,7 +24,7 @@ echo '</div>';
$legal_count = LegalManager::count();
$languages = api_get_languages();
$available_languages = count($languages['folder']);
$available_languages = count($languages);
if ($legal_count != $available_languages) {
echo Display::return_message(get_lang('YouShouldCreateTermAndConditionsForAllAvailableLanguages'), 'warning');
}

@ -601,7 +601,7 @@ if ($form->validate()) {
//Checking the user language
$languages = api_get_languages();
if (!in_array($user_data['language'], $languages['folder'])) {
if (!in_array($user_data['language'], $languages)) {
$user_data['language'] = api_get_setting('platformLanguage');
}
$_SESSION['_user']['language'] = $user_data['language'];

@ -172,9 +172,9 @@ if ($course_validation_feature) {
// Course language.
$languages = api_get_languages();
if (count($languages['name']) === 1) {
if (count($languages) === 1) {
// If there's only one language available, there's no point in asking
$form->addElement('hidden', 'course_language', $languages['folder'][0]);
$form->addElement('hidden', 'course_language', $languages[0]);
} else {
$form->addSelectLanguage(
'course_language',

@ -4399,7 +4399,7 @@ function api_get_languages_combo($name = 'language')
// Retrieve a complete list of all the languages.
$language_list = api_get_languages();
if (count($language_list['name']) < 2) {
if (count($language_list) < 2) {
return $ret;
}
@ -4410,17 +4410,14 @@ function api_get_languages_combo($name = 'language')
$default = $platformLanguage;
}
$languages = $language_list['name'];
$folder = $language_list['folder'];
$ret .= '<select name="'.$name.'" id="language_chosen" class="selectpicker show-tick form-control">';
foreach ($languages as $key => $value) {
if ($folder[$key] == $default) {
foreach ($language_list as $key => $value) {
if ($key == $default) {
$selected = ' selected="selected"';
} else {
$selected = '';
}
$ret .= sprintf('<option value=%s" %s>%s</option>', $folder[$key], $selected, $value);
$ret .= sprintf('<option value=%s" %s>%s</option>', $key, $selected, $value);
}
$ret .= '</select>';
@ -4451,15 +4448,15 @@ function api_display_language_form($hide_if_no_choice = false, $showAsButton = f
$user_selected_language = api_get_setting('platformLanguage');
}
$currentLanguageId = api_get_language_id($user_selected_language);
$currentLanguageInfo = api_get_language_info($currentLanguageId);
$countryCode = languageToCountryIsoCode($currentLanguageInfo['isocode']);
$countryCode = languageToCountryIsoCode($user_selected_language);
$language = api_get_language_from_iso($user_selected_language);
$url = api_get_self();
if ($showAsButton) {
$html = '<div class="btn-group">
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
<span class="flag-icon flag-icon-'.$countryCode.'"></span>
'.$currentLanguageInfo['original_name'].'
'.$language->getOriginalName().'
<span class="caret">
</span>
</button>';
@ -4467,16 +4464,17 @@ function api_display_language_form($hide_if_no_choice = false, $showAsButton = f
$html = '
<a href="'.$url.'" class="dropdown-toggle" data-toggle="dropdown" role="button">
<span class="flag-icon flag-icon-'.$countryCode.'"></span>
'.$currentLanguageInfo['original_name'].'
'.$language->getOriginalName().'
<span class="caret"></span>
</a>
';
}
$html .= '<ul class="dropdown-menu" role="menu">';
foreach ($language_list['all'] as $key => $data) {
$urlLink = $url.'?language='.$data['english_name'];
$html .= '<li><a href="'.$urlLink.'"><span class="flag-icon flag-icon-'.languageToCountryIsoCode($data['isocode']).'"></span> '.$data['original_name'].'</a></li>';
foreach ($language_list as $iso => $data) {
$urlLink = $url.'?language='.$data;
$html .= '<li><a href="'.$urlLink.'">';
$html .= '<span class="flag-icon flag-icon-'.languageToCountryIsoCode($iso).'"></span> '.$data.'</a></li>';
}
$html .= '</ul>';
@ -4572,10 +4570,8 @@ function api_get_languages()
ORDER BY original_name ASC";
$result = Database::query($sql);
$language_list = [];
while ($row = Database::fetch_array($result)) {
$language_list['name'][] = $row['original_name'];
$language_list['folder'][] = $row['dokeos_folder'];
$language_list['all'][] = $row;
while ($row = Database::fetch_array($result, 'ASSOC')) {
$language_list[$row['isocode']] = $row['original_name'];
}
return $language_list;
}
@ -4705,6 +4701,17 @@ function api_get_language_info($languageId)
];
}
/**
* @param string $code
* @return \Chamilo\CoreBundle\Entity\Language
*/
function api_get_language_from_iso($code)
{
$em = Database::getManager();
$language = $em->getRepository('ChamiloCoreBundle:Language')->findOneBy(['isocode' => $code]);
return $language;
}
/**
* Returns the name of the visual (CSS) theme to be applied on the current page.
* The returned name depends on the platform, course or user -wide settings.

@ -15,7 +15,6 @@ class ChamiloSession implements \ArrayAccess
*/
public static function read($variable, $default = null)
{
//throw new Exception('"s"');
$session = Container::getSession();
$result = null;
if (isset($session)) {
@ -39,7 +38,6 @@ class ChamiloSession implements \ArrayAccess
*/
public static function write($variable, $value)
{
//$_SESSION[$variable] = $value;
$session = Container::getSession();
// Writing the session in 2 instances because
$_SESSION[$variable] = $value;

@ -17,7 +17,31 @@ class Database
*/
private static $em;
private static $connection;
public static $utcDateTimeClass;
/**
* Only used by the installer
*
* @param array $params
* @param string $entityRootPath
*
* @throws \Doctrine\ORM\ORMException
*
* @return
*/
public function connect(
$params = [],
$entityRootPath = ''
) {
$config = self::getDoctrineConfig($entityRootPath);
$config->setAutoGenerateProxyClasses(true);
$params['charset'] = 'utf8';
$entityManager = EntityManager::create($params, $config);
$connection = $entityManager->getConnection();
$this->setConnection($connection);
$this->setManager($entityManager);
}
/**
* @param EntityManager $em
@ -110,117 +134,6 @@ class Database
return $result->rowCount();
}
/**
* @return string
*/
public static function getUTCDateTimeTypeClass()
{
return isset(self::$utcDateTimeClass) ? self::$utcDateTimeClass : 'Application\DoctrineExtensions\DBAL\Types\UTCDateTimeType';
}
/**
* Connect to the database sets the entity manager.
*
* @param array $params
* @param string $sysPath
* @param string $entityRootPath
* @param bool $returnConnection
* @param bool $returnManager
*
* @throws \Doctrine\ORM\ORMException
*
* @return
*/
public function connect(
$params = [],
$sysPath = '',
$entityRootPath = '',
$returnConnection = false,
$returnManager = false
) {
$config = self::getDoctrineConfig($entityRootPath);
$config->setAutoGenerateProxyClasses(true);
$config->setEntityNamespaces(
[
'ChamiloCoreBundle' => 'Chamilo\CoreBundle\Entity',
'ChamiloCourseBundle' => 'Chamilo\CourseBundle\Entity',
'ChamiloPageBundle' => 'Chamilo\PageBundle\Entity',
'ChamiloPluginBundle' => 'Chamilo\PluginBundle\Entity',
'ChamiloSkillBundle' => 'Chamilo\SkillBundle\Entity',
'ChamiloTicketBundle' => 'Chamilo\TicketBundle\Entity',
'ChamiloUserBundle' => 'Chamilo\UserBundle\Entity'
]
);
$params['charset'] = 'utf8';
$entityManager = EntityManager::create($params, $config);
$sysPath = !empty($sysPath) ? $sysPath : api_get_path(SYS_PATH);
$uniqueEntityPath = $sysPath.'vendor/symfony/symfony/src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntity.php';
// Folder symfony/symfony/src doesn't exists in chash use the component folder
if (!file_exists($uniqueEntityPath)) {
$uniqueEntityPath = $sysPath.'vendor/symfony/doctrine-bridge/Validator/Constraints/UniqueEntity.php';
AnnotationRegistry::registerLoader(
function ($class) use ($sysPath) {
$file = str_replace("\\", DIRECTORY_SEPARATOR, $class).".php";
$file = str_replace('Symfony/Component/Validator', '', $file);
$file = $sysPath.'vendor/symfony/validator'.$file;
if (file_exists($file)) {
// file exists makes sure that the loader fails silently
require_once $file;
return true;
}
}
);
} else {
// Registering Constraints
AnnotationRegistry::registerAutoloadNamespace(
'Symfony\Component\Validator\Constraint',
$sysPath.'vendor/symfony/symfony/src'
);
}
AnnotationRegistry::registerFile(
$uniqueEntityPath
);
// Registering gedmo extensions
AnnotationRegistry::registerAutoloadNamespace(
'Gedmo\Mapping\Annotation',
$sysPath."vendor/gedmo/doctrine-extensions/lib"
);
Type::overrideType(
Type::DATETIME,
self::getUTCDateTimeTypeClass()
);
$listener = new \Gedmo\Timestampable\TimestampableListener();
$entityManager->getEventManager()->addEventSubscriber($listener);
$listener = new \Gedmo\Tree\TreeListener();
$entityManager->getEventManager()->addEventSubscriber($listener);
$listener = new \Gedmo\Sortable\SortableListener();
$entityManager->getEventManager()->addEventSubscriber($listener);
$connection = $entityManager->getConnection();
$connection->executeQuery('SET sql_mode = "";');
if ($returnConnection) {
return $connection;
}
if ($returnManager) {
return $entityManager;
}
$this->setConnection($connection);
$this->setManager($entityManager);
}
/**
* Escape MySQL wildchars _ and % in LIKE search
* @param string $text The string to escape
@ -490,13 +403,10 @@ class Database
}
if (!empty($updateSql)) {
//Parsing and cleaning the where conditions
// Parsing and cleaning the where conditions
$whereReturn = self::parse_where_conditions($whereConditions);
$sql = "UPDATE $tableName SET $updateSql $whereReturn ";
$statement = self::getManager()->getConnection()->prepare($sql);
$result = $statement->execute($attributes);
if ($showQuery) {

@ -773,146 +773,6 @@ class Event
return true;
}
/**
* Get every email stored in the database
* @deprecated
* @return array
* @assert () !== false
*/
public static function get_all_event_types()
{
global $event_config;
$sql = 'SELECT etm.id, event_type_name, activated, language_id, message, subject, dokeos_folder
FROM '.Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).' etm
INNER JOIN '.Database::get_main_table(TABLE_MAIN_LANGUAGE).' l
ON etm.language_id = l.id';
$events_types = Database::store_result(Database::query($sql), 'ASSOC');
$to_return = [];
foreach ($events_types as $et) {
$et['nameLangVar'] = $event_config[$et["event_type_name"]]["name_lang_var"];
$et['descLangVar'] = $event_config[$et["event_type_name"]]["desc_lang_var"];
$to_return[] = $et;
}
return $to_return;
}
/**
* Get the users related to one event
*
* @param string $event_name
*
* @return string
*/
public static function get_event_users($event_name)
{
$event_name = Database::escape_string($event_name);
$sql = 'SELECT user.user_id, user.firstname, user.lastname
FROM '.Database::get_main_table(TABLE_MAIN_USER).' user
JOIN '.Database::get_main_table(TABLE_EVENT_TYPE_REL_USER).' relUser
ON relUser.user_id = user.user_id
WHERE user.status <> '.ANONYMOUS.' AND relUser.event_type_name = "'.$event_name.'"';
$user_list = Database::store_result(Database::query($sql), 'ASSOC');
return json_encode($user_list);
}
/**
* @param int $user_id
* @param string $event_type
* @return array|bool
*/
public static function get_events_by_user_and_type($user_id, $event_type)
{
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
$user_id = intval($user_id);
$event_type = Database::escape_string($event_type);
$sql = "SELECT * FROM $table
WHERE default_value_type = 'user_id' AND
default_value = $user_id AND
default_event_type = '$event_type'
ORDER BY default_date ";
$result = Database::query($sql);
if ($result) {
return Database::store_result($result, 'ASSOC');
}
return false;
}
/**
* Save the new message for one event and for one language
*
* @param string $event_name
* @param array $users
* @param string $message
* @param string $subject
* @param string $event_message_language
* @param int $activated
*/
public static function save_event_type_message(
$event_name,
$users,
$message,
$subject,
$event_message_language,
$activated
) {
$event_name = Database::escape_string($event_name);
$activated = intval($activated);
$event_message_language = Database::escape_string($event_message_language);
// Deletes then re-adds the users linked to the event
$sql = 'DELETE FROM '.Database::get_main_table(TABLE_EVENT_TYPE_REL_USER).'
WHERE event_type_name = "'.$event_name.'" ';
Database::query($sql);
foreach ($users as $user) {
$sql = 'INSERT INTO '.Database::get_main_table(TABLE_EVENT_TYPE_REL_USER).' (user_id,event_type_name)
VALUES('.intval($user).',"'.$event_name.'")';
Database::query($sql);
}
$language_id = api_get_language_id($event_message_language);
// check if this template in this language already exists or not
$sql = 'SELECT COUNT(id) as total
FROM '.Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).'
WHERE event_type_name = "'.$event_name.'" AND language_id = '.$language_id;
$sql = Database::store_result(Database::query($sql), 'ASSOC');
// if already exists, we update
if ($sql[0]["total"] > 0) {
$sql = 'UPDATE '.Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).'
SET message = "'.Database::escape_string($message).'",
subject = "'.Database::escape_string($subject).'",
activated = '.$activated.'
WHERE event_type_name = "'.$event_name.'" AND language_id = (
SELECT id FROM '.Database::get_main_table(TABLE_MAIN_LANGUAGE).'
WHERE dokeos_folder = "'.$event_message_language.'"
)';
Database::query($sql);
} else { // else we create a new record
// gets the language_-_id
$lang_id = '(SELECT id FROM '.Database::get_main_table(TABLE_MAIN_LANGUAGE).'
WHERE dokeos_folder = "'.$event_message_language.'")';
$lang_id = Database::store_result(Database::query($lang_id), 'ASSOC');
if (!empty($lang_id[0]["id"])) {
$sql = 'INSERT INTO '.Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).' (event_type_name, language_id, message, subject, activated)
VALUES("'.$event_name.'", '.$lang_id[0]["id"].', "'.Database::escape_string($message).'", "'.Database::escape_string($subject).'", '.$activated.')';
Database::query($sql);
}
}
// set activated at every save
$sql = 'UPDATE '.Database::get_main_table(TABLE_EVENT_EMAIL_TEMPLATE).'
SET activated = '.$activated.'
WHERE event_type_name = "'.$event_name.'"';
Database::query($sql);
}
/**
* Gets the last attempt of an exercise based in the exe_id

@ -3,7 +3,7 @@
/**
* Class SelectLanguage
* A dropdownlist with all languages to use with QuickForm
* A dropdown list with all languages to use with QuickForm
*/
class SelectLanguage extends HTML_QuickForm_select
{
@ -22,16 +22,16 @@ class SelectLanguage extends HTML_QuickForm_select
// Get all languages
$languages = api_get_languages();
foreach ($languages['name'] as $index => $name) {
foreach ($languages as $index => $name) {
if (!empty($default)) {
$defaultValue = $default;
} else {
$defaultValue = api_get_setting('platformLanguage');
}
if ($languages['folder'][$index] == $defaultValue) {
$this->addOption($name, $languages['folder'][$index], ['selected'=>'selected']);
if ($languages[$index] == $defaultValue) {
$this->addOption($name, $languages[$index], ['selected'=>'selected']);
} else {
$this->addOption($name, $languages['folder'][$index]);
$this->addOption($name, $languages[$index]);
}
}
}

@ -62,8 +62,15 @@ define('PERSON_NAME_DATA_EXPORT', PERSON_NAME_EASTERN_ORDER);
*/
function get_lang($variable)
{
$translator = Container::getTranslator();
if (!$translator) {
return $variable;
}
//return $variable;
// Using symfony
/*$defaultDomain = 'messages';
$defaultDomain = 'messages';
$translated = Container::getTranslator()->trans(
$variable,
array(),
@ -83,7 +90,7 @@ function get_lang($variable)
}
}
return $translated;*/
return $translated;
// For serving some old hacks:
@ -176,7 +183,7 @@ function api_get_interface_language(
global $language_interface;
if (empty($language_interface)) {
return 'english';
return 'en';
}
if ($check_sub_language) {
@ -239,45 +246,11 @@ function api_purify_language_id($language)
}
/**
* Gets language isocode column from the language table, taking the given language as a query parameter.
* @param string $language This is the name of the folder containing translations for the corresponding language (e.g arabic, english).
* @param string $default_code This is the value to be returned if there was no code found corresponding to the given language.
* If $language is omitted, interface language is assumed then.
* @return string The found isocode or null on error.
* Returned codes are according to the following standards (in order of preference):
* - ISO 639-1 : Alpha-2 code (two-letters code - en, fr, es, ...)
* - RFC 4646 : five-letter code based on the ISO 639 two-letter language codes
* and the ISO 3166 two-letter territory codes (pt-BR, ...)
* - ISO 639-2 : Alpha-3 code (three-letters code - ast, fur, ...)
* Gets language isocode
*/
function api_get_language_isocode($language = null, $default_code = 'en')
function api_get_language_isocode()
{
static $iso_code = [];
if (empty($language)) {
$language = api_get_interface_language(false, true);
}
if (!isset($iso_code[$language])) {
if (!class_exists('Database')) {
// This might happen, in case of calling this function early during the global initialization.
return $default_code; // This might happen, in case of calling this function early during the global initialization.
}
$sql = "SELECT isocode
FROM ".Database::get_main_table(TABLE_MAIN_LANGUAGE)."
WHERE dokeos_folder = '$language'";
$sql_result = Database::query($sql);
if (Database::num_rows($sql_result)) {
$result = Database::fetch_array($sql_result);
$iso_code[$language] = trim($result['isocode']);
} else {
$language_purified_id = api_purify_language_id($language);
$iso_code[$language] = isset($iso_code[$language_purified_id]) ? $iso_code[$language_purified_id] : null;
}
if (empty($iso_code[$language])) {
$iso_code[$language] = $default_code;
}
}
return $iso_code[$language];
return Container::getTranslator()->getLocale();
}
/**
@ -858,6 +831,7 @@ function api_get_person_name(
if (is_int($format)) {
switch ($format) {
case PERSON_NAME_COMMON_CONVENTION:
$valid[$format][$language] = _api_get_person_name_convention($language, 'format');
$usernameOrderFromDatabase = api_get_setting('user_name_order');
if (isset($usernameOrderFromDatabase) && !empty($usernameOrderFromDatabase)) {
@ -884,6 +858,7 @@ function api_get_person_name(
$format = $valid[$format][$language];
$keywords = [
'%firstname',
'%f',
@ -1938,7 +1913,8 @@ function &_api_get_day_month_names($language = null)
function _api_get_person_name_convention($language, $type)
{
static $conventions;
$language = api_purify_language_id($language);
$language = api_get_language_from_iso($language);
$language = $language->getOriginalName();
if (!isset($conventions)) {
$file = __DIR__.'/internationalization_database/name_order_conventions.php';
if (file_exists($file)) {
@ -1951,9 +1927,9 @@ function _api_get_person_name_convention($language, $type)
]
];
}
// Overwrite classic conventions
$customConventions = api_get_configuration_value('name_order_conventions');
if (!empty($customConventions)) {
foreach ($customConventions as $key => $data) {
$conventions[$key] = $data;

@ -337,9 +337,8 @@ class UserManager
// Checking the user language
$languages = api_get_languages();
$language = strtolower($language);
if (isset($languages['folder'])) {
if (!in_array($language, $languages['folder'])) {
if (isset($languages)) {
if (!in_array($language, $languages)) {
$language = api_get_setting('platformLanguage');
}
}
@ -1067,7 +1066,7 @@ class UserManager
// Checking the user language
$languages = api_get_languages();
if (!in_array($language, $languages['folder'])) {
if (!in_array($language, $languages)) {
$language = api_get_setting('platformLanguage');
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

@ -8,6 +8,7 @@ use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Dotenv\Dotenv;
use Chamilo\CoreBundle\Framework\Container;
use Symfony\Component\Translation\Translator;
/**
* Chamilo installation
@ -25,8 +26,8 @@ use Chamilo\CoreBundle\Framework\Container;
ini_set('display_errors', '1');
ini_set('log_errors', '1');
ini_set('memory_limit', -1);
ini_set('max_execution_time', 0);
//ini_set('memory_limit', -1);
//ini_set('max_execution_time', 0);
error_reporting(-1);
require_once __DIR__.'/../../vendor/autoload.php';
@ -43,6 +44,7 @@ require_once '../inc/lib/text.lib.php';
api_check_php_version('../inc/');
// Defaults settings
putenv("APP_LOCALE=en");
putenv("APP_URL_APPEND=''");
putenv("APP_ENCRYPT_METHOD='bcrypt'");
@ -51,15 +53,11 @@ putenv("DATABASE_PORT=");
putenv("DATABASE_NAME=");
putenv("DATABASE_USER=");
putenv("DATABASE_PASSWORD=");
putenv("APP_ENV=dev");
putenv("APP_DEBUG=1");
// Calling Symfony container
$kernel = new Chamilo\Kernel('dev', true);
$kernel->boot();
$container = $kernel->getContainer();
// Set container to use with chamilo legacy code
Container::setContainer($container);
ob_implicit_flush(true);
require_once api_get_path(LIBRARY_PATH).'database.constants.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
@ -67,6 +65,29 @@ require_once api_get_path(LIBRARY_PATH).'text.lib.php';
require_once api_get_path(LIBRARY_PATH).'banner.lib.php';
require_once 'install.lib.php';
$installationLanguage = 'en';
// Determination of the language during the installation procedure.
if (!empty($_POST['language_list'])) {
$search = ['../', '\\0'];
$installationLanguage = str_replace($search, '', urldecode($_POST['language_list']));
$_SESSION['install_language'] = $installationLanguage;
} else {
// Trying to switch to the browser's language, it is covenient for most of the cases.
$installationLanguage = detect_browser_language();
}
// Language validation.
if (!array_key_exists($installationLanguage, get_language_folder_list())) {
$installationLanguage = 'en';
}
// Set translation
$translator = new Translator($installationLanguage);
$translator->addLoader('po', new \Symfony\Component\Translation\Loader\PoFileLoader());
$translator->addResource('po', "../../translations/installation.$installationLanguage.po", $installationLanguage);
Container::$translator = $translator;
// The function api_get_setting() might be called within the installation scripts.
// We need to provide some limited support for it through initialization of the
// global array-type variable $_setting.
@ -84,9 +105,9 @@ $urlForm = '';
$pathForm = '';
$emailForm = '';
$dbHostForm = 'localhost';
$dbUsernameForm = '';
$dbUsernameForm = 'root';
$dbPassForm = '';
$dbNameForm = '';
$dbNameForm = 'chamilo';
$dbPortForm = 3306;
$allowSelfReg = '';
$allowSelfReg = 'approval';
@ -102,32 +123,16 @@ $educationForm = 'Albert Einstein';
$adminPhoneForm = '(000) 001 02 03';
$institutionForm = 'My Organisation';
$session_lifetime = 360000;
$installLanguage = Session::read('install_language');
$installLanguage = isset($_SESSION['install_language']) ? $_SESSION['install_language'] : 'english';
// Determination of the language during the installation procedure.
if (!empty($_POST['language_list'])) {
$search = ['../', '\\0'];
$install_language = str_replace($search, '', urldecode($_POST['language_list']));
Session::write('install_language', $install_language);
} elseif ($installLanguage) {
$install_language = $installLanguage;
} else {
// Trying to switch to the browser's language, it is covenient for most of the cases.
$install_language = detect_browser_language();
}
// Language validation.
if (!array_key_exists($install_language, get_language_folder_list())) {
$install_language = 'english';
}
$installationGuideLink = '../../documentation/installation_guide.html';
/*
// Loading language files.
require api_get_path(SYS_LANG_PATH).'english/trad4all.inc.php';
if ($install_language != 'english') {
include_once api_get_path(SYS_LANG_PATH).$install_language.'/trad4all.inc.php';
switch ($install_language) {
if ($installationLanguage != 'english') {
include_once api_get_path(SYS_LANG_PATH).$installationLanguage.'/trad4all.inc.php';
switch ($installationLanguage) {
case 'french':
$installationGuideLink = '../../documentation/installation_guide_fr_FR.html';
break;
@ -140,11 +145,7 @@ if ($install_language != 'english') {
default:
break;
}
}
// These global variables must be set for proper working of the function get_lang(...) during the installation.
$language_interface = $install_language;
$language_interface_initial_value = $install_language;
}*/
// Character set during the installation, it is always to be 'UTF-8'.
$charset = 'UTF-8';
@ -159,7 +160,8 @@ header('Content-Type: text/html; charset='.$charset);
error_reporting(E_ALL);
// Overriding the timelimit (for large campusses that have to be migrated).
@set_time_limit(0);
//@set_time_limit(0);
// Upgrading from any subversion of 1.9
$update_from_version_8 = [
@ -251,7 +253,6 @@ if (@$_POST['step2_install'] || @$_POST['step2_update_8'] || @$_POST['step2_upda
$installType = isset($_GET['installType']) ? $_GET['installType'] : null;
$updateFromConfigFile = isset($_GET['updateFromConfigFile']) ? $_GET['updateFromConfigFile'] : false;
}
if ($installType == 'update' && in_array($my_old_version, $update_from_version_8)) {
// This is the main configuration file of the system before the upgrade.
// Old configuration file.
@ -263,10 +264,6 @@ if ($installType == 'update' && in_array($my_old_version, $update_from_version_8
}
if (!isset($_GET['running'])) {
$dbUsernameForm = 'root';
$dbPassForm = '';
$dbNameForm = 'chamilo';
// Extract the path to append to the url if Chamilo is not installed on the web root directory.
$urlAppendPath = api_remove_trailing_slash(api_get_path(REL_PATH));
$urlForm = api_get_path(WEB_PATH);
@ -279,15 +276,16 @@ if (!isset($_GET['running'])) {
if (isset($email_parts[1]) && $email_parts[1] == 'localhost') {
$emailForm .= '.localdomain';
}
$adminLastName = get_lang('DefaultInstallAdminLastname');
$adminFirstName = get_lang('DefaultInstallAdminFirstname');
//$adminLastName = get_lang('DefaultInstallAdminLastname');
//$adminFirstName = get_lang('DefaultInstallAdminFirstname');
$adminLastName = 'admin';
$adminFirstName = 'admin';
$loginForm = 'admin';
$passForm = api_generate_password();
$institutionUrlForm = 'http://www.chamilo.org';
$languageForm = api_get_interface_language();
$checkEmailByHashSent = 0;
$ShowEmailNotCheckedToStudent = 1;
$userMailCanBeEmpty = 1;
@ -320,7 +318,6 @@ if (!isset($_GET['running'])) {
}
/* NEXT STEPS IMPLEMENTATION */
$total_steps = 7;
if (!$_POST) {
$current_step = 1;
@ -354,6 +351,7 @@ if ($encryptPassForm == '1') {
@import "../../public/build/css/base.css";
@import "../../public/build/css/themes/chamilo/default.css";
</style>
<script type="text/javascript" src="../../public/build/chamilo.js"></script>
<script type="text/javascript">
$(document).ready( function() {
@ -460,12 +458,14 @@ if ($installType == 'new') {
if (!empty($instalation_type_label) && empty($_POST['step6'])) {
echo '<div class="page-header"><h2>'.$instalation_type_label.'</h2></div>';
}
if (empty($installationProfile)) {
$installationProfile = '';
if (!empty($_POST['installationProfile'])) {
$installationProfile = api_htmlentities($_POST['installationProfile']);
}
}
?>
<input type="hidden" name="updatePath" value="<?php if (!$badUpdatePath) {
echo api_htmlentities($proposedUpdatePath, ENT_QUOTES);
@ -502,7 +502,7 @@ if (empty($installationProfile)) {
<?php
if (@$_POST['step2']) {
//STEP 3 : LICENSE
// STEP 3 : LICENSE
display_license_agreement();
} elseif (@$_POST['step3']) {
//STEP 4 : MYSQL DATABASE SETTINGS
@ -516,8 +516,8 @@ if (@$_POST['step2']) {
$installationProfile
);
} elseif (@$_POST['step4']) {
//STEP 5 : CONFIGURATION SETTINGS
//STEP 5 : CONFIGURATION SETTINGS
//if update, try getting settings from the database...
if ($installType == 'update') {
$db_name = $dbNameForm;
@ -763,7 +763,6 @@ if (@$_POST['step2']) {
if (!empty($f)) {
ob_flush(); //#5565
}
if ($installType == 'update') {
$database = connectToDatabase(
$dbHostForm,
@ -803,7 +802,7 @@ if (@$_POST['step2']) {
$envFile = api_get_path(SYS_PATH).'.env';
$distFile = api_get_path(SYS_PATH).'.env.dist';
$oldSession = $container->get('session');
//$oldSession = $container->get('session');
$params = [
'{{DATABASE_HOST}}' => $dbHostForm,
'{{DATABASE_PORT}}' => $dbPortForm,
@ -815,7 +814,7 @@ if (@$_POST['step2']) {
];
updateEnvFile($distFile, $envFile, $params);
(new Dotenv())->load($envFile);
exit;
// Load Symfony Kernel
$kernel = new Kernel('dev', true);
$application = new Application($kernel);
@ -824,6 +823,7 @@ if (@$_POST['step2']) {
$input = new ArrayInput([]);
$command = $application->find('doctrine:schema:create');
$result = $command->run($input, new ConsoleOutput());
var_dump($result);exit;
// No errors
if ($result == 0) {
// Boot kernel and get the doctrine from Symfony container
@ -832,10 +832,12 @@ if (@$_POST['step2']) {
$container->set('session', $oldSession);
Container::setContainer($container);
$doctrine = $container->get('doctrine');
$siteManager = $container->get('sonata.page.manager.site');
$manager = $doctrine->getManager();
$sysPath = api_get_path(SYS_PATH);
$settingsManager = $container->get('chamilo.settings.manager');
finishInstallationWithContainer(
$siteManager,
$settingsManager,
$manager,
$sysPath,
@ -872,19 +874,21 @@ if (@$_POST['step2']) {
} else {
// This is the start screen.
display_language_selection();
if (!empty($_GET['profile'])) {
$installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
}
echo '<input type="hidden" name="installationProfile" value="'.api_htmlentities($installationProfile, ENT_QUOTES).'" />';
}
$poweredBy = 'Powered by <a href="http://www.chamilo.org" target="_blank"> Chamilo </a> &copy; '.date('Y');
$poweredBy = 'Powered by <a href="http://www.chamilo.org" target="_blank"> Chamilo </a> &copy; '.date('Y');
?>
</form>
</div>
<div class="col-md-4">
<div class="logo-install">
<img src="<?php echo api_get_path(WEB_CSS_PATH) ?>themes/chamilo/images/header-logo.png" hspace="10" vspace="10" alt="Chamilo" />
<img src="header-logo.png" hspace="10" vspace="10" alt="Chamilo" />
</div>
<div class="well install-steps-menu">
<ol>
@ -905,7 +909,6 @@ $poweredBy = 'Powered by <a href="http://www.chamilo.org" target="_blank"> Chami
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-body">
<div class="col-md-12">

@ -251,7 +251,7 @@ function detect_browser_language()
'yo' => 'yoruba'
];
$system_available_languages = & get_language_folder_list();
$system_available_languages = get_language_folder_list();
$accept_languages = strtolower(str_replace('_', '-', $_SERVER['HTTP_ACCEPT_LANGUAGE']));
foreach ($language_index as $code => $language) {
if (strpos($accept_languages, $code) === 0) {
@ -411,34 +411,65 @@ function write_system_config_file($path)
/**
* Returns a list of language directories.
*/
function & get_language_folder_list()
function get_language_folder_list()
{
static $result;
if (!is_array($result)) {
$result = [];
$exceptions = ['.', '..', 'CVS', '.svn'];
$search = ['_latin', '_unicode', '_corporate', '_org', '_KM', '_'];
$replace_with = [' (Latin)', ' (unicode)', ' (corporate)', ' (org)', ' (KM)', ' '];
$dirname = api_get_path(SYS_LANG_PATH);
$handle = opendir($dirname);
while ($entries = readdir($handle)) {
if (in_array($entries, $exceptions)) {
continue;
}
if (is_dir($dirname.$entries)) {
if (is_file($dirname.$entries.'/install_disabled')) {
// Skip all languages that have this file present, just for
// the install process (languages incomplete)
continue;
}
$result[$entries] = ucwords(str_replace($search, $replace_with, $entries));
}
}
closedir($handle);
asort($result);
}
return [
'ar' => 'arabic',
'ast' => 'asturian',
'bg' => 'bulgarian',
'bs' => 'bosnian',
'ca' => 'catalan',
'zh' => 'simpl_chinese',
'zh-tw' => 'trad_chinese',
'cs' => 'czech',
'da' => 'danish',
'prs' => 'dari',
'de' => 'german',
'el' => 'greek',
'en' => 'english',
'es' => 'spanish',
'eo' => 'esperanto',
'eu' => 'basque',
'fa' => 'persian',
'fr' => 'french',
'fur' => 'friulian',
'gl' => 'galician',
'ka' => 'georgian',
'hr' => 'croatian',
'he' => 'hebrew',
'hi' => 'hindi',
'id' => 'indonesian',
'it' => 'italian',
'ko' => 'korean',
'lv' => 'latvian',
'lt' => 'lithuanian',
'mk' => 'macedonian',
'hu' => 'hungarian',
'ms' => 'malay',
'nl' => 'dutch',
'ja' => 'japanese',
'no' => 'norwegian',
'oc' => 'occitan',
'ps' => 'pashto',
'pl' => 'polish',
'pt' => 'portuguese',
'pt-br' => 'brazilian',
'ro' => 'romanian',
'qu' => 'quechua_cusco',
'ru' => 'russian',
'sk' => 'slovak',
'sl' => 'slovenian',
'sr' => 'serbian',
'fi' => 'finnish',
'sv' => 'swedish',
'th' => 'thai',
'tr' => 'turkish',
'uk' => 'ukrainian',
'vi' => 'vietnamese',
'sw' => 'swahili',
'yo' => 'yoruba'
];
return $result;
}
/**
@ -582,20 +613,9 @@ function display_language_selection_box(
// Reading language list.
$language_list = get_language_folder_list();
/*
// Reduction of the number of languages shown. Enable this fragment of code for customization purposes.
// Modify the language list according to your preference. Don't exclude the 'english' item.
$language_to_display = array('asturian', 'bulgarian', 'english', 'italian', 'french', 'slovenian', 'slovenian_unicode', 'spanish');
foreach ($language_list as $key => & $value) {
if (!in_array($key, $language_to_display)) {
unset($language_list[$key]);
}
}
*/
// Sanity checks due to the possibility for customizations.
if (!is_array($language_list) || empty($language_list)) {
$language_list = ['english' => 'English'];
$language_list = ['en' => 'English'];
}
// Sorting again, if it is necessary.
@ -603,8 +623,8 @@ function display_language_selection_box(
// More sanity checks.
if (!array_key_exists($default_language, $language_list)) {
if (array_key_exists('english', $language_list)) {
$default_language = 'english';
if (array_key_exists('en', $language_list)) {
$default_language = 'en';
} else {
$language_keys = array_keys($language_list);
$default_language = $language_keys[0];
@ -706,7 +726,6 @@ function display_requirements(
// SERVER REQUIREMENTS
echo '<div class="RequirementHeading"><h4>'.get_lang('ServerRequirements').'</h4>';
$timezone = checkPhpSettingExists("date.timezone");
if (!$timezone) {
echo "<div class='alert alert-warning'>".
@ -1026,8 +1045,8 @@ function display_requirements(
} else {
$error = false;
// First, attempt to set writing permissions if we don't have them yet
$perm = api_get_permissions_for_new_directories();
$perm_file = api_get_permissions_for_new_files();
$perm = octdec('0770');
$perm_file = octdec('0770');
$notWritable = [];
$checked_writable = api_get_path(SYS_APP_PATH);
@ -1059,7 +1078,6 @@ function display_requirements(
}
// Second, if this fails, report an error
//--> The user would have to adjust the permissions manually
if (count($notWritable) > 0) {
$error = true; ?>
@ -2727,6 +2745,7 @@ function updateEnvFile($distFile, $envFile, $params)
* @param string $installationProfile Installation profile, if any was provided
*/
function finishInstallationWithContainer(
$siteManager,
$settingsManager,
$manager,
$sysPath,
@ -2857,6 +2876,17 @@ function finishInstallationWithContainer(
$result->execute();
$result->closeCursor();
/** @var Chamilo\PageBundle\Entity\Site $site */
$site = $siteManager->create();
$site->setHost('localhost');
$site->setEnabled(true);
$site->setName('localhost');
$site->setEnabledFrom(new \DateTime('now'));
$site->setEnabledTo(new \DateTime('+20 years'));
$site->setRelativePath("");
$site->setIsDefault(true);
$siteManager->save($site);
UserManager::setPasswordEncryption($encryptPassForm);
// Create admin user.

@ -212,12 +212,13 @@ class Virtual
try {
$database = new \Database();
$connection = $database->connect(
$database->connect(
$dbParams,
$_configuration['root_sys'],
$_configuration['root_sys'],
true
);
$connection = $database->getConnection();
} catch (Exception $e) {
echo('Side connection failure with '.$_configuration['db_host'].', '.$_configuration['db_user'].', ******** ');
die();
@ -886,7 +887,7 @@ class Virtual
try {
$database = new \Database();
$manager = $database->connect(
$database->connect(
$dbParams,
api_get_configuration_value('root_sys'),
api_get_configuration_value('root_sys'),
@ -894,11 +895,12 @@ class Virtual
true
);
$manager = $database->getManager();
if ($getManager) {
return $manager;
}
return $manager->getConnection();
return $database->getConnection();
} catch (Exception $e) {
error_log($e->getMessage());
}

@ -39,14 +39,14 @@ $dbParams = [
try {
$database = new \Database();
$connection = $database->connect(
$database->connect(
$dbParams,
$_configuration['root_sys'],
$_configuration['root_sys'],
true
);
$list = $connection->getSchemaManager()->listDatabases();
$list = $database->getConnection()->getSchemaManager()->listDatabases();
echo $plugin->get_lang('connectionok');
} catch (Exception $e) {
echo $plugin->get_lang('badconnection');

@ -0,0 +1,4 @@
msgid "InstallationLanguage"
msgstr "Installation language"

@ -0,0 +1,9 @@
msgid "InstallationLanguage"
msgstr "Langue d'installation"
msgid "Requirements"
msgstr "Pré-requis"
msgid "PleaseSelectInstallationProcessLanguage"
msgstr "Veuillez sélectionner la langue de l'installateur"
Loading…
Cancel
Save