本文整理汇总了PHP中TYPO3\CMS\Core\Utility\GeneralUtility::inList方法的典型用法代码示例。如果您正苦于以下问题:PHP GeneralUtility::inList方法的具体用法?PHP GeneralUtility::inList怎么用?PHP GeneralUtility::inList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\GeneralUtility
的用法示例。
在下文中一共展示了GeneralUtility::inList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValidOrdering
/**
* Validate ordering as extbase can't handle that currently
*
* @param string $fieldToCheck
* @param string $allowedSettings
* @return boolean
*/
public static function isValidOrdering($fieldToCheck, $allowedSettings)
{
$isValid = TRUE;
if (empty($fieldToCheck)) {
return $isValid;
} elseif (empty($allowedSettings)) {
return FALSE;
}
$fields = GeneralUtility::trimExplode(',', $fieldToCheck, TRUE);
foreach ($fields as $field) {
if ($isValid === TRUE) {
$split = GeneralUtility::trimExplode(' ', $field, TRUE);
$count = count($split);
switch ($count) {
case 1:
if (!GeneralUtility::inList($allowedSettings, $split[0])) {
$isValid = FALSE;
}
break;
case 2:
if (strtolower($split[1]) !== 'desc' && strtolower($split[1]) !== 'asc' || !GeneralUtility::inList($allowedSettings, $split[0])) {
$isValid = FALSE;
}
break;
default:
$isValid = FALSE;
}
}
}
return $isValid;
}
示例2: addData
/**
* Initialize new row with default values from various sources
*
* @param array $result
* @return array
*/
public function addData(array $result)
{
$databaseRow = $result['databaseRow'];
$newRow = $databaseRow;
foreach ($result['processedTca']['columns'] as $fieldName => $fieldConfig) {
// Keep current value if it can be resolved to "the is something" directly
if (isset($databaseRow[$fieldName])) {
$newRow[$fieldName] = $databaseRow[$fieldName];
continue;
}
// Special handling for eval null
if (!empty($fieldConfig['config']['eval']) && GeneralUtility::inList($fieldConfig['config']['eval'], 'null')) {
if (array_key_exists($fieldName, $databaseRow) || array_key_exists('default', $fieldConfig['config']) && $fieldConfig['config']['default'] === null) {
$newRow[$fieldName] = null;
} else {
$newRow[$fieldName] = (string) $fieldConfig['config']['default'];
}
} else {
// Fun part: This forces empty string for any field even if no default is set. Unsure if that is a good idea.
$newRow[$fieldName] = (string) $fieldConfig['config']['default'];
}
}
$result['databaseRow'] = $newRow;
return $result;
}
示例3: reBuild
/**
* Rebuild the class cache
*
* @param array $parameters
*
* @throws \Evoweb\Extender\Exception\FileNotFoundException
* @throws \TYPO3\CMS\Core\Cache\Exception\InvalidDataException
* @return void
*/
public function reBuild(array $parameters = array())
{
if (empty($parameters) || !empty($parameters['cacheCmd']) && GeneralUtility::inList('all,system', $parameters['cacheCmd']) && isset($GLOBALS['BE_USER'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['EXTCONF'] as $extensionKey => $extensionConfiguration) {
if (!isset($extensionConfiguration['extender']) || !is_array($extensionConfiguration['extender'])) {
continue;
}
foreach ($extensionConfiguration['extender'] as $entity => $entityConfiguration) {
$key = 'Domain/Model/' . $entity;
// Get the file to extend, this needs to be loaded as first
$path = ExtensionManagementUtility::extPath($extensionKey) . 'Classes/' . $key . '.php';
if (!is_file($path)) {
throw new \Evoweb\Extender\Exception\FileNotFoundException('given file "' . $path . '" does not exist');
}
$code = $this->parseSingleFile($path, false);
// Get the files from all other extensions that are extending this domain model
if (is_array($entityConfiguration)) {
foreach ($entityConfiguration as $extendingExtension => $extendingFilepath) {
$path = GeneralUtility::getFileAbsFileName($extendingFilepath, false);
if (!is_file($path) && !is_numeric($extendingExtension)) {
$path = ExtensionManagementUtility::extPath($extendingExtension) . 'Classes/' . $key . '.php';
}
$code .= $this->parseSingleFile($path);
}
}
// Close the class definition
$code = $this->closeClassDefinition($code);
// Add the new file to the class cache
$cacheEntryIdentifier = GeneralUtility::underscoredToLowerCamelCase($extensionKey) . '_' . str_replace('/', '', $key);
$this->cacheInstance->set($cacheEntryIdentifier, $code);
}
}
}
}
示例4: initializeAction
/**
* Initialize actions. These actions are meant to be called by an logged-in FE User.
*/
public function initializeAction()
{
// Perhaps it should go into a validator?
// Check permission before executing any action.
$allowedFrontendGroups = trim($this->settings['allowedFrontendGroups']);
if ($allowedFrontendGroups === '*') {
if (empty($this->getFrontendUser()->user)) {
throw new Exception('FE User must be logged-in.', 1387696171);
}
} elseif (!empty($allowedFrontendGroups)) {
$isAllowed = FALSE;
$frontendGroups = GeneralUtility::trimExplode(',', $allowedFrontendGroups, TRUE);
foreach ($frontendGroups as $frontendGroup) {
if (GeneralUtility::inList($this->getFrontendUser()->user['usergroup'], $frontendGroup)) {
$isAllowed = TRUE;
break;
}
}
// Throw exception if not allowed
if (!$isAllowed) {
throw new Exception('FE User does not have enough permission.', 1415211931);
}
}
$this->emitBeforeHandleUploadSignal();
}
示例5: render
/**
* Renders <f:then> child if BE user is allowed to edit given table, otherwise renders <f:else> child.
*
* @param string $table Name of the table
* @return string the rendered string
* @api
*/
public function render($table)
{
if ($GLOBALS['BE_USER']->isAdmin() || \TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['BE_USER']->groupData['tables_modify'], $table)) {
return $this->renderThenChild();
}
return $this->renderElseChild();
}
示例6: render
/**
* Rendering the cObject, HMENU
*
* @param array $conf Array of TypoScript properties
* @return string Output
*/
public function render($conf = array())
{
$theValue = '';
if ($this->cObj->checkIf($conf['if.'])) {
$cls = strtolower($conf[1]);
if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($GLOBALS['TSFE']->tmpl->menuclasses, $cls)) {
if (isset($conf['excludeUidList.'])) {
$conf['excludeUidList'] = $this->cObj->stdWrap($conf['excludeUidList'], $conf['excludeUidList.']);
}
if (isset($conf['special.']['value.'])) {
$conf['special.']['value'] = $this->cObj->stdWrap($conf['special.']['value'], $conf['special.']['value.']);
}
$GLOBALS['TSFE']->register['count_HMENU']++;
$GLOBALS['TSFE']->register['count_HMENU_MENUOBJ'] = 0;
$GLOBALS['TSFE']->register['count_MENUOBJ'] = 0;
$GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMid'] = array();
$GLOBALS['TSFE']->applicationData['GMENU_LAYERS']['WMparentId'] = array();
$menu = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tslib_' . $cls);
$menu->parent_cObj = $this->cObj;
$menu->start($GLOBALS['TSFE']->tmpl, $GLOBALS['TSFE']->sys_page, '', $conf, 1);
$menu->makeMenu();
$theValue .= $menu->writeMenu();
}
$wrap = isset($conf['wrap.']) ? $this->cObj->stdWrap($conf['wrap'], $conf['wrap.']) : $conf['wrap'];
if ($wrap) {
$theValue = $this->cObj->wrap($theValue, $wrap);
}
if (isset($conf['stdWrap.'])) {
$theValue = $this->cObj->stdWrap($theValue, $conf['stdWrap.']);
}
}
return $theValue;
}
示例7: render
/**
* Handler for unknown types.
*
* @return array As defined in initializeResultArray() of AbstractNode
*/
public function render()
{
$resultArray = $this->initializeResultArray();
$languageService = $this->getLanguageService();
$row = $this->data['databaseRow'];
$parameterArray = $this->data['parameterArray'];
// If ratios are set do not add default options
if (isset($parameterArray['fieldConf']['config']['ratios'])) {
unset($this->defaultConfig['ratios']);
}
$config = ArrayUtility::arrayMergeRecursiveOverrule($this->defaultConfig, $parameterArray['fieldConf']['config']);
// By default we allow all image extensions that can be handled by the GFX functionality
if ($config['allowedExtensions'] === null) {
$config['allowedExtensions'] = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
}
if ($config['readOnly']) {
$options = array();
$options['parameterArray'] = array('fieldConf' => array('config' => $config), 'itemFormElValue' => $parameterArray['itemFormElValue']);
$options['renderType'] = 'none';
return $this->nodeFactory->create($options)->render();
}
$file = $this->getFile($row, $config['file_field']);
if (!$file) {
return $resultArray;
}
$content = '';
$preview = '';
if (GeneralUtility::inList(mb_strtolower($config['allowedExtensions']), mb_strtolower($file->getExtension()))) {
// Get preview
$preview = $this->getPreview($file, $parameterArray['itemFormElValue']);
// Check if ratio labels hold translation strings
foreach ((array) $config['ratios'] as $ratio => $label) {
$config['ratios'][$ratio] = $languageService->sL($label, true);
}
$formFieldId = StringUtility::getUniqueId('formengine-image-manipulation-');
$wizardData = array('zoom' => $config['enableZoom'] ? '1' : '0', 'ratios' => json_encode($config['ratios']), 'file' => $file->getUid());
$wizardData['token'] = GeneralUtility::hmac(implode('|', $wizardData), 'ImageManipulationWizard');
$buttonAttributes = array('data-url' => BackendUtility::getAjaxUrl('wizard_image_manipulation', $wizardData), 'data-severity' => 'notice', 'data-image-name' => $file->getNameWithoutExtension(), 'data-image-uid' => $file->getUid(), 'data-file-field' => $config['file_field'], 'data-field' => $formFieldId);
$button = '<button class="btn btn-default t3js-image-manipulation-trigger"';
foreach ($buttonAttributes as $key => $value) {
$button .= ' ' . $key . '="' . htmlspecialchars($value) . '"';
}
$button .= '><span class="t3-icon fa fa-crop"></span>';
$button .= $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.open-editor', true);
$button .= '</button>';
$inputField = '<input type="hidden" ' . 'id="' . $formFieldId . '" ' . 'name="' . $parameterArray['itemFormElName'] . '" ' . 'value="' . htmlspecialchars($parameterArray['itemFormElValue']) . '" />';
$content .= $inputField . $button;
$content .= $this->getImageManipulationInfoTable($parameterArray['itemFormElValue']);
$resultArray['requireJsModules'][] = array('TYPO3/CMS/Backend/ImageManipulation' => 'function(ImageManipulation){ImageManipulation.initializeTrigger()}');
}
$content .= '<p class="text-muted"><em>' . $languageService->sL('LLL:EXT:lang/locallang_wizards.xlf:imwizard.supported-types-message', true) . '<br />';
$content .= mb_strtoupper(implode(', ', GeneralUtility::trimExplode(',', $config['allowedExtensions'])));
$content .= '</em></p>';
$item = '<div class="media">';
$item .= $preview;
$item .= '<div class="media-body">' . $content . '</div>';
$item .= '</div>';
$resultArray['html'] = $item;
return $resultArray;
}
示例8: 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);
}
示例9: manipulateWizardItems
/**
* Processes the items of the new content element wizard
* and inserts necessary default values for items created within a grid
*
* @param array $wizardItems : The array containing the current status of the wizard item list before rendering
* @param \TYPO3\CMS\Backend\Controller\ContentElement\NewContentElementController $parentObject : The parent object that triggered this hook
*
* @return void
*/
public function manipulateWizardItems(&$wizardItems, &$parentObject)
{
if (!GeneralUtility::inList($GLOBALS['BE_USER']->groupData['explicit_allowdeny'], 'tt_content:CType:gridelements_pi1:DENY')) {
$pageID = $parentObject->id;
$this->init($pageID);
$container = (int) GeneralUtility::_GP('tx_gridelements_container');
$column = (int) GeneralUtility::_GP('tx_gridelements_columns');
$allowed_GP = GeneralUtility::_GP('tx_gridelements_allowed');
if (!empty($allowed_GP)) {
$allowed = array_flip(explode(',', $allowed_GP));
$allowedGridTypes_GP = GeneralUtility::_GP('tx_gridelements_allowed_grid_types');
if (!empty($allowedGridTypes_GP)) {
$allowed['gridelements_pi1'] = 1;
}
$this->removeDisallowedWizardItems($allowed, $wizardItems);
} else {
$allowed = null;
}
if (empty($allowed) || isset($allowed['gridelements_pi1'])) {
$allowedGridTypes = array_flip(GeneralUtility::trimExplode(',', GeneralUtility::_GP('tx_gridelements_allowed_grid_types'), true));
$excludeLayouts = $this->getExcludeLayouts($container, $parentObject);
$gridItems = $this->layoutSetup->getLayoutWizardItems($parentObject->colPos, $excludeLayouts, $allowedGridTypes);
$this->addGridItemsToWizard($gridItems, $wizardItems);
}
$this->addGridValuesToWizardItems($wizardItems, $container, $column);
$this->removeEmptyHeadersFromWizard($wizardItems);
}
}
示例10: render
/**
* Renders else-child or else-argument if variable $item is in $list
*
* @param string $list
* @param string $item
* @return string
*/
public function render($list, $item)
{
if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($list, $item) === TRUE) {
return $this->renderThenChild();
}
return $this->renderElseChild();
}
示例11: render
/**
* Renders else-child or else-argument if variable $item is in $list
*
* @return string
*/
public function render()
{
if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($this->arguments['list'], $this->arguments['item']) === true) {
return $this->renderThenChild();
}
return $this->renderElseChild();
}
示例12: evaluateCondition
/**
* This method decides if the condition is TRUE or FALSE. It can be overriden in extending viewhelpers to adjust functionality.
*
* @param array $arguments ViewHelper arguments to evaluate the condition for this ViewHelper, allows for flexiblity in overriding this method.
* @return bool
*/
protected static function evaluateCondition($arguments = null)
{
if (\TYPO3\CMS\Core\Utility\GeneralUtility::inList($arguments['list'], $arguments['item']) === true) {
return true;
} else {
return false;
}
}
示例13: getSingleField_postProcess
/**
* Remove rendered field from output if it is no event
*
* @param string $table
* @param string $field
* @param array $row
* @param string $out
* @return void
*/
public function getSingleField_postProcess($table, $field, $row, &$out)
{
if ($table === 'tx_news_domain_model_news' && $row['is_event'] == 0) {
if (GeneralUtility::inList(self::FIELDS, $field)) {
$out = '';
}
}
}
示例14: render
/**
* Check if given list contains given item. If yes, render the thenChild, otherwise
* the elseChild
*
* @param string $list list of items
* @param string $item item
* @return string
*/
public function render()
{
if (GeneralUtility::inList($this->arguments['list'], $this->arguments['item'])) {
return true;
} else {
return false;
}
}
示例15: getOrderBy
/**
* Returns the field for the ORDER BY statement
*
* @return string
*/
public function getOrderBy()
{
$orderBy = 'lastUpdated';
if (isset($this->settings['orderBy']) && GeneralUtility::inList($this->getAllowedOrderByFields(), $this->settings['orderBy'])) {
$orderBy = (string) $this->settings['orderBy'];
}
return $orderBy;
}