Feature #20102 ยป 10563_v1.diff
class.t3lib_extmgm.php 2009-03-02 12:19:50.000000000 +0100 | ||
---|---|---|
return substr($key, 0, 5)=='user_' ? 'user_'.str_replace('_', '', substr($key, 5)) : 'tx_'.str_replace('_', '', $key);
|
||
}
|
||
|
||
|
||
/**
|
||
* Returns the EM_CONF array of the given extension key $key.
|
||
* Old style ext_emconf.php will be cleaned up.
|
||
* If $arrKey is given, the value of this key in EM_CONF will be returned
|
||
* Nested values can be accessed by $arrKey by separating the keys with
|
||
* a tube |. E.g.: 'constraints|depends'
|
||
*
|
||
*
|
||
* @param string Extension key
|
||
* @param string Array key
|
||
* @return mixed
|
||
* @author Sebastian Gebhard <s.gebhard@markenmotiv.de>
|
||
*/
|
||
public static function getEMConfArray($_EXTKEY,$arrKey=false) {
|
||
$filePath = t3lib_extMgm::extPath($_EXTKEY).'ext_emconf.php';
|
||
if (@is_file($filePath)) {
|
||
include($filePath);
|
||
if(is_array($EM_CONF[$_EXTKEY])) {
|
||
$emConf = $EM_CONF[$_EXTKEY];
|
||
|
||
/* The following code is a refactoring of em_index->fixEMCONF to clean up emConf from old style to TER2 style */
|
||
$stringToConstraints_keys = array(
|
||
'dependencies' => 'depends',
|
||
'conflicts' => 'conflicts'
|
||
);
|
||
foreach($stringToConstraints_keys as $oldKey => $targetKey) {
|
||
if(!isset($emConf['constraints'][$targetKey])) {
|
||
if(is_string($emConf[$oldKey]) && strlen($emConf[$oldKey])) {
|
||
$dep = explode(',',$emConf[$oldKey]);
|
||
foreach($dep as $v) {
|
||
$emConf['constraints'][$targetKey][$v] = '';
|
||
}
|
||
}
|
||
}
|
||
}
|
||
// sanity check and old style -> TER2 conversion
|
||
$versions = array(
|
||
array(
|
||
'oldKey' => 'PHP_version',
|
||
'targetKey' => 'php',
|
||
'minVersion' => '3.0.0'
|
||
),
|
||
array(
|
||
'oldKey' => 'TYPO3_version',
|
||
'targetKey' => 'typo3',
|
||
'minVersion' => '3.5.0'
|
||
),
|
||
);
|
||
foreach($versions as $version) {
|
||
if(isset($emConf['constraints']['depends'][$version['targetKey']])) {
|
||
$ver = $emConf['constraints']['depends'][$version['targetKey']];
|
||
}else{
|
||
$ver = $emConf[$version['oldKey']];
|
||
}
|
||
$versionRange = array();
|
||
if (strstr($ver, '-')) {
|
||
$versionRange = explode('-', $ver, 2);
|
||
} else {
|
||
$versionRange[0] = $ver;
|
||
$versionRange[1] = '';
|
||
}
|
||
if (!$versionRange[0]) { $versionRange[0] = '0.0.0'; }
|
||
if (!$versionRange[1]) { $versionRange[1] = '0.0.0'; }
|
||
if (version_compare($versionRange[0],$version['minVersion'],'<')) $versionRange[0] = $version['minVersion'];
|
||
if (version_compare($versionRange[1],$version['minVersion'],'<')) $versionRange[1] = '0.0.0';
|
||
$emConf['constraints']['depends'][$version['targetKey']] = implode('-',$versionRange);
|
||
}
|
||
if(!isset($emConf['constraints']['suggests'])) {
|
||
$emConf['constraints']['suggests'] = array();
|
||
}
|
||
unset($emConf['private']);
|
||
unset($emConf['download_password']);
|
||
unset($emConf['TYPO3_version']);
|
||
unset($emConf['PHP_version']);
|
||
/* End of cleaning emConf */
|
||
|
||
if($arrKey!==false){
|
||
$expArrKey = t3lib_div::trimExplode('|',$arrKey,1);
|
||
if(count($expArrKey)==1){
|
||
if(isset($emConf[$arrKey])) {
|
||
// Return single value
|
||
return $emConf[$arrKey];
|
||
}
|
||
// key was not found
|
||
return null;
|
||
}
|
||
foreach($expArrKey as $key){
|
||
if(!isset($emConf[$key])) {
|
||
// (nested) key was not found
|
||
return null;
|
||
}
|
||
$emConf = $emConf[$key];
|
||
}
|
||
// Return nested value
|
||
return $emConf;
|
||
}
|
||
// Return hole array
|
||
return $emConf;
|
||
}
|
||
}
|
||
// file was not found
|
||
return null;
|
||
}
|