Feature #19739 » 10011.diff
t3lib/class.t3lib_extmgm.php (copie de travail) | ||
---|---|---|
}
|
||
/**
|
||
* Returns version information
|
||
*
|
||
* @param string Version code, x.x.x
|
||
* @param string part: "", "int", "main", "sub", "dev"
|
||
* @return string
|
||
* @see renderVersion()
|
||
*/
|
||
public static function makeVersion ($v,$mode) {
|
||
$vDat = self::renderVersion($v);
|
||
return $vDat['version_' . $mode];
|
||
}
|
||
/**
|
||
* Evaluates differences in version numbers with three parts, x.x.x. Returns true if $v1 is greater than $v2
|
||
*
|
||
* @param string Version number 1
|
||
* @param string Version number 2
|
||
* @param string comparator string for the version compare
|
||
* @param integer Tolerance factor. For instance, set to 1000 to ignore difference in dev-version (third part)
|
||
* @return boolean True if version 1 is greater than version 2
|
||
*/
|
||
public static function versionDifference ($v1,$v2,$comp='',$div=1) {
|
||
$rc = FALSE;
|
||
$leftValue = floor(self::makeVersion($v1,'int')/$div);
|
||
$rightValue = floor(self::makeVersion($v2,'int')/$div);
|
||
if (!$comp) {
|
||
$comp = '>';
|
||
}
|
||
$rc = self::testNumber($comp . $rightValue, $leftValue);
|
||
return $rc;
|
||
}
|
||
/**
|
||
* Evaluates a $leftValue based on an operator: "<", ">", "<=", ">=", "!=" or "="
|
||
*
|
||
* @param string $test: The value to compare with on the form [operator][number]. Eg. "< 123"
|
||
* @param integer $leftValue: The value on the left side
|
||
* @return boolean If $value is "50" and $test is "< 123" then it will return true.
|
||
*/
|
||
public static function testNumber ($test, $leftValue) {
|
||
$test = trim($test);
|
||
if (preg_match('/^(!?=+|<=?|>=?)\s*([^\s]*)\s*$/', $test, $matches)) {
|
||
$operator = $matches[1];
|
||
$rightValue = $matches[2];
|
||
switch ($operator) {
|
||
case '>=':
|
||
return ($leftValue >= doubleval($rightValue));
|
||
break;
|
||
case '<=':
|
||
return ($leftValue <= doubleval($rightValue));
|
||
break;
|
||
case '!=':
|
||
return ($leftValue != doubleval($rightValue));
|
||
break;
|
||
case '<':
|
||
return ($leftValue < doubleval($rightValue));
|
||
break;
|
||
case '>':
|
||
return ($leftValue > doubleval($rightValue));
|
||
break;
|
||
default:
|
||
// nothing valid found except '=', use '='
|
||
return ($leftValue == trim($rightValue));
|
||
break;
|
||
}
|
||
}
|
||
return false;
|
||
}
|
||
/**
|
||
* Parses the version number x.x.x and returns an array with the various parts.
|
||
*
|
||
* @param string Version code, x.x.x
|
||
* @param string Increase version part: "main", "sub", "dev"
|
||
* @return string
|
||
*/
|
||
public static function renderVersion ($v,$raise='') {
|
||
$parts = t3lib_div::intExplode('.',$v.'..');
|
||
$parts[0] = t3lib_div::intInRange($parts[0],0,999);
|
||
$parts[1] = t3lib_div::intInRange($parts[1],0,999);
|
||
$parts[2] = t3lib_div::intInRange($parts[2],0,999);
|
||
switch((string)$raise) {
|
||
case 'main':
|
||
$parts[0]++;
|
||
$parts[1]=0;
|
||
$parts[2]=0;
|
||
break;
|
||
case 'sub':
|
||
$parts[1]++;
|
||
$parts[2]=0;
|
||
break;
|
||
case 'dev':
|
||
$parts[2]++;
|
||
break;
|
||
}
|
||
$res = array();
|
||
$res['version'] = $parts[0].'.'.$parts[1].'.'.$parts[2];
|
||
$res['version_int'] = intval($parts[0]*1000000+$parts[1]*1000+$parts[2]);
|
||
$res['version_main'] = $parts[0];
|
||
$res['version_sub'] = $parts[1];
|
||
$res['version_dev'] = $parts[2];
|
||
return $res;
|
||
}
|
||
/**
|
||
* Gets information for an extension, eg. version and most-recently-edited-script
|
||
*
|
||
* @param string Extension key
|
||
* @return array Information array (unless an error occured)
|
||
*/
|
||
public static function getExtensionInfo ($extKey) {
|
||
$rc = '';
|
||
if (self::isLoaded($extKey)) {
|
||
$path = self::extPath($extKey);
|
||
$file = $path.'/ext_emconf.php';
|
||
if (@is_file($file)) {
|
||
$_EXTKEY = $extKey;
|
||
$EM_CONF = array();
|
||
include($file);
|
||
$eInfo = array();
|
||
// Info from emconf:
|
||
$eInfo['title'] = $EM_CONF[$extKey]['title'];
|
||
$eInfo['author'] = $EM_CONF[$extKey]['author'];
|
||
$eInfo['author_email'] = $EM_CONF[$extKey]['author_email'];
|
||
$eInfo['author_company'] = $EM_CONF[$extKey]['author_company'];
|
||
$eInfo['version'] = $EM_CONF[$extKey]['version'];
|
||
$eInfo['CGLcompliance'] = $EM_CONF[$extKey]['CGLcompliance'];
|
||
$eInfo['CGLcompliance_note'] = $EM_CONF[$extKey]['CGLcompliance_note'];
|
||
if (is_array($EM_CONF[$extKey]['constraints']) && is_array($EM_CONF[$extKey]['constraints']['depends'])) {
|
||
$eInfo['TYPO3_version'] = $EM_CONF[$extKey]['constraints']['depends']['typo3'];
|
||
} else {
|
||
$eInfo['TYPO3_version'] = $EM_CONF[$extKey]['TYPO3_version'];
|
||
}
|
||
$filesHash = unserialize($EM_CONF[$extKey]['_md5_values_when_last_written']);
|
||
$eInfo['manual'] = @is_file($path.'/doc/manual.sxw');
|
||
$rc = $eInfo;
|
||
} else {
|
||
$rc = 'ERROR: No emconf.php file: '.$file;
|
||
}
|
||
} else {
|
||
$rc = 'Error: Extension '.$extKey.' has not been installed. (patch10011_extMgm::getExtensionInfo)';
|
||
}
|
||
return $rc;
|
||
}
|
||
/**
|
||
* Clears the extension key map.
|
||
*
|
||
* @return void
|
t3lib/matchcondition/class.t3lib_matchcondition_abstract.php (copie de travail) | ||
---|---|---|
* @package TYPO3
|
||
* @subpackage t3lib
|
||
*/
|
||
require_once (PATH_t3lib . 'class.t3lib_extmgm.php');
|
||
abstract class t3lib_matchCondition_abstract {
|
||
/**
|
||
* Id of the current page.
|
||
... | ... | |
* @return mixed Returns true or false based on the evaluation
|
||
*/
|
||
protected function evaluateConditionCommon($key, $value) {
|
||
$rc = NULL;
|
||
if (t3lib_div::inList('browser,version,system,useragent', strtolower($key))) {
|
||
$browserInfo = $this->getBrowserInfo(t3lib_div::getIndpEnv('HTTP_USER_AGENT'));
|
||
}
|
||
... | ... | |
return true;
|
||
}
|
||
break;
|
||
case 'ext':
|
||
$values = t3lib_div::trimExplode(',', $value, true);
|
||
$point = strcspn($value, '!=<>');
|
||
$part = substr($value, 0, $point);
|
||
$values['0'] = substr($value, $point);
|
||
$keyArray = explode(':', $part);
|
||
$extKey = $keyArray['0'];
|
||
$attribute = trim($keyArray['1']);
|
||
foreach($values as $curValue) {
|
||
if (strlen($curValue) && strlen($extKey)) {
|
||
$curValue = trim($curValue);
|
||
$bExtIsLoaded = t3lib_extMgm::isLoaded($extKey);
|
||
if (!strlen($attribute) && $bExtIsLoaded || ($attribute == 'active' && intval($bExtIsLoaded) == $curValue)) {
|
||
$rc = true;
|
||
break;
|
||
} else {
|
||
$extInfoArray = t3lib_extMgm::getExtensionInfo($extKey);
|
||
if (
|
||
is_array($extInfoArray) &&
|
||
isset($extInfoArray[$attribute])
|
||
) {
|
||
$test = $extInfoArray[$attribute] . $curValue;
|
||
switch ($attribute) {
|
||
case 'version':
|
||
if (preg_match('/^\s*([^\s]*)\s*(!?=+|<=?|>=?)\s*([^\s]*)\s*$/', $test, $matches)) {
|
||
$rc = t3lib_extMgm::versionDifference($matches['1'],$matches['3'],$matches['2'],1);
|
||
}
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
}
|
||
return NULL;
|
||
return $rc;
|
||
}
|
||
protected function getVariableCommon(array $vars) {
|
- « Previous
- 1
- 2
- 3
- Next »