Skip to content
This repository
Browse code

BUGFIX Hardcoding locales in installer, because we can't include i18n

properly, and including core/Core.php is too much.
  • Loading branch information...
commit 5f73643e3f82e3d53545cf96004f6be62e307ec4 1 parent ad2a21c
Sean Harvey authored April 17, 2012
4  _register_database.php
... ...
@@ -1,11 +1,13 @@
1 1
 <?php
2 2
 
3 3
 // Register the SilverStripe provided databases
  4
+$frameworkPath = defined('FRAMEWORK_PATH') ? FRAMEWORK_PATH : FRAMEWORK_NAME;
  5
+
4 6
 DatabaseAdapterRegistry::register(
5 7
 	array(
6 8
 		'class' => 'MySQLDatabase',
7 9
 		'title' => 'MySQL 5.0+',
8  
-		'helperPath' => FRAMEWORK_PATH . '/dev/install/MySQLDatabaseConfigurationHelper.php',
  10
+		'helperPath' => $frameworkPath . '/dev/install/MySQLDatabaseConfigurationHelper.php',
9 11
 		'supported' => function_exists('mysql_connect'),
10 12
 	)
11 13
 );
8  core/Core.php
@@ -327,6 +327,14 @@ function getTempFolder($base = null) {
327 327
 		}
328 328
 	}
329 329
 
  330
+	if(!$worked) {
  331
+		throw new Exception(
  332
+			'Permission problem gaining access to a temp folder. ' .
  333
+			'Please create a folder named silverstripe-cache in the base folder ' .
  334
+			'of the installation and ensure it has the correct permissions'
  335
+		);
  336
+	}
  337
+
330 338
 	return $ssTmp;
331 339
 }
332 340
 
132  dev/install/install.php5
@@ -19,6 +19,8 @@ ini_set('mysql.connect_timeout', 5);
19 19
 
20 20
 ini_set('max_execution_time', 0);
21 21
 
  22
+error_reporting(E_ALL | E_STRICT);
  23
+
22 24
 // Include environment files
23 25
 $usingEnv = false;
24 26
 $envFileExists = false;
@@ -40,21 +42,95 @@ if($envFileExists) {
40 42
 	}
41 43
 }
42 44
 
43  
-// include the core of the framework, we need this for dependencies like i18n, include paths etc
44  
-include_once(FRAMEWORK_NAME . '/core/Core.php');
  45
+require_once FRAMEWORK_NAME . '/dev/install/DatabaseConfigurationHelper.php';
  46
+require_once FRAMEWORK_NAME . '/dev/install/DatabaseAdapterRegistry.php';
45 47
 
46 48
 // Set default locale, but try and sniff from the user agent
47  
-$locales = i18n::$common_locales;
48  
-$defaultLocale = i18n::get_locale();
49  
-if(isset($_SERVER['HTTP_USER_AGENT'])) {
50  
-	foreach($locales as $code => $details) {
51  
-		$bits = explode('_', $code);
52  
-		if(preg_match("/{$bits[0]}.{$bits[1]}/", $_SERVER['HTTP_USER_AGENT'])) {
53  
-			$defaultLocale = $code;
54  
-			break;
55  
-		}
56  
-	}
57  
-}
  49
+$defaultLocale = 'en_US';
  50
