本文整理汇总了PHP中TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsFloat方法的典型用法代码示例。如果您正苦于以下问题:PHP MathUtility::canBeInterpretedAsFloat方法的具体用法?PHP MathUtility::canBeInterpretedAsFloat怎么用?PHP MathUtility::canBeInterpretedAsFloat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\MathUtility
的用法示例。
在下文中一共展示了MathUtility::canBeInterpretedAsFloat方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clearUrlCache
/**
* Clears the URL cache according to parameters.
*
* @param array $parameters
* @return void
*/
public function clearUrlCache(array $parameters)
{
$cacheCommand = $parameters['cacheCmd'];
if (MathUtility::canBeInterpretedAsFloat($cacheCommand)) {
$cacheInstance = CacheFactory::getCache();
$cacheInstance->clearUrlCacheForPage((int) $cacheCommand);
}
}
示例2: evaluateFieldValue
/**
* Validates the given longitude value (between -180 and 180 degrees)
* @see https://developers.google.com/maps/documentation/javascript/reference?hl=fr#LatLng
*
* @param mixed $value The value that has to be checked.
* @param string $is_in Is-In String
* @param int $set Determines if the field can be set (value correct) or not
*
* @return string The new value of the field
*/
public function evaluateFieldValue($value, $is_in, &$set)
{
$newValue = '0.000000';
$set = TRUE;
if (MathUtility::canBeInterpretedAsFloat($value) && ((double) $value >= -180 && (double) $value <= 180)) {
$newValue = number_format((double) $value, 6);
}
return $newValue;
}
示例3: canBeInterpretedAsFloatReturnsFalse
/**
* @test
* @dataProvider functionCanBeInterpretedAsFloatInvalidDataProvider
*/
public function canBeInterpretedAsFloatReturnsFalse($int)
{
$this->assertFalse(\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsFloat($int));
}
示例4: updateIndex
/**
* Updates the index entry for a given file.
*
* @param \TYPO3\CMS\Core\Resource\File $file
* @param integer $width
* @param integer $height
* @param array $metadata EXIF metadata
* @return void
*/
protected static function updateIndex(\TYPO3\CMS\Core\Resource\File $file = null, $width, $height, array $metadata = array())
{
if (version_compare(TYPO3_version, '6.99.99', '<=')) {
/** @var \TYPO3\CMS\Core\Resource\Service\IndexerService $indexerService */
$indexerService = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Resource\\Service\\IndexerService');
$indexerService->indexFile($file);
}
if (count($metadata) > 0) {
/** @var \TYPO3\CMS\Core\Resource\Index\MetaDataRepository $metadataRepository */
$metadataRepository = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Resource\Index\MetaDataRepository::class);
// Will take care of creating the record if it does not exist yet
$currentMetadata = $metadataRepository->findByFile($file);
$newMetadata = [];
// Pre-populate with metadata coming from external extractors
foreach ($currentMetadata as $key => $value) {
if (!empty($metadata[$key])) {
// Known issue with "creator_tool" having a software version sometimes
if ($key === 'creator_tool' && MathUtility::canBeInterpretedAsFloat($metadata[$key])) {
continue;
}
$newMetadata[$key] = $metadata[$key];
}
}
// Width and height are always wrong since we resized the image
unset($newMetadata['width']);
unset($newMetadata['height']);
// We deal with resized images so unit is always pixels
$newMetadata['unit'] = 'px';
// Mapping for the built-in PHP-based metadata extractor
$mapping = ['color_space' => 'ColorSpace', 'content_creation_date' => 'DateTimeOriginal', 'creator' => 'IPTCCreator|Company', 'creator_tool' => 'Model|Make|Software', 'description' => 'ImageDescription', 'keywords' => 'IPTCKeywords', 'latitude' => 'GPSLatitudeDecimal', 'longitude' => 'GPSLongitudeDecimal', 'location_city' => 'IPTCCity', 'location_country' => 'IPTCCountry', 'location_region' => 'IPTCRegion', 'note' => 'IPTCLocation', 'publisher' => 'IPTCCredit', 'source' => 'IPTCSource', 'title' => 'IPTCTitle'];
foreach ($mapping as $falKey => $metadataKeyMapping) {
if (!empty($newMetadata[$falKey])) {
// We already have a known-to-be-valid metadata for this FAL property
continue;
}
$metatadaKeys = explode('|', $metadataKeyMapping);
foreach ($metatadaKeys as $metadataKey) {
$value = null;
if (isset($metadata[$metadataKey])) {
$value = trim($metadata[$metadataKey]);
if (ord($value) === 1) {
$value = null;
}
switch ($metadataKey) {
case 'ColorSpace':
if ($value == 1) {
$value = 'RGB';
} else {
// Unknown
$value = null;
}
break;
case 'DateTimeOriginal':
$value = strtotime($value);
break;
}
}
if (!empty($value)) {
$newMetadata[$falKey] = $value;
break;
}
}
}
$metadataRepository->update($file->getUid(), $newMetadata);
}
}