TYPO3CMS  6.2
 All Classes Namespaces Files Functions Variables Pages
MathUtility Class Reference

Static Public Member Functions

static forceIntegerInRange ($theInt, $min, $max=2000000000, $defaultValue=0)
 
static convertToPositiveInteger ($theInt)
 
static canBeInterpretedAsInteger ($var)
 
static canBeInterpretedAsFloat ($var)
 
static calculateWithPriorityToAdditionAndSubtraction ($string)
 
static calculateWithParentheses ($string)
 
static isIntegerInRange ($value, $minimum, $maximum)
 

Detailed Description

This file is part of the TYPO3 CMS project.

It is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License, either version 2 of the License, or any later version.

For the full copyright and license information, please read the LICENSE.txt file that was distributed with this source code.

The TYPO3 project - inspiring people to share! Class with helper functions for mathematical calculations

Author
Susanne Moog typo3.nosp@m.@sus.nosp@m.anne-.nosp@m.moog.nosp@m..de

Definition at line 21 of file MathUtility.php.

Member Function Documentation

static calculateWithParentheses (   $string)
static

Calculates the input with parenthesis levels

Parameters
string$stringInput string, eg "(123 + 456) / 789 - 4
Returns
integer Calculated value. Or error string.
See also
calculateWithPriorityToAdditionAndSubtraction(), ::stdWrap()

Definition at line 166 of file MathUtility.php.

Referenced by ContentObjectRenderer\stdWrap_prioriCalc().

static calculateWithPriorityToAdditionAndSubtraction (   $string)
static

Calculates the input by +,-,*,/,%,^ with priority to + and -

Parameters
string$stringInput string, eg "123 + 456 / 789 - 4
Returns
integer Calculated value. Or error string.
See also
::calculateWithParentheses()

Definition at line 108 of file MathUtility.php.

static canBeInterpretedAsFloat (   $var)
static

Tests if the input can be interpreted as float.

Note: Float casting from objects or arrays is considered undefined and thus will return false.

See also
http://www.php.net/manual/en/language.types.float.php, section "Formally" for the notation
Parameters
mixed$varAny input variable to test
Returns
boolean Returns TRUE if string is a float

Definition at line 88 of file MathUtility.php.

static canBeInterpretedAsInteger (   $var)
static

Tests if the input can be interpreted as integer.

Note: Integer casting from objects or arrays is considered undefined and thus will return false.

See also
http://php.net/manual/en/language.types.integer.php#language.types.integer.casting.from-other
Parameters
mixed$varAny input variable to test
Returns
boolean Returns TRUE if string is an integer

Definition at line 72 of file MathUtility.php.

Referenced by ResourceCompressor\__construct(), GeneralUtility\array2xml(), InlineElement\checkAccess(), TypoScriptFrontendController\checkAndSetAlias(), FileMetadataPermissionsAspect\checkModifyAccessList(), DataHandler\checkValue_inline(), DataHandler\clear_cacheCmd(), HtmlParser\compileTagAttribs(), RelationHandler\convertPosNeg(), NormalizeCommand\convertRangeToListOfValues(), ShortcutToolbarItem\createAjaxShortcut(), InlineElement\createNewRecord(), DataHandler\dbAnalysisStoreExec(), TypoScriptFrontendController\determineIdIsHiddenPage(), DataHandler\doesRecordExist(), FrontendEditPanel\editPanelLinkWrap(), AbstractConditionMatcher\evaluateConditionCommon(), ContentObjectRenderer\fillInMarkerArray(), AbstractRepository\findByUid(), FileRepository\findFileReferenceByUid(), EditDocumentController\getButtons(), PageLayoutController\getButtons(), AbstractFile\getCombinedIdentifier(), FormEngine\getExcludeElements(), BackendUtility\getFlexFormDS(), ImageService\getImageFromSourceString(), InlineElement\getNewRecordPid(), BackendUtility\getPidForModTSconfig(), LiveSearch\getRecordTitlePrep(), BackendUtility\getRecordTitlePrep(), InlineElement\getSingleField_typeInline(), BackendUtility\getTSconfig_pidValue(), CleanUp\getTypo3TempStatistics(), SoftReferenceIndex\getTypoLinkParts(), BackendController\handlePageEditing(), ContentObjectRenderer\imageLinkWrap(), AddController\init(), ShowImageController\init(), Clipboard\initializeClipboard(), Bootstrap\initializeOutputCompression(), ShortcutToolbarItem\initShortcuts(), DataHandler\insertUpdateDB_preprocessBasedOnFieldType(), FormEngine\isNewRecord(), RelationHandler\isOnSymmetricSide(), ContentObjectRenderer\listNum(), EditController\main(), LiveSearch\makeQuerySearchByTable(), AbstractMenuContentObject\menuTypoLink(), NormalizeCommand\normalizeIntegerField(), RelationHandler\readList(), NormalizeCommand\reduceListOfValuesByStepValue(), ImageTextContentObject\render(), FormContentObject\render(), DateViewHelper\render(), InlineElement\renderForeignRecord(), InlineElement\renderForeignRecordHeaderControl(), SuggestElement\renderSuggestSelector(), FormEngine\renderWizards(), ContentObjectRenderer\replacement(), ResourceFactory\retrieveFileOrFolderObject(), DeletedRecords\setData(), DataHandler\setTSconfigPermissions(), SoftReferenceIndex\setTypoLinkPartsElement(), ContentObjectRenderer\splitObj(), RteHtmlParser\TS_links_rte(), DataHandler\updateFlexFormData(), ProcessedFile\updateProperties(), FileStorageIndexingAdditionalFieldProvider\validateAdditionalFields(), FileStorageExtractionAdditionalFieldProvider\validateAdditionalFields(), RelationHandler\writeForeignField(), and GeneralUtility\xml2arrayProcess().

