本文整理汇总了PHP中TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger方法的典型用法代码示例。如果您正苦于以下问题:PHP MathUtility::convertToPositiveInteger方法的具体用法?PHP MathUtility::convertToPositiveInteger怎么用?PHP MathUtility::convertToPositiveInteger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\MathUtility
的用法示例。
在下文中一共展示了MathUtility::convertToPositiveInteger方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: main
/**
* @param array $tsConfig
* @param array $userArguments
*
* @return string
*/
public function main(array $tsConfig, $userArguments = [])
{
$url = $tsConfig['url'];
$regExpCurlyBraceOpen = preg_quote(rawurlencode('{'), '@');
$regExpCurlyBraceClose = preg_quote(rawurlencode('}'), '@');
$pattern = "@{$regExpCurlyBraceOpen}product{$regExpCurlyBraceClose}@i";
// Return if argument to be replaced is not set!
if (!preg_match($pattern, $url)) {
return $tsConfig['TAG'];
}
/** @var \TYPO3\CMS\Core\Database\DatabaseConnection $db */
$db = $GLOBALS['TYPO3_DB'];
/**
* <a href="' . $finalTagParts['url'] . '"' . $finalTagParts['targetParams'] . $finalTagParts['aTagParams'] . '>
*
* @see http://docs.typo3.org/typo3cms/TyposcriptReference/Functions/Typolink/Index.html
*/
$return = '<a href="%1$s"%2$s>';
$product = false;
// get necessary params to apply; replace in url
if ($page = $db->exec_SELECTgetSingleRow('tx_product', 'pages', 'uid=' . $GLOBALS['TSFE']->id)) {
if (MathUtility::canBeInterpretedAsInteger($page['tx_product']) && MathUtility::convertToPositiveInteger($page['tx_product'])) {
$product = MathUtility::convertToPositiveInteger($page['tx_product']);
}
}
/** @var \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $contentObject */
$contentObject = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
$url = str_ireplace($GLOBALS['TSFE']->baseUrl, '', $contentObject->getTypoLink_URL($userArguments['targetPid'], $product ? ['product' => $product] : []));
return sprintf($return, $url, $tsConfig['targetParams'] . $tsConfig['aTagParams']);
}
示例2: processDatamap_afterDatabaseOperations
/**
* This method is called by a hook in the TYPO3 core when a record is saved.
*
* We use the tx_linkhandler for backend "save & show" button to display records on the configured detail view page.
*
* @param string $status Type of database operation i.e. new/update.
* @param string $table The table currently being processed.
* @param integer $id The records id (if any).
* @param array $fieldArray The field names and their values to be processed (passed by reference).
* @param \TYPO3\CMS\Core\DataHandling\DataHandler $pObj Reference to the parent object.
*/
public function processDatamap_afterDatabaseOperations($status, $table, $id, $fieldArray, $pObj)
{
if (isset($GLOBALS['_POST']['_savedokview_x'])) {
$settingFound = FALSE;
$currentPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($GLOBALS['_POST']['popViewId']);
$rootPageData = $this->getRootPage($currentPageId);
$defaultPageId = isset($rootPageData) && array_key_exists('uid', $rootPageData) ? $rootPageData['uid'] : $currentPageId;
$pagesTsConfig = \TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($currentPageId);
$handlerConfigurationStruct = $pagesTsConfig['mod.']['tx_linkhandler.'];
// search for the current setting for given table
foreach ($pagesTsConfig['mod.']['tx_linkhandler.'] as $key => $handler) {
if (is_array($handler) && $handler['listTables'] === $table) {
$settingFound = TRUE;
$selectedConfiguration = $key;
break;
}
}
if ($settingFound) {
$l18nPointer = array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl']) ? $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] : '';
if (!\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
$id = $pObj->substNEWwithIDs[$id];
}
if (\TYPO3\CMS\Core\Utility\MathUtility::canBeInterpretedAsInteger($id)) {
$recordArray = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecord($table, $id);
} else {
$recordArray = $fieldArray;
}
if (array_key_exists('previewPageId', $handlerConfigurationStruct[$selectedConfiguration]) && \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']) > 0) {
$previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($handlerConfigurationStruct[$selectedConfiguration]['previewPageId']);
} else {
$previewPageId = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($defaultPageId);
}
if ($GLOBALS['BE_USER']->workspace != 0) {
$timeToLiveHours = intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) ? intval($GLOBALS['BE_USER']->getTSConfigVal('options.workspaces.previewLinkTTLHours')) : 24 * 2;
$wsPreviewValue = ';' . $GLOBALS['BE_USER']->workspace . ':' . $GLOBALS['BE_USER']->user['uid'] . ':' . 60 * 60 * $timeToLiveHours;
// get record UID for
if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) {
$id = $recordArray[$l18nPointer];
} elseif (array_key_exists('t3ver_oid', $recordArray) && intval($recordArray['t3ver_oid']) > 0) {
// this makes no sense because we already receive the UID of the WS-Placeholder which will be the real record in the LIVE-WS
$id = $recordArray['t3ver_oid'];
}
} else {
$wsPreviewValue = '';
if (array_key_exists($l18nPointer, $recordArray) && $recordArray[$l18nPointer] > 0 && $recordArray['sys_language_uid'] > 0) {
$id = $recordArray[$l18nPointer];
}
}
$previewDomainRootline = \TYPO3\CMS\Backend\Utility\BackendUtility::BEgetRootLine($previewPageId);
$previewDomain = \TYPO3\CMS\Backend\Utility\BackendUtility::getViewDomain($previewPageId, $previewDomainRootline);
$linkParamValue = 'record:' . $table . ':' . $id;
$queryString = '&eID=linkhandlerPreview&linkParams=' . urlencode($linkParamValue . $wsPreviewValue);
$languageParam = '&L=' . $recordArray['sys_language_uid'];
$queryString .= $languageParam . '&authCode=' . \TYPO3\CMS\Core\Utility\GeneralUtility::stdAuthCode($linkParamValue . $wsPreviewValue . intval($recordArray['sys_language_uid']), '', 32);
$GLOBALS['_POST']['viewUrl'] = $previewDomain . '/index.php?id=' . $previewPageId . $queryString . '&y=';
$GLOBALS['_POST']['popViewId_addParams'] = $queryString;
}
}
}
示例3: getUserSysLanguageUidForLanguageListing
/**
* Find the selected sys_language_uid which are set by the templavoila page module.
*
* @return integer
*/
private function getUserSysLanguageUidForLanguageListing()
{
$sysLanguageId = 0;
$moduleKey = 'web_txtemplavoilaM1';
if (array_key_exists('web_tvpagemodulM1', $GLOBALS['BE_USER']->uc['moduleData'])) {
$moduleKey = 'web_tvpagemodulM1';
}
if (is_array($GLOBALS['BE_USER']->uc['moduleData'][$moduleKey]) && array_key_exists('language', $GLOBALS['BE_USER']->uc['moduleData'][$moduleKey]) && \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($GLOBALS['BE_USER']->uc['moduleData'][$moduleKey]['language']) > 0) {
$sysLanguageId = $GLOBALS['BE_USER']->uc['moduleData'][$moduleKey]['language'];
}
return $sysLanguageId;
}
示例4: render
/**
* Render a video player
*
* @param FileReference $element
* @param integer $width
* @param integer $height
* @param string $templateFile template file to override. Absolute path
* @return string
*/
public function render(FileReference $element, $width, $height, $templateFile = '')
{
$view = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Fluid_View_StandaloneView');
if (!$templateFile || !is_readable($templateFile)) {
$view->setTemplatePathAndFilename(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('news') . 'Resources/Private/Templates/ViewHelpers/Flv.html');
} else {
$view->setTemplatePathAndFilename($templateFile);
}
$GLOBALS['TSFE']->getPageRenderer()->addJsFile(self::PATH_TO_JS . 'flowplayer-3.2.12.min.js');
$view->assign('width', \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($width));
$view->assign('height', \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($height));
$view->assign('uniqueDivId', 'mediaelement-' . md5($element->getUid() . uniqid()));
$view->assign('url', $element->getOriginalResource()->getPublicUrl());
return $view->render();
}
示例5: render
/**
* Render a video player
*
* @param Tx_News_Domain_Model_Media $element
* @param integer $width
* @param integer $height
* @param string $templateFile template file to override. Absolute path
* @return string
*/
public function render(Tx_News_Domain_Model_Media $element, $width, $height, $templateFile = '')
{
$view = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Fluid_View_StandaloneView');
if (!$templateFile || !is_readable($templateFile)) {
$view->setTemplatePathAndFilename(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('news') . 'Resources/Private/Templates/ViewHelpers/Flv.html');
} else {
$view->setTemplatePathAndFilename($templateFile);
}
$url = Tx_News_Service_FileService::getCorrectUrl($element->getContent());
$GLOBALS['TSFE']->getPageRenderer()->addJsFile(self::PATH_TO_JS . 'flowplayer-3.2.12.min.js');
// override width & height if both are set
if ($element->getWidth() > 0 && $element->getHeight() > 0) {
$width = $element->getWidth();
$height = $element->getHeight();
}
$view->assign('width', \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($width));
$view->assign('height', \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($height));
$view->assign('uniqueDivId', 'mediaelement-' . Tx_News_Service_FileService::getUniqueId($element));
$view->assign('url', $url);
return $view->render();
}
示例6: render
/**
* Render a video player
*
* @param \GeorgRinger\News\Domain\Model\Media $element
* @param int $width
* @param int $height
* @param string $templateFile template file to override. Absolute path
* @return string
*/
public function render(\GeorgRinger\News\Domain\Model\Media $element, $width, $height, $templateFile = '')
{
$view = GeneralUtility::makeInstance('TYPO3\\CMS\\Fluid\\View\\StandaloneView');
if (!$templateFile || !is_readable($templateFile)) {
$view->setTemplatePathAndFilename(ExtensionManagementUtility::extPath('news') . 'Resources/Private/Templates/ViewHelpers/Flv.html');
} else {
$view->setTemplatePathAndFilename($templateFile);
}
$url = FileService::getCorrectUrl($element->getContent());
$pageRenderer = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Page\\PageRenderer');
$pageRenderer->addJsFile(self::PATH_TO_JS . 'flowplayer-3.2.12.min.js');
// override width & height if both are set
if ($element->getWidth() > 0 && $element->getHeight() > 0) {
$width = $element->getWidth();
$height = $element->getHeight();
}
$view->assign('width', MathUtility::convertToPositiveInteger($width));
$view->assign('height', MathUtility::convertToPositiveInteger($height));
$view->assign('uniqueDivId', 'mediaelement-' . FileService::getUniqueId($element));
$view->assign('url', $url);
return $view->render();
}
示例7: linkWrapItems
/**
* Returns the title of a record (from table $table) with the proper link around (that is for "pages"-records a link to the level of that record)
*
* @param string $table Table name
* @param integer $uid UID
* @param string $title Title string
* @param array $row Records array (from table name)
* @return string
*/
public function linkWrapItems($table, $uid, $title, $row)
{
// if we handle translation records, make sure that we refer to the localisation parent with their uid
if (is_array($GLOBALS['TCA'][$table]['ctrl']) && array_key_exists('transOrigPointerField', $GLOBALS['TCA'][$table]['ctrl'])) {
$transOrigPointerField = $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'];
if (\TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($row[$transOrigPointerField]) > 0) {
$uid = $row[$transOrigPointerField];
}
}
$currentImage = '';
if ($this->browselistObj->curUrlInfo['recordTable'] === $table && $this->browselistObj->curUrlInfo['recordUid'] === $uid) {
$currentImage = '<img' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'gfx/blinkarrow_right.gif', 'width="5" height="9"') . ' class="c-blinkArrowL" alt="" />';
}
$title = \TYPO3\CMS\Backend\Utility\BackendUtility::getRecordTitle($table, $row, FALSE, TRUE);
if (@$this->browselistObj->mode === 'rte') {
//used in RTE mode:
$aOnClick = 'return link_spec(\'' . $this->linkHandler . ':' . $table . ':' . $uid . '\');';
} else {
//used in wizard mode
$aOnClick = 'return link_folder(\'' . $this->linkHandler . ':' . $table . ':' . $uid . '\');';
}
return '<a href="#" onclick="' . $aOnClick . '">' . $title . $currentImage . '</a>';
}
示例8: die
if (!defined('TYPO3_MODE')) {
die('Access denied.');
}
?>
<br />
<div id="controll-panel">
<?php
echo $this->getRefreshLink();
?>
<?php
echo $this->getEnableDisableLink();
?>
<?php
// Check if ActiveProcess is reached
if (\TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($this->getActiveProcessCount()) < \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($this->getMaxActiveProcessCount())) {
echo $this->getAddLink();
}
?>
<?php
echo $this->getModeLink();
?>
</div>
<h2><?php
echo $this->getLLLabel('LLL:EXT:crawler/modfunc1/locallang.xml:labels.generalinformation');
?>
:</h2>
<table>
<tr>
<td><?php
示例9: generatePreviewCode
/**
* @return string
*/
protected function generatePreviewCode()
{
$currentPageId = MathUtility::convertToPositiveInteger($this->popViewId);
$table = $this->previewData['table'];
$recordId = $this->previewData['id'];
$pageTsConfig = BackendUtility::getPagesTSconfig($currentPageId);
$previewConfiguration = isset($pageTsConfig['TCEMAIN.']['preview.'][$table . '.']) ? $pageTsConfig['TCEMAIN.']['preview.'][$table . '.'] : array();
$recordArray = BackendUtility::getRecord($table, $recordId);
// find the right preview page id
$previewPageId = 0;
if (isset($previewConfiguration['previewPageId'])) {
$previewPageId = $previewConfiguration['previewPageId'];
}
// if no preview page was configured
if (!$previewPageId) {
$rootPageData = null;
$rootLine = BackendUtility::BEgetRootLine($currentPageId);
$currentPage = reset($rootLine);
if ((int) $currentPage['doktype'] === PageRepository::DOKTYPE_DEFAULT) {
// try the current page
$previewPageId = $currentPageId;
} else {
// or search for the root page
foreach ($rootLine as $page) {
if ($page['is_siteroot']) {
$rootPageData = $page;
break;
}
}
$previewPageId = isset($rootPageData) ? (int) $rootPageData['uid'] : $currentPageId;
}
}
$linkParameters = ['no_cache' => 1];
// language handling
$languageField = isset($GLOBALS['TCA'][$table]['ctrl']['languageField']) ? $GLOBALS['TCA'][$table]['ctrl']['languageField'] : '';
if ($languageField && !empty($recordArray[$languageField])) {
$l18nPointer = isset($GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField']) ? $GLOBALS['TCA'][$table]['ctrl']['transOrigPointerField'] : '';
if ($l18nPointer && !empty($recordArray[$l18nPointer]) && isset($previewConfiguration['useDefaultLanguageRecord']) && !$previewConfiguration['useDefaultLanguageRecord']) {
// use parent record
$recordId = $recordArray[$l18nPointer];
}
$linkParameters['L'] = $recordArray[$languageField];
}
// map record data to GET parameters
if (isset($previewConfiguration['fieldToParameterMap.'])) {
foreach ($previewConfiguration['fieldToParameterMap.'] as $field => $parameterName) {
$value = $recordArray[$field];
if ($field === 'uid') {
$value = $recordId;
}
$linkParameters[$parameterName] = $value;
}
}
// add/override parameters by configuration
if (isset($previewConfiguration['additionalGetParameters.'])) {
$additionalGetParameters = [];
$this->parseAdditionalGetParameters($additionalGetParameters, $previewConfiguration['additionalGetParameters.']);
$linkParameters = array_replace($linkParameters, $additionalGetParameters);
}
$this->popViewId = $previewPageId;
$this->popViewId_addParams = GeneralUtility::implodeArrayForUrl('', $linkParameters, '', false, true);
$previewPageRootline = BackendUtility::BEgetRootLine($this->popViewId);
return '
if (window.opener) {
' . BackendUtility::viewOnClick($this->popViewId, '', $previewPageRootline, '', $this->viewUrl, $this->popViewId_addParams, false) . '
} else {
' . BackendUtility::viewOnClick($this->popViewId, '', $previewPageRootline, '', $this->viewUrl, $this->popViewId_addParams) . '
}';
}
示例10: initTSFE
/**
* Initializes tslib_fe and sets it to $GLOBALS['TSFE']
*
* @return void
*/
protected function initTSFE()
{
\TYPO3\CMS\Frontend\Utility\EidUtility::initTCA();
$pid = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger(GeneralUtility::_GP('id'));
$GLOBALS['TSFE'] = GeneralUtility::makeInstance('tslib_fe', $GLOBALS['TYPO3_CONF_VARS'], $pid, 0, 0, 0);
$GLOBALS['TSFE']->connectToDB();
$GLOBALS['TSFE']->initFEuser();
//!TODO first check if already a fe_user session exists - otherwise this line will overwrite the existing one
$GLOBALS['TSFE']->checkAlternativeIdMethods();
$GLOBALS['TSFE']->determineId();
$GLOBALS['TSFE']->initTemplate();
$GLOBALS['TSFE']->getConfigArray();
$GLOBALS['TSFE']->cObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer');
}
示例11: cmd_compileMailGroup
/**
* Get the recipient IDs given a list of group IDs
*
* @param array $groups List of selected group IDs
*
* @return array list of the recipient ID
*/
protected function cmd_compileMailGroup(array $groups)
{
// If supplied with an empty array, quit instantly as there is nothing to do
if (!count($groups)) {
return array();
}
// Looping through the selected array, in order to fetch recipient details
$idLists = array();
foreach ($groups as $group) {
// Testing to see if group ID is a valid integer, if not - skip to next group ID
$group = MathUtility::convertToPositiveInteger($group);
if (!$group) {
continue;
}
$recipientList = $this->getSingleMailGroup($group);
if (!is_array($recipientList)) {
continue;
}
$idLists = array_merge_recursive($idLists, $recipientList);
}
// Make unique entries
if (is_array($idLists['tt_address'])) {
$idLists['tt_address'] = array_unique($idLists['tt_address']);
}
if (is_array($idLists['fe_users'])) {
$idLists['fe_users'] = array_unique($idLists['fe_users']);
}
if (is_array($idLists[$this->userTable]) && $this->userTable) {
$idLists[$this->userTable] = array_unique($idLists[$this->userTable]);
}
if (is_array($idLists['PLAINLIST'])) {
$idLists['PLAINLIST'] = DirectMailUtility::cleanPlainList($idLists['PLAINLIST']);
}
/**
* Hook for cmd_compileMailGroup
* manipulate the generated id_lists
*/
if (is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['mod2']['cmd_compileMailGroup'])) {
$hookObjectsArr = array();
$temporaryList = "";
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['direct_mail']['mod2']['cmd_compileMailGroup'] as $classRef) {
$hookObjectsArr[] =& GeneralUtility::getUserObj($classRef);
}
foreach ($hookObjectsArr as $hookObj) {
if (method_exists($hookObj, 'cmd_compileMailGroup_postProcess')) {
$temporaryList = $hookObj->cmd_compileMailGroup_postProcess($idLists, $this, $groups);
}
}
unset($idLists);
$idLists = $temporaryList;
}
return array('queryInfo' => array('id_lists' => $idLists));
}
示例12: setPageId
/**
* Set wherever you want to use the parent page id clicked in the tree
*
* @param integer $pid
* @access public
* @return void
*/
function setPageId($pid)
{
$this->pageId = MathUtility::convertToPositiveInteger($pid);
}
示例13: current
</tr>
<tr>
<td><?php
echo $LANG->getLL('general.list.infodetail.incfcewithdefaultlanguage.title');
?>
</td>
<td><?php
echo $configurationElementArray['incfcewithdefaultlanguage'];
?>
</td>
</tr>
</table>
</div>
</td>
<td><?php
echo '<a href="' . \TYPO3\CMS\Core\Utility\GeneralUtility::resolveBackPath($BACK_PATH . \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('l10nmgr')) . 'cm1/index.php?id=' . $configurationElementArray['uid'] . '&srcPID=' . \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($this->getPageId()) . '">' . $configurationElementArray['title'] . '</a>';
?>
</td>
<td><?php
echo current(BackendUtility::getRecordPath($configurationElementArray['pid'], '1', 20, 50));
?>
</td>
<td><?php
echo $configurationElementArray['depth'];
?>
</td>
<td><?php
echo $configurationElementArray['tablelist'];
?>
</td>
<td><?php
示例14: setStartCount
/**
* Setter for start count value.
*
* @param integer $startCount
* @return void
*/
public function setStartCount($startCount)
{
$this->startCount = MathUtility::convertToPositiveInteger($startCount);
}
示例15: setStartCount
/**
* Setter for start count value.
*
* @param integer $startCount
* @return void
*/
public function setStartCount($startCount)
{
$this->startCount = \TYPO3\CMS\Core\Utility\MathUtility::convertToPositiveInteger($startCount);
}