mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Hardcoding locales in installer, because we can't include i18n
properly, and including core/Core.php is too much.
This commit is contained in:
parent
ad2a21cc92
commit
5f73643e3f
@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// Register the SilverStripe provided databases
|
// Register the SilverStripe provided databases
|
||||||
|
$frameworkPath = defined('FRAMEWORK_PATH') ? FRAMEWORK_PATH : FRAMEWORK_NAME;
|
||||||
|
|
||||||
DatabaseAdapterRegistry::register(
|
DatabaseAdapterRegistry::register(
|
||||||
array(
|
array(
|
||||||
'class' => 'MySQLDatabase',
|
'class' => 'MySQLDatabase',
|
||||||
'title' => 'MySQL 5.0+',
|
'title' => 'MySQL 5.0+',
|
||||||
'helperPath' => FRAMEWORK_PATH . '/dev/install/MySQLDatabaseConfigurationHelper.php',
|
'helperPath' => $frameworkPath . '/dev/install/MySQLDatabaseConfigurationHelper.php',
|
||||||
'supported' => function_exists('mysql_connect'),
|
'supported' => function_exists('mysql_connect'),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -327,6 +327,14 @@ function getTempFolder($base = null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$worked) {
|
||||||
|
throw new Exception(
|
||||||
|
'Permission problem gaining access to a temp folder. ' .
|
||||||
|
'Please create a folder named silverstripe-cache in the base folder ' .
|
||||||
|
'of the installation and ensure it has the correct permissions'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return $ssTmp;
|
return $ssTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@ ini_set('mysql.connect_timeout', 5);
|
|||||||
|
|
||||||
ini_set('max_execution_time', 0);
|
ini_set('max_execution_time', 0);
|
||||||
|
|
||||||
|
error_reporting(E_ALL | E_STRICT);
|
||||||
|
|
||||||
// Include environment files
|
// Include environment files
|
||||||
$usingEnv = false;
|
$usingEnv = false;
|
||||||
$envFileExists = false;
|
$envFileExists = false;
|
||||||
@ -40,21 +42,95 @@ if($envFileExists) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// include the core of the framework, we need this for dependencies like i18n, include paths etc
|
require_once FRAMEWORK_NAME . '/dev/install/DatabaseConfigurationHelper.php';
|
||||||
include_once(FRAMEWORK_NAME . '/core/Core.php');
|
require_once FRAMEWORK_NAME . '/dev/install/DatabaseAdapterRegistry.php';
|
||||||
|
|
||||||
// Set default locale, but try and sniff from the user agent
|
// Set default locale, but try and sniff from the user agent
|
||||||
$locales = i18n::$common_locales;
|
$defaultLocale = 'en_US';
|
||||||
$defaultLocale = i18n::get_locale();
|
$locales = array(
|
||||||
if(isset($_SERVER['HTTP_USER_AGENT'])) {
|
'af_ZA' => array('Afrikaans', 'Afrikaans'),
|
||||||
foreach($locales as $code => $details) {
|
'sq_AL' => array('Albanian', 'shqip'),
|
||||||
$bits = explode('_', $code);
|
'ar_EG' => array('Arabic', 'العربية'),
|
||||||
if(preg_match("/{$bits[0]}.{$bits[1]}/", $_SERVER['HTTP_USER_AGENT'])) {
|
'eu_ES' => array('Basque', 'euskera'),
|
||||||
$defaultLocale = $code;
|
'be_BY' => array('Belarusian', 'Беларуская мова'),
|
||||||
break;
|
'bn_BD' => array('Bengali', 'বাংলা'),
|
||||||
}
|
'bg_BG' => array('Bulgarian', 'български'),
|
||||||
}
|
'ca_ES' => array('Catalan', 'català'),
|
||||||
}
|
'zh_yue' => array('Chinese (Cantonese)', '廣東話 [广东话]'),
|
||||||
|
'zh_cmn' => array('Chinese (Mandarin)', '普通話 [普通话]'),
|
||||||
|
'hr_HR' => array('Croatian', 'Hrvatski'),
|
||||||
|
'cs_CZ' => array('Czech', 'čeština'),
|
||||||
|
'cy_GB' => array('Welsh', 'Welsh/Cymraeg'),
|
||||||
|
'da_DK' => array('Danish', 'dansk'),
|
||||||
|
'nl_NL' => array('Dutch', 'Nederlands'),
|
||||||
|
'en_NZ' => array('English (NZ)', 'English (NZ)'),
|
||||||
|
'en_US' => array('English (US)', 'English (US)'),
|
||||||
|
'en_GB' => array('English (UK)', 'English (UK)'),
|
||||||
|
'eo_XX' => array('Esperanto', 'Esperanto'),
|
||||||
|
'et_EE' => array('Estonian', 'eesti keel'),
|
||||||
|
'fo_FO' => array('Faroese', 'Føroyska'),
|
||||||
|
'fi_FI' => array('Finnish', 'suomi'),
|
||||||
|
'fr_FR' => array('French', 'français'),
|
||||||
|
'gd_GB' => array('Gaelic', 'Gaeilge'),
|
||||||
|
'gl_ES' => array('Galician', 'Galego'),
|
||||||
|
'de_DE' => array('German', 'Deutsch'),
|
||||||
|
'el_GR' => array('Greek', 'ελληνικά'),
|
||||||
|
'gu_IN' => array('Gujarati', 'ગુજરાતી'),
|
||||||
|
'ha_NG' => array('Hausa', 'حَوْسَ'),
|
||||||
|
'he_IL' => array('Hebrew', 'עברית'),
|
||||||
|
'hi_IN' => array('Hindi', 'हिन्दी'),
|
||||||
|
'hu_HU' => array('Hungarian', 'magyar'),
|
||||||
|
'is_IS' => array('Icelandic', 'Íslenska'),
|
||||||
|
'id_ID' => array('Indonesian', 'Bahasa Indonesia'),
|
||||||
|
'ga_IE' => array('Irish', 'Irish'),
|
||||||
|
'it_IT' => array('Italian', 'italiano'),
|
||||||
|
'ja_JP' => array('Japanese', '日本語'),
|
||||||
|
'jv_ID' => array('Javanese', 'basa Jawa'),
|
||||||
|
'ko_KR' => array('Korean', '한국어 [韓國語]'),
|
||||||
|
'ku_IQ' => array('Kurdish', 'Kurdí'),
|
||||||
|
'lv_LV' => array('Latvian', 'latviešu'),
|
||||||
|
'lt_LT' => array('Lithuanian', 'lietuviškai'),
|
||||||
|
'mk_MK' => array('Macedonian', 'македонски'),
|
||||||
|
'mi_NZ' => array('Maori', 'Maori'),
|
||||||
|
'ms_MY' => array('Malay', 'Bahasa melayu'),
|
||||||
|
'mt_MT' => array('Maltese', 'Malti'),
|
||||||
|
'mr_IN' => array('Marathi', 'मराठी'),
|
||||||
|
'ne_NP' => array('Nepali', 'नेपाली'),
|
||||||
|
'nb_NO' => array('Norwegian', 'Norsk'),
|
||||||
|
'om_ET' => array('Oromo', 'Afaan Oromo'),
|
||||||
|
'fa_IR' => array('Persian', 'فارسى'),
|
||||||
|
'pl_PL' => array('Polish', 'polski'),
|
||||||
|
'pt_PT' => array('Portuguese (Portugal)', 'português (Portugal)'),
|
||||||
|
'pt_BR' => array('Portuguese (Brazil)', 'português (Brazil)'),
|
||||||
|
'pa_IN' => array('Punjabi', 'ਪੰਜਾਬੀ'),
|
||||||
|
'qu_PE' => array('Quechua', 'Quechua'),
|
||||||
|
'rm_CH' => array('Romansh', 'rumantsch'),
|
||||||
|
'ro_RO' => array('Romanian', 'român'),
|
||||||
|
'ru_RU' => array('Russian', 'Русский'),
|
||||||
|
'sco_SCO' => array('Scots', 'Scoats leid, Lallans'),
|
||||||
|
'sr_RS' => array('Serbian', 'српски'),
|
||||||
|
'sk_SK' => array('Slovak', 'slovenčina'),
|
||||||
|
'sl_SI' => array('Slovenian', 'slovenščina'),
|
||||||
|
'es_ES' => array('Spanish', 'español'),
|
||||||
|
'sv_SE' => array('Swedish', 'Svenska'),
|
||||||
|
'tl_PH' => array('Tagalog', 'Tagalog'),
|
||||||
|
'ta_IN' => array('Tamil', 'தமிழ்'),
|
||||||
|
'te_IN' => array('Telugu', 'తెలుగు'),
|
||||||
|
'to_TO' => array('Tonga', 'chiTonga'),
|
||||||
|
'ts_ZA' => array('Tsonga', 'xiTshonga'),
|
||||||
|
'tn_ZA' => array('Tswana', 'seTswana'),
|
||||||
|
'tr_TR' => array('Turkish', 'Türkçe'),
|
||||||
|
'tk_TM' => array('Turkmen', 'түркmенче'),
|
||||||
|
'tw_GH' => array('Twi', 'twi'),
|
||||||
|
'uk_UA' => array('Ukrainian', 'Українська'),
|
||||||
|
'ur_PK' => array('Urdu', 'اردو'),
|
||||||
|
'uz_UZ' => array('Uzbek', 'ўзбек'),
|
||||||
|
've_ZA' => array('Venda', 'tshiVenḓa'),
|
||||||
|
'vi_VN' => array('Vietnamese', 'tiếng việt'),
|
||||||
|
'wo_SN' => array('Wolof', 'Wollof'),
|
||||||
|
'xh_ZA' => array('Xhosa', 'isiXhosa'),
|
||||||
|
'zu_ZA' => array('Zulu', 'isiZulu'),
|
||||||
|
);
|
||||||
|
|
||||||
// Discover which databases are available
|
// Discover which databases are available
|
||||||
DatabaseAdapterRegistry::autodiscover();
|
DatabaseAdapterRegistry::autodiscover();
|
||||||
@ -339,7 +415,7 @@ class InstallRequirements {
|
|||||||
}
|
}
|
||||||
$this->requireWriteable('assets', array("File permissions", "Is the assets/ directory writeable?", null));
|
$this->requireWriteable('assets', array("File permissions", "Is the assets/ directory writeable?", null));
|
||||||
|
|
||||||
$tempFolder = getTempFolder();
|
$tempFolder = $this->getTempFolder();
|
||||||
$this->requireTempFolder(array('File permissions', 'Is a temporary directory available?', null, $tempFolder));
|
$this->requireTempFolder(array('File permissions', 'Is a temporary directory available?', null, $tempFolder));
|
||||||
if($tempFolder) {
|
if($tempFolder) {
|
||||||
// in addition to the temp folder being available, check it is writable
|
// in addition to the temp folder being available, check it is writable
|
||||||
@ -653,14 +729,36 @@ class InstallRequirements {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getTempFolder() {
|
||||||
|
$sysTmp = sys_get_temp_dir();
|
||||||
|
$worked = true;
|
||||||
|
$ssTmp = "$sysTmp/silverstripe-cache";
|
||||||
|
|
||||||
|
if(!@file_exists($ssTmp)) {
|
||||||
|
@$worked = mkdir($ssTmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$worked) {
|
||||||
|
$ssTmp = dirname($_SERVER['SCRIPT_FILENAME']) . '/silverstripe-cache';
|
||||||
|
$worked = true;
|
||||||
|
if(!@file_exists($ssTmp)) {
|
||||||
|
@$worked = mkdir($ssTmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($worked) return $ssTmp;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
function requireTempFolder($testDetails) {
|
function requireTempFolder($testDetails) {
|
||||||
$this->testing($testDetails);
|
$this->testing($testDetails);
|
||||||
|
|
||||||
$tempFolder = getTempFolder();
|
$tempFolder = $this->getTempFolder();
|
||||||
if(!$tempFolder) {
|
if(!$tempFolder) {
|
||||||
$testDetails[2] = "Permission problem gaining access to a temp directory. " .
|
$testDetails[2] = "Permission problem gaining access to a temp directory. " .
|
||||||
"Please create a folder named silverstripe-cache in the base directory " .
|
"Please create a folder named silverstripe-cache in the base directory " .
|
||||||
"of the installation and ensure it has the adequate permissions";
|
"of the installation and ensure it has the adequate permissions.";
|
||||||
$this->error($testDetails);
|
$this->error($testDetails);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1071,6 +1169,8 @@ PHP
|
|||||||
|
|
||||||
$this->statusMessage("Building database schema...");
|
$this->statusMessage("Building database schema...");
|
||||||
|
|
||||||
|
require_once 'core/Core.php';
|
||||||
|
|
||||||
// Build database
|
// Build database
|
||||||
$con = new Controller();
|
$con = new Controller();
|
||||||
$con->pushCurrent();
|
$con->pushCurrent();
|
||||||
|
Loading…
Reference in New Issue
Block a user