本文整理汇总了PHP中TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange方法的典型用法代码示例。如果您正苦于以下问题:PHP MathUtility::forceIntegerInRange方法的具体用法?PHP MathUtility::forceIntegerInRange怎么用?PHP MathUtility::forceIntegerInRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\MathUtility
的用法示例。
在下文中一共展示了MathUtility::forceIntegerInRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkSolrConnection
/**
* Check if a connection to a Solr server could be established with the given credentials.
*
* @access public
*
* @param array &$params: An array with parameters
* @param \TYPO3\CMS\Core\TypoScript\ConfigurationForm &$pObj: The parent object
*
* @return string Message informing the user of success or failure
*/
public function checkSolrConnection(&$params, &$pObj)
{
// Prepend username and password to hostname.
if (!empty($this->conf['solrUser']) && !empty($this->conf['solrPass'])) {
$host = $this->conf['solrUser'] . ':' . $this->conf['solrPass'] . '@' . (!empty($this->conf['solrHost']) ? $this->conf['solrHost'] : 'localhost');
} else {
$host = !empty($this->conf['solrHost']) ? $this->conf['solrHost'] : 'localhost';
}
// Set port if not set.
$port = !empty($this->conf['solrPort']) ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->conf['solrPort'], 0, 65535, 8180) : 8180;
// Trim path and append trailing slash.
$path = !empty($this->conf['solrPath']) ? trim($this->conf['solrPath'], '/') . '/' : '';
// Build request URI.
$url = 'http://' . $host . ':' . $port . '/' . $path . 'admin/cores';
$context = stream_context_create(array('http' => array('method' => 'GET', 'user_agent' => !empty($this->conf['useragent']) ? $this->conf['useragent'] : ini_get('user_agent'))));
// Try to connect to Solr server.
$response = @simplexml_load_string(file_get_contents($url, FALSE, $context));
// Check status code.
if ($response) {
$status = $response->xpath('//lst[@name="responseHeader"]/int[@name="status"]');
if (is_array($status)) {
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', sprintf($GLOBALS['LANG']->getLL('solr.status'), (string) $status[0]), $GLOBALS['LANG']->getLL('solr.connected'), $status[0] == 0 ? \TYPO3\CMS\Core\Messaging\FlashMessage::OK : \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, FALSE);
$this->content .= $message->render();
return $this->content;
}
}
$message = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Messaging\\FlashMessage', sprintf($GLOBALS['LANG']->getLL('solr.error'), $url), $GLOBALS['LANG']->getLL('solr.notConnected'), \TYPO3\CMS\Core\Messaging\FlashMessage::WARNING, FALSE);
$this->content .= $message->render();
return $this->content;
}
示例2: breakBulletList
/**
* Breaks content lines into a bullet list
*
* @param ContentObjectRenderer $contentObject
* @param string $str Content string to make into a bullet list
*
* @return string Processed value
*/
function breakBulletList($contentObject, $str)
{
$type = $contentObject->data['layout'];
$type = MathUtility::forceIntegerInRange($type, 0, 3);
$tConf = $this->configuration['bulletlist.'][$type . '.'];
$cParts = explode(chr(10), $str);
$lines = array();
$c = 0;
foreach ($cParts as $substrs) {
if (!strlen($substrs)) {
continue;
}
$c++;
$bullet = $tConf['bullet'] ? $tConf['bullet'] : ' - ';
$bLen = strlen($bullet);
$bullet = substr(str_replace('#', $c, $bullet), 0, $bLen);
$secondRow = substr($tConf['secondRow'] ? $tConf['secondRow'] : str_pad('', strlen($bullet), ' '), 0, $bLen);
$lines[] = $bullet . $this->breakLines($substrs, chr(10) . $secondRow, Configuration::getPlainTextWith() - $bLen);
$blanks = MathUtility::forceIntegerInRange($tConf['blanks'], 0, 1000);
if ($blanks) {
$lines[] = str_pad('', $blanks - 1, chr(10));
}
}
return implode(chr(10), $lines);
}
示例3: process
/**
* This method actually does the processing of files locally
*
* takes the original file (on remote storages this will be fetched from the remote server)
* does the IM magic on the local server by creating a temporary typo3temp/ file
* copies the typo3temp/ file to the processing folder of the target storage
* removes the typo3temp/ file
*
* @param TaskInterface $task
* @return array
*/
public function process(TaskInterface $task)
{
$targetFile = $task->getTargetFile();
// Merge custom configuration with default configuration
$configuration = array_merge(array('width' => 64, 'height' => 64), $task->getConfiguration());
$configuration['width'] = Utility\MathUtility::forceIntegerInRange($configuration['width'], 1, 1000);
$configuration['height'] = Utility\MathUtility::forceIntegerInRange($configuration['height'], 1, 1000);
$originalFileName = $targetFile->getOriginalFile()->getForLocalProcessing(FALSE);
// Create a temporary file in typo3temp/
if ($targetFile->getOriginalFile()->getExtension() === 'jpg') {
$targetFileExtension = '.jpg';
} else {
$targetFileExtension = '.png';
}
// Create the thumb filename in typo3temp/preview_....jpg
$temporaryFileName = Utility\GeneralUtility::tempnam('preview_') . $targetFileExtension;
// Check file extension
if ($targetFile->getOriginalFile()->getType() != Resource\File::FILETYPE_IMAGE && !Utility\GeneralUtility::inList($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'], $targetFile->getOriginalFile()->getExtension())) {
// Create a default image
$this->processor->getTemporaryImageWithText($temporaryFileName, 'Not imagefile!', 'No ext!', $targetFile->getOriginalFile()->getName());
} else {
// Create the temporary file
if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['im']) {
$parameters = '-sample ' . $configuration['width'] . 'x' . $configuration['height'] . ' ' . $this->processor->wrapFileName($originalFileName) . '[0] ' . $this->processor->wrapFileName($temporaryFileName);
$cmd = Utility\GeneralUtility::imageMagickCommand('convert', $parameters) . ' 2>&1';
Utility\CommandUtility::exec($cmd);
if (!file_exists($temporaryFileName)) {
// Create a error gif
$this->processor->getTemporaryImageWithText($temporaryFileName, 'No thumb', 'generated!', $targetFile->getOriginalFile()->getName());
}
}
}
return array('filePath' => $temporaryFileName);
}
示例4: prepareLoader
/**
* Get all the complex data for the loader.
* This return value will be cached and stored in the database
* There is no file monitoring for this cache
*
* @param Loader $autoLoader
* @param int $type
*
* @return array
*/
public function prepareLoader(Loader $autoLoader, $type)
{
$slots = [];
$slotPath = ExtensionManagementUtility::extPath($autoLoader->getExtensionKey()) . 'Classes/Slots/';
$slotClasses = FileUtility::getBaseFilesInDir($slotPath, 'php');
foreach ($slotClasses as $slot) {
$slotClass = ClassNamingUtility::getFqnByPath($autoLoader->getVendorName(), $autoLoader->getExtensionKey(), 'Slots/' . $slot);
if (!$autoLoader->isInstantiableClass($slotClass)) {
continue;
}
$methods = ReflectionUtility::getPublicMethods($slotClass);
foreach ($methods as $methodReflection) {
/** @var MethodReflection $methodReflection */
$tagConfiguration = ReflectionUtility::getTagConfiguration($methodReflection, ['signalClass', 'signalName', 'signalPriority']);
foreach ($tagConfiguration['signalClass'] as $key => $signalClass) {
if (!isset($tagConfiguration['signalName'][$key])) {
continue;
}
$priority = isset($tagConfiguration['signalPriority'][$key]) ? $tagConfiguration['signalPriority'][$key] : 0;
$priority = MathUtility::forceIntegerInRange($priority, 0, 100);
$slots[$priority][] = ['signalClassName' => trim($signalClass, '\\'), 'signalName' => $tagConfiguration['signalName'][$key], 'slotClassNameOrObject' => $slotClass, 'slotMethodName' => $methodReflection->getName()];
}
}
}
$slots = $this->flattenSlotsByPriority($slots);
return $slots;
}
示例5: getCroppedImageSrcByFile
/**
* Get the cropped image by File Object
*
* @param FileInterface $file
* @param string $ratio
*
* @return string The new filename
*/
public function getCroppedImageSrcByFile(FileInterface $file, $ratio)
{
$absoluteImageName = GeneralUtility::getFileAbsFileName($file->getPublicUrl());
$focusPointX = MathUtility::forceIntegerInRange((int) $file->getProperty('focus_point_x'), -100, 100, 0);
$focusPointY = MathUtility::forceIntegerInRange((int) $file->getProperty('focus_point_y'), -100, 100, 0);
$tempImageFolder = 'typo3temp/focuscrop/';
$tempImageName = $tempImageFolder . $file->getSha1() . '-' . str_replace(':', '-', $ratio) . '-' . $focusPointX . '-' . $focusPointY . '.' . $file->getExtension();
$absoluteTempImageName = GeneralUtility::getFileAbsFileName($tempImageName);
if (is_file($absoluteTempImageName)) {
return $tempImageName;
}
$absoluteTempImageFolder = GeneralUtility::getFileAbsFileName($tempImageFolder);
if (!is_dir($absoluteTempImageFolder)) {
GeneralUtility::mkdir_deep($absoluteTempImageFolder);
}
$this->graphicalFunctions = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Imaging\\GraphicalFunctions');
$imageSizeInformation = getimagesize($absoluteImageName);
$width = $imageSizeInformation[0];
$height = $imageSizeInformation[1];
// dimensions
/** @var \HDNET\Focuspoint\Service\DimensionService $service */
$dimensionService = GeneralUtility::makeInstance('HDNET\\Focuspoint\\Service\\DimensionService');
list($focusWidth, $focusHeight) = $dimensionService->getFocusWidthAndHeight($width, $height, $ratio);
$cropMode = $dimensionService->getCropMode($width, $height, $ratio);
list($sourceX, $sourceY) = $dimensionService->calculateSourcePosition($cropMode, $width, $height, $focusWidth, $focusHeight, $focusPointX, $focusPointY);
// generate image
$sourceImage = $this->graphicalFunctions->imageCreateFromFile($absoluteImageName);
$destinationImage = imagecreatetruecolor($focusWidth, $focusHeight);
$this->graphicalFunctions->imagecopyresized($destinationImage, $sourceImage, 0, 0, $sourceX, $sourceY, $focusWidth, $focusHeight, $focusWidth, $focusHeight);
$this->graphicalFunctions->ImageWrite($destinationImage, $absoluteTempImageName, $GLOBALS['TYPO3_CONF_VARS']['GFX']['jpg_quality']);
return $tempImageName;
}
示例6: main
/**
* The main method of the PlugIn
*
* @access public
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
*
* @return string The content that is displayed on the website
*/
public function main($content, $conf)
{
$this->init($conf);
// Merge configuration with conf array of toolbox.
$this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf);
// Load current document.
$this->loadDocument();
if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpFulltext'])) {
// Quit without doing anything if required variables are not set.
return $content;
} else {
// Set default values if not set.
// page may be integer or string (physical page attribute)
if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) {
$this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
} else {
$this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalPages);
}
$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Load template file.
if (!empty($this->conf['templateFile'])) {
$this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');
} else {
$this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/toolbox/tools/fulltext/template.tmpl'), '###TEMPLATE###');
}
$fullTextFile = $this->doc->physicalPagesInfo[$this->doc->physicalPages[$this->piVars['page']]]['files'][$this->conf['fileGrpFulltext']];
if (!empty($fullTextFile)) {
$markerArray['###FULLTEXT_SELECT###'] = '<a class="select switchoff" id="tx-dlf-tools-fulltext" title="" data-dic="fulltext-on:' . $this->pi_getLL('fulltext-on', '', TRUE) . ';fulltext-off:' . $this->pi_getLL('fulltext-off', '', TRUE) . '"></a>';
} else {
$markerArray['###FULLTEXT_SELECT###'] = $this->pi_getLL('fulltext-not-available', '', TRUE);
}
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
}
示例7: getCurrentFocusPoint
/**
* Get focus point information
*
* @param $uid
*
* @return array|FALSE|NULL
*/
protected function getCurrentFocusPoint($uid)
{
$row = GlobalUtility::getDatabaseConnection()->exec_SELECTgetSingleRow('focus_point_x, focus_point_y', 'sys_file_metadata', 'uid=' . $uid);
$row['focus_point_x'] = MathUtility::forceIntegerInRange((int) $row['focus_point_x'], -100, 100, 0);
$row['focus_point_y'] = MathUtility::forceIntegerInRange((int) $row['focus_point_y'], -100, 100, 0);
return $row;
}
示例8: __construct
/**
* Construct a status
*
* All values must be given as constructor arguments.
* All strings should be localized.
*
* @param string $title Status title, eg. "Deprecation log"
* @param string $value Status value, eg. "Disabled"
* @param string $message Optional message further describing the title/value combination
* Example:, eg "The deprecation log is important and does foo, to disable it do bar"
* @param integer $severity A severity level. Use one of the constants above!
*/
public function __construct($title, $value, $message = '', $severity = self::OK)
{
$this->title = (string) $title;
$this->value = (string) $value;
$this->message = (string) $message;
$this->severity = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($severity, self::NOTICE, self::ERROR, self::OK);
}
示例9: renderStatic
/**
* @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 = MathUtility::forceIntegerInRange($arguments['state'], -2, 2, -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>';
}
示例10: main
/**
* The main method of the PlugIn
*
* @access public
*
* @param string $content: The PlugIn content
* @param array $conf: The PlugIn configuration
*
* @return string The content that is displayed on the website
*/
public function main($content, $conf)
{
$this->init($conf);
// Merge configuration with conf array of toolbox.
$this->conf = tx_dlf_helper::array_merge_recursive_overrule($this->cObj->data['conf'], $this->conf);
// Load current document.
$this->loadDocument();
if ($this->doc === NULL || $this->doc->numPages < 1 || empty($this->conf['fileGrpDownload'])) {
// Quit without doing anything if required variables are not set.
return $content;
} else {
// Set default values if not set.
// page may be integer or string (physical page attribute)
if ((int) $this->piVars['page'] > 0 || empty($this->piVars['page'])) {
$this->piVars['page'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange((int) $this->piVars['page'], 1, $this->doc->numPages, 1);
} else {
$this->piVars['page'] = array_search($this->piVars['page'], $this->doc->physicalPages);
}
$this->piVars['double'] = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->piVars['double'], 0, 1, 0);
}
// Load template file.
if (!empty($this->conf['templateFile'])) {
$this->template = $this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']), '###TEMPLATE###');
} else {
$this->template = $this->cObj->getSubpart($this->cObj->fileResource('EXT:dlf/plugins/toolbox/tools/pdf/template.tmpl'), '###TEMPLATE###');
}
// Get single page downloads.
$markerArray['###PAGE###'] = $this->getPageLink();
// Get work download.
$markerArray['###WORK###'] = $this->getWorkLink();
$content .= $this->cObj->substituteMarkerArray($this->template, $markerArray);
return $this->pi_wrapInBaseClass($content);
}
示例11: intInRange
/**
* Forces the integer $theInt into the boundaries of $min and $max. If the $theInt is 'FALSE' then the $zeroValue is applied.
*
* @param integer $theInt Input value
* @param integer $min Lower limit
* @param integer $max Higher limit
* @param integer $zeroValue Default value if input is FALSE.
* @return integer The input value forced into the boundaries of $min and $max
* @deprecated since TYPO3 4.6, will be removed in TYPO3 4.8 - Use t3lib_utility_Math::forceIntegerInRange() instead
*/
public static function intInRange($theInt, $min, $max = 2000000000, $zeroValue = 0)
{
if (tx_rnbase_util_TYPO3::isTYPO62OrHigher()) {
return \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($theInt, $min, $max, $zeroValue);
} elseif (tx_rnbase_util_TYPO3::isTYPO46OrHigher()) {
return t3lib_utility_Math::forceIntegerInRange($theInt, $min, $max, $zeroValue);
} else {
return t3lib_div::intInRange($theInt, $min, $max, $zeroValue);
}
}
示例12: main
/**
* Find orphan records
* VERY CPU and memory intensive since it will look up the whole page tree!
*
* @return array
*/
public function main()
{
// Initialize result array:
$resultArray = array('message' => $this->cli_help['name'] . LF . LF . $this->cli_help['description'], 'headers' => array('deleted' => array('Index of deleted records', 'These are records from the page tree having the deleted-flag set. The --AUTOFIX option will flush them completely!', 1)), 'deleted' => array());
$startingPoint = $this->cli_isArg('--pid') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--pid'), 0) : 0;
$depth = $this->cli_isArg('--depth') ? \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($this->cli_argValue('--depth'), 0) : 1000;
$this->genTree($startingPoint, $depth, (int) $this->cli_argValue('--echotree'));
$resultArray['deleted'] = $this->recStats['deleted'];
return $resultArray;
}
示例13: renderStatic
/**
* @param array $arguments
* @param \Closure $renderChildrenClosure
* @param RenderingContextInterface $renderingContext
*
* @return string
*/
public static function renderStatic(array $arguments, \Closure $renderChildrenClosure, RenderingContextInterface $renderingContext)
{
$maximumNumberOfResultPages = $arguments['maximumNumberOfResultPages'];
$numberOfResults = $arguments['numberOfResults'];
$resultsPerPage = $arguments['resultsPerPage'];
$currentPage = $arguments['currentPage'];
$freeIndexUid = $arguments['freeIndexUid'];
if ($resultsPerPage <= 0) {
$resultsPerPage = 10;
}
$pageCount = (int) ceil($numberOfResults / $resultsPerPage);
// only show the result browser if more than one page is needed
if ($pageCount === 1) {
return '';
}
// Check if $currentPage is in range
$currentPage = MathUtility::forceIntegerInRange($currentPage, 0, $pageCount - 1);
$content = '';
// prev page
// show on all pages after the 1st one
if ($currentPage > 0) {
$label = LocalizationUtility::translate('displayResults.previous', 'IndexedSearch');
$content .= '<li>' . self::makecurrentPageSelector_link($label, $currentPage - 1, $freeIndexUid) . '</li>';
}
// Check if $maximumNumberOfResultPages is in range
$maximumNumberOfResultPages = MathUtility::forceIntegerInRange($maximumNumberOfResultPages, 1, $pageCount, 10);
// Assume $currentPage is in the middle and calculate the index limits of the result page listing
$minPage = $currentPage - (int) floor($maximumNumberOfResultPages / 2);
$maxPage = $minPage + $maximumNumberOfResultPages - 1;
// Check if the indexes are within the page limits
if ($minPage < 0) {
$maxPage -= $minPage;
$minPage = 0;
} elseif ($maxPage >= $pageCount) {
$minPage -= $maxPage - $pageCount + 1;
$maxPage = $pageCount - 1;
}
$pageLabel = LocalizationUtility::translate('displayResults.page', 'IndexedSearch');
for ($a = $minPage; $a <= $maxPage; $a++) {
$label = trim($pageLabel . ' ' . ($a + 1));
$label = self::makecurrentPageSelector_link($label, $a, $freeIndexUid);
if ($a === $currentPage) {
$content .= '<li class="tx-indexedsearch-browselist-currentPage"><strong>' . $label . '</strong></li>';
} else {
$content .= '<li>' . $label . '</li>';
}
}
// next link
if ($currentPage < $pageCount - 1) {
$label = LocalizationUtility::translate('displayResults.next', 'IndexedSearch');
$content .= '<li>' . self::makecurrentPageSelector_link($label, $currentPage + 1, $freeIndexUid) . '</li>';
}
return '<ul class="tx-indexedsearch-browsebox">' . $content . '</ul>';
}
示例14: forceIntegerInRange
/**
* Forces the integer $theInt into the boundaries of $min and $max.
* If the $theInt is 'FALSE' then the $zeroValue is applied.
*
* @param integer $theInt Input value
* @param integer $min Lower limit
* @param integer $max Higher limit
* @param integer $zeroValue Default value if input is FALSE.
* @return integer The input value forced into the boundaries of $min and $max
*/
public static function forceIntegerInRange($theInt, $min, $max = 2000000000, $zeroValue = 0)
{
$result = '';
if (self::isEqualOrHigherSixZero()) {
$result = \TYPO3\CMS\Core\Utility\MathUtility::forceIntegerInRange($theInt, $min, $max, $zeroValue);
} elseif (class_exists('t3lib_utility_Math')) {
$result = t3lib_utility_Math::forceIntegerInRange($theInt, $min, $max, $zeroValue);
} else {
$result = t3lib_div::intInRange($theInt, $min, $max, $zeroValue);
}
return $result;
}
示例15: setCurrentPoint
/**
* Set the point (between -100 and 100)
*
* @param int $x
* @param int $y
* @return void
*/
public function setCurrentPoint($x, $y)
{
$values = ['focus_point_x' => MathUtility::forceIntegerInRange($x, -100, 100, 0), 'focus_point_y' => MathUtility::forceIntegerInRange($y, -100, 100, 0)];
GlobalUtility::getDatabaseConnection()->exec_UPDATEquery('sys_file_reference', 'uid=' . $this->getReferenceUid(), $values);
// save also to the file
$reference = ResourceFactory::getInstance()->getFileReferenceObject($this->getReferenceUid());
$fileUid = $reference->getOriginalFile()->getUid();
$row = GlobalUtility::getDatabaseConnection()->exec_SELECTgetSingleRow('*', 'sys_file_metadata', 'file=' . $fileUid);
if ($row) {
GlobalUtility::getDatabaseConnection()->exec_UPDATEquery('sys_file_metadata', 'uid=' . $row['uid'], $values);
}
}