Revision 1885
Added by Dietmar over 11 years ago
initialize.php | ||
---|---|---|
114 | 114 |
if(is_readable($sSetupFile)) { |
115 | 115 |
$aCfg = parse_ini_file($sSetupFile, true); |
116 | 116 |
foreach($aCfg['Constants'] as $key=>$value) { |
117 |
if($key == 'debug') { $value = filter_var($value, FILTER_VALIDATE_BOOLEAN); } |
|
118 |
if(!defined(strtoupper($key))) { define(strtoupper($key), $value); } |
|
117 |
switch($key): |
|
118 |
case 'DEBUG': |
|
119 |
$value = filter_var($value, FILTER_VALIDATE_BOOLEAN); |
|
120 |
break; |
|
121 |
case 'WB_URL': |
|
122 |
case 'AppUrl': |
|
123 |
$value = trim(str_replace('\\', '/', $value), '/'); |
|
124 |
if(!defined('WB_URL')) { define('WB_URL', $value); } |
|
125 |
break; |
|
126 |
case 'ADMIN_DIRECTORY': |
|
127 |
case 'AcpDir': |
|
128 |
$value = trim(str_replace('\\', '/', $value), '/'); |
|
129 |
if(!defined('ADMIN_DIRECTORY')) { define('ADMIN_DIRECTORY', $value); } |
|
130 |
break; |
|
131 |
default: |
|
132 |
if(!defined($key)) { define($key, $value); } |
|
133 |
break; |
|
134 |
endswitch; |
|
119 | 135 |
} |
120 | 136 |
$db = $aCfg['DataBase']; |
121 | 137 |
$db['type'] = isset($db['type']) ? $db['type'] : 'mysql'; |
... | ... | |
135 | 151 |
$aRetval[2] = array( 'user' => $db['user'], 'pass' => $db['pass']); |
136 | 152 |
}else { // $sRetvalType == 'url' |
137 | 153 |
$aRetval[0] = $db['type'].'://'.$db['user'].':'.$db['pass'].'@' |
138 |
. $db['host'].($db['port'] != '' ? ':'.$db['port'] : '').'/'.$db['name']; |
|
154 |
. $db['host'].($db['port'] != '' ? ':'.$db['port'] : '').'/'.$db['name'] |
|
155 |
. '?Charset='.$db['charset'].'&TablePrefix='.$db['table_prefix']; |
|
139 | 156 |
} |
140 | 157 |
unset($db, $aCfg); |
141 | 158 |
return $aRetval; |
... | ... | |
159 | 176 |
} |
160 | 177 |
// load db configuration --- |
161 | 178 |
if(defined('DB_TYPE')) { |
162 |
$aSqlData = array( 0 => DB_TYPE.'://'.DB_USERNAME.':'.DB_PASSWORD.'@'.DB_HOST.'/'.DB_NAME); |
|
179 |
$sTmp = ($sTmp=((defined('DB_PORT') && DB_PORT !='') ? DB_PORT : '')) ? ':'.$sTmp : ''; |
|
180 |
$sTmp = DB_TYPE.'://'.DB_USERNAME.':'.DB_PASSWORD.'@'.DB_HOST.$sTmp.'/'.DB_NAME.'?Charset='; |
|
181 |
$sTmp .= (defined('DB_CHARSET') ? DB_CHARSET : '').'&TablePrefix='.TABLE_PREFIX; |
|
182 |
$aSqlData = array( 0 => $sTmp); |
|
163 | 183 |
}else { |
164 | 184 |
$aSqlData = readConfiguration($sDbConnectType); |
165 | 185 |
} |
... | ... | |
193 | 213 |
if($sDbConnectType == 'dsn') { |
194 | 214 |
$bTmp = $database->doConnect($aSqlData[0], $aSqlData[1]['user'], $aSqlData[1]['pass'], $aSqlData[2]); |
195 | 215 |
}else { |
196 |
$bTmp = $database->doConnect($aSqlData[0], TABLE_PREFIX);
|
|
216 |
$bTmp = $database->doConnect($aSqlData[0]); |
|
197 | 217 |
} |
198 | 218 |
unset($aSqlData); |
199 | 219 |
// load global settings from database and define global consts from --- |
... | ... | |
316 | 336 |
// load and activate new global translation table |
317 | 337 |
Translate::getInstance()->initialize('en', |
318 | 338 |
(defined('DEFAULT_LANGUAGE') ? DEFAULT_LANGUAGE : ''), |
319 |
(defined('LANGUAGE') ? LANGUAGE : '') |
|
339 |
(defined('LANGUAGE') ? LANGUAGE : ''), |
|
340 |
'WbOldStyle', |
|
341 |
(DEBUG ? Translate::CACHE_DISABLED|Translate::KEEP_MISSING : 0) |
|
320 | 342 |
); |
321 | 343 |
// *** END OF FILE *********************************************************************** |
322 | 344 |
|
Also available in: Unified diff
+ additional arguments for Charset and TablePrefix in WbDatabase::doConnect
+ WbDatabase now can activate SET NAMES by doConnect argument
+ WbDatabase now provide TablePrefix property also (WbDatabase::TablePrefix)
+ initialize.php now also support Charset and TablePrefix settings from setup.ini.php
! in setup.ini.php some keys are renamed (WB_URL => AppUrl and ADMIN_DIRECTORY => AcpDir)