static convertToPositiveInteger (   $theInt)
static

Returns $theInt if it is greater than zero, otherwise returns zero.

Parameters
integer$theIntInteger string to process
Returns
integer

Definition at line 55 of file MathUtility.php.

Referenced by LiveSearch\setLimitCount(), and LiveSearch\setStartCount().

static forceIntegerInRange (   $theInt,
  $min,
  $max = 2000000000,
  $defaultValue = 0 
)
static

Forces the integer $theInt into the boundaries of $min and $max. If the $theInt is FALSE then the $defaultValue is applied.

Parameters
integer$theIntInput value
integer$minLower limit
integer$maxHigher limit
integer$defaultValueDefault value if input is FALSE.
Returns
integer The input value forced into the boundaries of $min and $max

Definition at line 32 of file MathUtility.php.

Referenced by Status\__construct(), ImportExportController\addRecordsForPid(), Indexer\bodyDescription(), CleanerCommand\cli_printInfo(), GraphicalFunctions\convertColor(), VersionNumberUtility\convertVersionsStringToVersionNumbers(), VersionNumberUtility\convertVersionStringToArray(), GraphicalFunctions\copyGifOntoGif(), CrawlerHook\crawler_execute_type1(), MagicImageService\createMagicImage(), FormEngine\dbFileIcons(), IndexSearchRepository\doSearch(), ImportExportController\exportData(), ExtendedTemplateService\ext_procesInput(), FileContentParser\fileContentParts(), FormEngine\formatValue(), CrawlerHook\generateNextIndexingTime(), SearchFormController\getDisplayResults(), FormEngine\getExcludeElements(), VersionNumberUtility\getNumericTypo3Version(), SearchFormController\getResultRows(), InlineElement\getSingleField_typeInline(), FormEngine\getSingleField_typeSelect(), FormEngine\getSingleField_typeSelect_multiple(), FormEngine\getSingleField_typeSelect_singlebox(), GraphicalFunctions\getTextScalFactor(), GraphicalFunctions\IMparams(), GraphicalFunctions\IMreduceColors(), ClickMenuController\init(), TableController\init(), SimpleDataHandlerController\init(), GraphicalFunctions\init(), Indexer\init(), EditDocumentController\init(), SearchController\initialize(), SearchFormController\initialize(), Clipboard\initializeClipboard(), PageTreeNavigationController\initializeTemporaryDBmount(), FileContentParser\initParser(), GeneralUtility\initSysLog(), GraphicalFunctions\inputLevels(), AbstractUserAuthentication\ipLockClause_remoteIPNumber(), CleanFlexformCommand\main(), DeletedRecordsCommand\main(), VersionsCommand\main(), CreateFolderController\main(), ThumbnailView\main(), GraphicalFunctions\makeBox(), GraphicalFunctions\makeOutline(), SearchController\makeRating(), GraphicalFunctions\makeShadow(), GraphicalFunctions\makeText(), SearchController\markupSWpartsOfString(), GeneralUtility\modifyHTMLColor(), GraphicalFunctions\output(), GraphicalFunctions\outputLevels(), PageGenerator\pagegenInit(), SearchFormController\pi_list_browseresults(), LocalPreviewHelper\process(), DataHandlerHook\processCmdmap(), ShowImageController\processImage(), VersionNumberUtility\raiseVersionNumber(), HorizontalRulerContentObject\render(), ImageTextContentObject\render(), ColumnsContentObject\render(), PageBrowsingViewHelper\render(), FormContentObject\render(), CssStyledContentController\render_table(), MailPostProcessor\setPriority(), AbstractMessage\setSeverity(), GifBuilder\start(), AbstractDatabaseRecordList\start(), RteHtmlParser\TS_transform_rte(), GraphicalFunctions\v5_blur(), GraphicalFunctions\v5_sharpen(), ActionTask\viewRecordList(), and JavaScriptMenuContentObject\writeMenu().

static isIntegerInRange (   $value,
  $minimum,
  $maximum 
)
static

Checks whether the given number $value is an integer in the range [$minimum;$maximum]

Parameters
integer$valueInteger value to check
integer$minimumLower boundary of the range
integer$maximumUpper boundary of the range
Returns
boolean

Definition at line 195 of file MathUtility.php.

Referenced by Typo3DependencyViewHelper\isVersionSuitable(), and FileStorageExtractionAdditionalFieldProvider\validateAdditionalFields().