/** * Check if current TYPO3 version is suitable for the extension * * @param string $lowestVersion * @param string $highestVersion * @return bool */ protected static function isVersionSuitable($lowestVersion, $highestVersion) { $numericTypo3Version = VersionNumberUtility::convertVersionNumberToInteger(VersionNumberUtility::getNumericTypo3Version()); $numericLowestVersion = VersionNumberUtility::convertVersionNumberToInteger($lowestVersion); $numericHighestVersion = VersionNumberUtility::convertVersionNumberToInteger($highestVersion); return MathUtility::isIntegerInRange($numericTypo3Version, $numericLowestVersion, $numericHighestVersion); }
/** * @param array $arguments * @param \Closure $renderChildrenClosure * @param RenderingContextInterface $renderingContext * * @return string */ public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext) { $title = $arguments['title']; $message = $arguments['message']; $state = $arguments['state']; $isInRange = MathUtility::isIntegerInRange($state, -2, 2); if (!$isInRange) { $state = -2; } $iconName = $arguments['iconName']; $disableIcon = $arguments['disableIcon']; if ($message === null) { $messageTemplate = $renderChildrenClosure(); } else { $messageTemplate = htmlspecialchars($message); } $classes = [self::STATE_NOTICE => 'notice', self::STATE_INFO => 'info', self::STATE_OK => 'success', self::STATE_WARNING => 'warning', self::STATE_ERROR => 'danger']; $icons = [self::STATE_NOTICE => 'lightbulb-o', self::STATE_INFO => 'info', self::STATE_OK => 'check', self::STATE_WARNING => 'exclamation', self::STATE_ERROR => 'times']; $stateClass = $classes[$state]; $icon = $icons[$state]; if ($iconName !== null) { $icon = $iconName; } $iconTemplate = ''; if (!$disableIcon) { $iconTemplate = '' . '<div class="media-left">' . '<span class="fa-stack fa-lg callout-icon">' . '<i class="fa fa-circle fa-stack-2x"></i>' . '<i class="fa fa-' . htmlspecialchars($icon) . ' fa-stack-1x"></i>' . '</span>' . '</div>'; } $titleTemplate = ''; if ($title !== null) { $titleTemplate = '<h4 class="callout-title">' . htmlspecialchars($title) . '</h4>'; } return '<div class="callout callout-' . htmlspecialchars($stateClass) . '">' . '<div class="media">' . $iconTemplate . '<div class="media-body">' . $titleTemplate . '<div class="callout-body">' . $messageTemplate . '</div>' . '</div>' . '</div>' . '</div>'; }
/** * Get compression level * * @return int */ protected function getCompressionLevel() { $level = isset($GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel']) ? (int) $GLOBALS['TYPO3_CONF_VARS']['FE']['compressionLevel'] : self::DEFAULT_COMPRESSION_LEVEL; if (!MathUtility::isIntegerInRange($level, 1, 9)) { $level = self::DEFAULT_COMPRESSION_LEVEL; } return $level; }
/** * Checks a level for validity, * whether it is an integer and in the range of 0-7. * * @param integer $level log level to validate * @return boolean TRUE if the given log level is valid, FALSE otherwise */ public static function isValidLevel($level) { return \TYPO3\CMS\Core\Utility\MathUtility::isIntegerInRange($level, self::EMERGENCY, self::DEBUG); }
/** * @test * @dataProvider isIntegerInRangeRejectsOtherDataTypesDataProvider */ public function isIntegerInRangeRejectsOtherDataTypes($inputValue) { $this->assertFalse(\TYPO3\CMS\Core\Utility\MathUtility::isIntegerInRange($inputValue, 0, 10)); }
/** * Validate additional fields * * @param array $submittedData Reference to the array containing the data submitted by the user * @param SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return bool True if validation was ok (or selected class is not relevant), false otherwise */ public function validateAdditionalFields(array &$submittedData, SchedulerModuleController $parentObject) { if (!MathUtility::canBeInterpretedAsInteger($submittedData['scheduler_fileStorageIndexing_storage']) || !MathUtility::canBeInterpretedAsInteger($submittedData['scheduler_fileStorageIndexing_fileCount'])) { return false; } elseif (ResourceFactory::getInstance()->getStorageObject($submittedData['scheduler_fileStorageIndexing_storage']) === null) { return false; } elseif (!MathUtility::isIntegerInRange($submittedData['scheduler_fileStorageIndexing_fileCount'], 1, 9999)) { return false; } return true; }
/** * Validate additional fields * * @param array $submittedData Reference to the array containing the data submitted by the user * @param \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject Reference to the calling object (Scheduler's BE module) * @return boolean True if validation was ok (or selected class is not relevant), false otherwise */ public function validateAdditionalFields(array &$submittedData, \TYPO3\CMS\Scheduler\Controller\SchedulerModuleController $parentObject) { if (!MathUtility::canBeInterpretedAsInteger($submittedData['scheduler_fileStorageIndexing_storage']) || !MathUtility::canBeInterpretedAsInteger($submittedData['scheduler_fileStorageIndexing_fileCount'])) { return FALSE; } elseif (\TYPO3\CMS\Core\Resource\ResourceFactory::getInstance()->getStorageObject($submittedData['scheduler_fileStorageIndexing_storage']) === NULL) { return FALSE; } elseif (!MathUtility::isIntegerInRange($submittedData['scheduler_fileStorageIndexing_fileCount'], 1, 9999)) { return FALSE; } return TRUE; }