+$locales = array(
  51
+	'af_ZA' => array('Afrikaans', 'Afrikaans'),
  52
+	'sq_AL' => array('Albanian', 'shqip'),
  53
+	'ar_EG' => array('Arabic', '&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577;'),
  54
+	'eu_ES' => array('Basque', 'euskera'),
  55
+	'be_BY' => array('Belarusian', '&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; &#1084;&#1086;&#1074;&#1072;'),
  56
+	'bn_BD' => array('Bengali', '&#2476;&#2494;&#2434;&#2482;&#2494;'),
  57
+	'bg_BG' => array('Bulgarian', '&#1073;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080;'),
  58
+	'ca_ES' => array('Catalan', 'catal&agrave;'),
  59
+	'zh_yue' => array('Chinese (Cantonese)', '&#24291;&#26481;&#35441; [&#24191;&#19996;&#35805;]'),
  60
+	'zh_cmn' => array('Chinese (Mandarin)', '&#26222;&#36890;&#35441; [&#26222;&#36890;&#35805;]'),
  61
+	'hr_HR' => array('Croatian', 'Hrvatski'),
  62
+	'cs_CZ' => array('Czech', '&#x010D;e&#353;tina'),
  63
+	'cy_GB' => array('Welsh', 'Welsh/Cymraeg'),
  64
+	'da_DK' => array('Danish', 'dansk'),
  65
+	'nl_NL' => array('Dutch', 'Nederlands'),
  66
+	'en_NZ' => array('English (NZ)', 'English (NZ)'),
  67
+	'en_US' => array('English (US)', 'English (US)'),
  68
+	'en_GB' => array('English (UK)', 'English (UK)'),
  69
+	'eo_XX' => array('Esperanto', 'Esperanto'),
  70
+	'et_EE' => array('Estonian', 'eesti keel'),
  71
+	'fo_FO' => array('Faroese', 'F&oslash;royska'),
  72
+	'fi_FI' => array('Finnish', 'suomi'),
  73
+	'fr_FR' => array('French', 'fran&ccedil;ais'),
  74
+	'gd_GB' => array('Gaelic', 'Gaeilge'),
  75
+	'gl_ES' => array('Galician', 'Galego'),
  76
+	'de_DE' => array('German', 'Deutsch'),
  77
+	'el_GR' => array('Greek', '&#949;&#955;&#955;&#951;&#957;&#953;&#954;&#940;'),
  78
+	'gu_IN' => array('Gujarati', '&#2711;&#2753;&#2716;&#2736;&#2750;&#2724;&#2752;'),
  79
+	'ha_NG' => array('Hausa', '&#1581;&#1614;&#1608;&#1618;&#1587;&#1614;'),
  80
+	'he_IL' => array('Hebrew', '&#1506;&#1489;&#1512;&#1497;&#1514;'),
  81
+	'hi_IN' => array('Hindi', '&#2361;&#2367;&#2344;&#2381;&#2342;&#2368;'),
  82
+	'hu_HU' => array('Hungarian', 'magyar'),
  83
+	'is_IS' => array('Icelandic', '&Iacute;slenska'),
  84
+	'id_ID' => array('Indonesian', 'Bahasa Indonesia'),
  85
+	'ga_IE' => array('Irish', 'Irish'),
  86
+	'it_IT' => array('Italian', 'italiano'),
  87
+	'ja_JP' => array('Japanese', '&#26085;&#26412;&#35486;'),
  88
+	'jv_ID' => array('Javanese', 'basa Jawa'),
  89
+	'ko_KR' => array('Korean', '&#54620;&#44397;&#50612; [&#38867;&#22283;&#35486;]'),
  90
+	'ku_IQ' => array('Kurdish', 'Kurd&iacute;'),
  91
+	'lv_LV' => array('Latvian', 'latvie&#353;u'),
  92
+	'lt_LT' => array('Lithuanian', 'lietuvi&#353;kai'),
  93
+	'mk_MK' => array('Macedonian', '&#1084;&#1072;&#1082;&#1077;&#1076;&#1086;&#1085;&#1089;&#1082;&#1080;'),
  94
+	'mi_NZ' => array('Maori', 'Maori'),
  95
+	'ms_MY' => array('Malay', 'Bahasa melayu'),
  96
+	'mt_MT' => array('Maltese', 'Malti'),
  97
+	'mr_IN' => array('Marathi', '&#2350;&#2352;&#2366;&#2336;&#2368;'),
  98
+	'ne_NP' => array('Nepali', '&#2344;&#2375;&#2346;&#2366;&#2354;&#2368;'),
  99
+	'nb_NO' => array('Norwegian', 'Norsk'),
  100
+	'om_ET' => array('Oromo', 'Afaan Oromo'),
  101
+	'fa_IR' => array('Persian', '&#1601;&#1575;&#1585;&#1587;&#1609;'),
  102
+	'pl_PL' => array('Polish', 'polski'),
  103
+	'pt_PT' => array('Portuguese (Portugal)', 'portugu&ecirc;s (Portugal)'),
  104
+	'pt_BR' => array('Portuguese (Brazil)', 'portugu&ecirc;s (Brazil)'),
  105
+	'pa_IN' => array('Punjabi', '&#2602;&#2672;&#2588;&#2622;&#2604;&#2624;'),
  106
+	'qu_PE' => array('Quechua', 'Quechua'),
  107
+	'rm_CH' => array('Romansh', 'rumantsch'),
  108
+	'ro_RO' => array('Romanian', 'rom&acirc;n'),
  109
+	'ru_RU' => array('Russian', '&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;'),
  110
+	'sco_SCO' => array('Scots', 'Scoats leid, Lallans'),
  111
+	'sr_RS' => array('Serbian', '&#1089;&#1088;&#1087;&#1089;&#1082;&#1080;'),
  112
+	'sk_SK' => array('Slovak', 'sloven&#269;ina'),
  113
+	'sl_SI' => array('Slovenian', 'sloven&#353;&#269;ina'),
  114
+	'es_ES' => array('Spanish', 'espa&ntilde;ol'),
  115
+	'sv_SE' => array('Swedish', 'Svenska'),
  116
+	'tl_PH' => array('Tagalog', 'Tagalog'),
  117
+	'ta_IN' => array('Tamil', '&#2980;&#2990;&#3007;&#2996;&#3021;'),
  118
+	'te_IN' => array('Telugu', '&#3108;&#3142;&#3122;&#3137;&#3095;&#3137;'),
  119
+	'to_TO' => array('Tonga', 'chiTonga'),
  120
+	'ts_ZA' => array('Tsonga', 'xiTshonga'),
  121
+	'tn_ZA' => array('Tswana', 'seTswana'),
  122
+	'tr_TR' => array('Turkish', 'T&uuml;rk&ccedil;e'),
  123
+	'tk_TM' => array('Turkmen', '&#1090;&#1199;&#1088;&#1082;m&#1077;&#1085;&#1095;&#1077;'),
  124
+	'tw_GH' => array('Twi', 'twi'),
  125
+	'uk_UA' => array('Ukrainian', '&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072;'),
  126
+	'ur_PK' => array('Urdu', '&#1575;&#1585;&#1583;&#1608;'),
  127
+	'uz_UZ' => array('Uzbek', '&#1118;&#1079;&#1073;&#1077;&#1082;'),
  128
+	've_ZA' => array('Venda', 'tshiVen&#x1E13;a'),
  129
+	'vi_VN' => array('Vietnamese', 'ti&#7871;ng vi&#7879;t'),
  130
+	'wo_SN' => array('Wolof', 'Wollof'),
  131
+	'xh_ZA' => array('Xhosa', 'isiXhosa'),
  132
+	'zu_ZA' => array('Zulu', 'isiZulu'),
  133
+);
58 134
 
59 135
 // Discover which databases are available
60 136
 DatabaseAdapterRegistry::autodiscover();
@@ -339,7 +415,7 @@ class InstallRequirements {
339 415
 		}
340 416
 		$this->requireWriteable('assets', array("File permissions", "Is the assets/ directory writeable?", null));
341 417
 
342  
-		$tempFolder = getTempFolder();
  418
+		$tempFolder = $this->getTempFolder();
343 419
 		$this->requireTempFolder(array('File permissions', 'Is a temporary directory available?', null, $tempFolder));
344 420
 		if($tempFolder) {
345 421
 			// in addition to the temp folder being available, check it is writable
@@ -653,14 +729,36 @@ class InstallRequirements {
653 729
 		}
654 730
 	}
655 731
 
  732
+	function getTempFolder() {
  733
+		$sysTmp = sys_get_temp_dir();
  734
+		$worked = true;
  735
+		$ssTmp = "$sysTmp/silverstripe-cache";
  736
+
  737
+		if(!@file_exists($ssTmp)) {
  738
+			@$worked = mkdir($ssTmp);
  739
+		}
  740
+
  741
+		if(!$worked) {
  742
+			$ssTmp = dirname($_SERVER['SCRIPT_FILENAME']) . '/silverstripe-cache';
  743
+			$worked = true;
  744
+			if(!@file_exists($ssTmp)) {
  745
+				@$worked = mkdir($ssTmp);
  746
+			}
  747
+		}
  748
+
  749
+		if($worked) return $ssTmp;
  750
+
  751
+		return false;
  752
+	}
  753
+
656 754
 	function requireTempFolder($testDetails) {
657 755
 		$this->testing($testDetails);
658 756
 
659  
-		$tempFolder = getTempFolder();
  757
+		$tempFolder = $this->getTempFolder();
660 758
 		if(!$tempFolder) {
661 759
 			$testDetails[2] = "Permission problem gaining access to a temp directory. " .
662 760
 				"Please create a folder named silverstripe-cache in the base directory " .
663  
-				"of the installation and ensure it has the adequate permissions";
  761
+				"of the installation and ensure it has the adequate permissions.";
664 762
 			$this->error($testDetails);
665 763
 		}
666 764
 	}
@@ -1071,6 +1169,8 @@ PHP
1071 1169
 
1072 1170
 		$this->statusMessage("Building database schema...");
1073 1171
 
  1172
+		require_once 'core/Core.php';
  1173
+
1074 1174
 		// Build database
1075 1175
 		$con = new Controller();
1076 1176
 		$con->pushCurrent();

0 notes on commit 5f73643

Please sign in to comment.
Something went wrong with that request. Please try again.