本文整理汇总了PHP中TYPO3\CMS\Core\Utility\ArrayUtility::inArray方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayUtility::inArray方法的具体用法?PHP ArrayUtility::inArray怎么用?PHP ArrayUtility::inArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TYPO3\CMS\Core\Utility\ArrayUtility
的用法示例。
在下文中一共展示了ArrayUtility::inArray方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: filterMenuPages
/**
* Checks if a page is OK to include in the final menu item array. Pages can be excluded if the doktype is wrong,
* if they are hidden in navigation, have a uid in the list of banned uids etc.
*
* @param array $data Array of menu items
* @param array $banUidArray Array of page uids which are to be excluded
* @param bool $spacer If set, then the page is a spacer.
* @return bool Returns TRUE if the page can be safely included.
*
* @throws \UnexpectedValueException
*/
public function filterMenuPages(&$data, $banUidArray, $spacer)
{
$includePage = true;
if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/tslib/class.tslib_menu.php']['filterMenuPages'])) {
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/tslib/class.tslib_menu.php']['filterMenuPages'] as $classRef) {
$hookObject = GeneralUtility::getUserObj($classRef);
if (!$hookObject instanceof AbstractMenuFilterPagesHookInterface) {
throw new \UnexpectedValueException('$hookObject must implement interface ' . AbstractMenuFilterPagesHookInterface::class, 1269877402);
}
$includePage = $includePage && $hookObject->processFilter($data, $banUidArray, $spacer, $this);
}
}
if (!$includePage) {
return false;
}
if ($data['_SAFE']) {
return true;
}
if (($this->mconf['SPC'] || !$spacer) && (!$data['nav_hide'] || $this->conf['includeNotInMenu']) && !GeneralUtility::inList($this->doktypeExcludeList, $data['doktype']) && !ArrayUtility::inArray($banUidArray, $data['uid'])) {
// Checks if the default language version can be shown:
// Block page is set, if l18n_cfg allows plus: 1) Either default language or 2) another language but NO overlay record set for page!
$tsfe = $this->getTypoScriptFrontendController();
$blockPage = $data['l18n_cfg'] & 1 && (!$tsfe->sys_language_uid || $tsfe->sys_language_uid && !$data['_PAGES_OVERLAY']);
if (!$blockPage) {
// Checking if a page should be shown in the menu depending on whether a translation exists:
$tok = true;
// There is an alternative language active AND the current page requires a translation:
if ($tsfe->sys_language_uid && GeneralUtility::hideIfNotTranslated($data['l18n_cfg'])) {
if (!$data['_PAGES_OVERLAY']) {
$tok = false;
}
}
// Continue if token is TRUE:
if ($tok) {
// Checking if "&L" should be modified so links to non-accessible pages will not happen.
if ($this->conf['protectLvar']) {
$languageUid = (int) $tsfe->config['config']['sys_language_uid'];
if ($languageUid && ($this->conf['protectLvar'] == 'all' || GeneralUtility::hideIfNotTranslated($data['l18n_cfg']))) {
$olRec = $tsfe->sys_page->getPageOverlay($data['uid'], $languageUid);
if (empty($olRec)) {
// If no pages_language_overlay record then page can NOT be accessed in
// the language pointed to by "&L" and therefore we protect the link by setting "&L=0"
$data['_ADD_GETVARS'] .= '&L=0';
}
}
}
return true;
}
}
}
return false;
}
示例2: dbFileIcons
//.........这里部分代码省略.........
$itemTitle = 'unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(basename($elValue))) . ')';
}
$aOnClick .= 'setFormValueFromBrowseWin(' . GeneralUtility::quoteJSvalue($fName) . ',unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(str_replace('%20', ' ', $elValue))) . '),' . $itemTitle . ',' . $itemTitle . ');';
}
$aOnClick .= 'return false;';
$icons['R'][] = '
<a href="#"
class="btn btn-default"
onclick="' . htmlspecialchars($aOnClick) . '"
title="' . htmlspecialchars(sprintf($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.clipInsert_' . ($mode == 'db' ? 'db' : 'file')), count($clipElements))) . '">
' . $this->iconFactory->getIcon('actions-document-paste-into', Icon::SIZE_SMALL)->render() . '
</a>';
}
}
if (!$params['readOnly'] && !$params['noDelete']) {
$icons['L'][] = '
<a href="#"
class="btn btn-default t3js-btn-removeoption"
onClick="' . $rOnClickInline . '"
data-fieldname="' . $fName . '"
title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.remove_selected')) . '">
' . $this->iconFactory->getIcon('actions-selection-delete', Icon::SIZE_SMALL)->render() . '
</a>';
}
// Thumbnails
$imagesOnly = false;
if ($params['thumbnails'] && $params['allowed']) {
// In case we have thumbnails, check if only images are allowed.
// In this case, render them below the field, instead of to the right
$allowedExtensionList = $params['allowed'];
$imageExtensionList = GeneralUtility::trimExplode(',', strtolower($GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']), true);
$imagesOnly = true;
foreach ($allowedExtensionList as $allowedExtension) {
if (!ArrayUtility::inArray($imageExtensionList, $allowedExtension)) {
$imagesOnly = false;
break;
}
}
}
$thumbnails = '';
if (is_array($params['thumbnails']) && !empty($params['thumbnails'])) {
if ($imagesOnly) {
$thumbnails .= '<ul class="list-inline">';
foreach ($params['thumbnails'] as $thumbnail) {
$thumbnails .= '<li><span class="thumbnail">' . $thumbnail['image'] . '</span></li>';
}
$thumbnails .= '</ul>';
} else {
$thumbnails .= '<div class="table-fit"><table class="table table-white"><tbody>';
foreach ($params['thumbnails'] as $thumbnail) {
$thumbnails .= '
<tr>
<td class="col-icon">
' . ($config['internal_type'] === 'db' ? BackendUtility::wrapClickMenuOnIcon($thumbnail['image'], $thumbnail['table'], $thumbnail['uid'], 1, '', '+copy,info,edit,view') : $thumbnail['image']) . '
</td>
<td class="col-title">
' . ($config['internal_type'] === 'db' ? BackendUtility::wrapClickMenuOnIcon($thumbnail['name'], $thumbnail['table'], $thumbnail['uid'], 1, '', '+copy,info,edit,view') : $thumbnail['name']) . '
' . ($config['internal_type'] === 'db' ? ' <span class="text-muted">[' . $thumbnail['uid'] . ']</span>' : '') . '
</td>
</tr>
';
}
$thumbnails .= '</tbody></table></div>';
}
}
// Allowed Tables
示例3: generate_level
/**
* Generates a number of lines of JavaScript code for a menu level.
* Calls itself recursively for additional levels.
*
* @param int $levels Number of levels to generate
* @param int $count Current level being generated - and if this number is less than $levels it will call itself recursively with $count incremented
* @param int $pid Page id of the starting point.
* @param array|string $menuItemArray $this->menuArr passed along
* @param array $MP_array Previous MP vars
* @return string JavaScript code lines.
* @access private
*/
public function generate_level($levels, $count, $pid, $menuItemArray = '', $MP_array = array())
{
$count = (int) $count;
$levelConf = $this->mconf[$count . '.'];
// Translate PID to a mount page, if any:
$mount_info = $this->sys_page->getMountPointInfo($pid);
if (is_array($mount_info)) {
$MP_array[] = $mount_info['MPvar'];
$pid = $mount_info['mount_pid'];
}
// UIDs to ban:
$banUidArray = $this->getBannedUids();
// Initializing variables:
$var = $this->JSVarName;
$menuName = $this->JSMenuName;
$parent = $count === 1 ? 0 : $var . ($count - 1);
$prev = 0;
$c = 0;
$codeLines = '';
$menuItems = is_array($menuItemArray) ? $menuItemArray : $this->sys_page->getMenu($pid);
foreach ($menuItems as $uid => $data) {
// $data['_MP_PARAM'] contains MP param for overlay mount points (MPs with "substitute this page" set)
// if present: add param to copy of MP array (copy used for that submenu branch only)
$MP_array_sub = $MP_array;
if (array_key_exists('_MP_PARAM', $data) && $data['_MP_PARAM']) {
$MP_array_sub[] = $data['_MP_PARAM'];
}
// Set "&MP=" var:
$MP_var = implode(',', $MP_array_sub);
$MP_params = $MP_var ? '&MP=' . rawurlencode($MP_var) : '';
// If item is a spacer, $spacer is set
$spacer = GeneralUtility::inList($this->spacerIDList, $data['doktype']) ? 1 : 0;
// If the spacer-function is not enabled, spacers will not enter the $menuArr
if ($this->mconf['SPC'] || !$spacer) {
// Page may not be 'not_in_menu' or 'Backend User Section' + not in banned uid's
if (!GeneralUtility::inList($this->doktypeExcludeList, $data['doktype']) && (!$data['nav_hide'] || $this->conf['includeNotInMenu']) && !ArrayUtility::inArray($banUidArray, $uid)) {
if ($count < $levels) {
$addLines = $this->generate_level($levels, $count + 1, $data['uid'], '', $MP_array_sub);
} else {
$addLines = '';
}
$title = $data['title'];
$url = '';
$target = '';
if (!$addLines && !$levelConf['noLink'] || $levelConf['alwaysLink']) {
$LD = $this->menuTypoLink($data, $this->mconf['target'], '', '', array(), $MP_params, $this->mconf['forceTypeValue']);
// If access restricted pages should be shown in menus, change the link of such pages to link to a redirection page:
$this->changeLinksForAccessRestrictedPages($LD, $data, $this->mconf['target'], $this->mconf['forceTypeValue']);
$url = $this->getTypoScriptFrontendController()->baseUrlWrap($LD['totalURL']);
$target = $LD['target'];
}
$codeLines .= LF . $var . $count . '=' . $menuName . '.add(' . $parent . ',' . $prev . ',0,' . GeneralUtility::quoteJSvalue($title, TRUE) . ',' . GeneralUtility::quoteJSvalue($url, TRUE) . ',' . GeneralUtility::quoteJSvalue($target, TRUE) . ');';
// If the active one should be chosen...
$active = $levelConf['showActive'] && $this->isActive($data['uid'], $MP_var);
// If the first item should be shown
$first = !$c && $levelConf['showFirst'];
// do it...
if ($active || $first) {
if ($count === 1) {
$codeLines .= LF . $menuName . '.openID = ' . $var . $count . ';';
} else {
$codeLines .= LF . $menuName . '.entry[' . $parent . '].openID = ' . $var . $count . ';';
}
}
// Add submenu...
$codeLines .= $addLines;
$prev = $var . $count;
$c++;
}
}
}
if ($this->mconf['firstLabelGeneral'] && !$levelConf['firstLabel']) {
$levelConf['firstLabel'] = $this->mconf['firstLabelGeneral'];
}
if ($levelConf['firstLabel'] && $codeLines) {
$codeLines .= LF . $menuName . '.defTopTitle[' . $count . '] = ' . GeneralUtility::quoteJSvalue($levelConf['firstLabel'], TRUE) . ';';
}
return $codeLines;
}
示例4: blindGroupNames
/**
* Corresponds to blindUserNames but works for groups instead
*
* @param array $groups Group names
* @param array $groupArray Group names (reference)
* @param bool $excludeBlindedFlag If $excludeBlindedFlag is set, then these records are unset from the array $usernames
* @return array
*/
public static function blindGroupNames($groups, $groupArray, $excludeBlindedFlag = false)
{
if (is_array($groups) && is_array($groupArray)) {
foreach ($groups as $uid => $row) {
$groupN = $uid;
$set = 0;
if (ArrayUtility::inArray($groupArray, $uid)) {
$groupN = $row['title'];
$set = 1;
}
$groups[$uid]['title'] = $groupN;
if ($excludeBlindedFlag && !$set) {
unset($groups[$uid]);
}
}
}
return $groups;
}
示例5: inArray
/**
* Check if an string item exists in an array.
* Please note that the order of function parameters is reverse compared to the PHP function in_array()!!!
*
* Comparison to PHP in_array():
* -> $array = array(0, 1, 2, 3);
* -> variant_a := \TYPO3\CMS\Core\Utility\ArrayUtility::inArray($array, $needle)
* -> variant_b := in_array($needle, $array)
* -> variant_c := in_array($needle, $array, TRUE)
* +---------+-----------+-----------+-----------+
* | $needle | variant_a | variant_b | variant_c |
* +---------+-----------+-----------+-----------+
* | '1a' | FALSE | TRUE | FALSE |
* | '' | FALSE | TRUE | FALSE |
* | '0' | TRUE | TRUE | FALSE |
* | 0 | TRUE | TRUE | TRUE |
* +---------+-----------+-----------+-----------+
*
* @param array $in_array One-dimensional array of items
* @param string $item Item to check for
* @return bool TRUE if $item is in the one-dimensional array $in_array
* @deprecated since TYPO3 CMS 7, will be removed in TYPO3 CMS 8 - use ArrayUtility::inArray() instead
*/
public static function inArray(array $in_array, $item)
{
static::logDeprecatedFunction();
return ArrayUtility::inArray($in_array, $item);
}
示例6: addDataArray
/**
* Prepare insert array for the TCE
*
* @param array $data Array for the TCE
* @param string $id Record ID
* @param array $dataArray The data to be imported
*
* @return void
*/
public function addDataArray(array &$data, $id, array $dataArray)
{
$data['tt_address'][$id] = $dataArray;
$data['tt_address'][$id]['pid'] = $this->indata['storage'];
if ($this->indata['all_html']) {
$data['tt_address'][$id]['module_sys_dmail_html'] = $this->indata['all_html'];
}
if (is_array($this->indata['cat']) && !ArrayUtility::inArray($this->indata['map'], 'cats')) {
foreach ($this->indata['cat'] as $k => $v) {
$data['tt_address'][$id]['module_sys_dmail_category'][$k] = $v;
}
}
}
示例7: inArrayChecksStringExistenceWithinArray
/**
* @test
* @dataProvider inArrayDataProvider
* @param array $array target array
* @param string $item search string
* @param bool $expected expected value
*/
public function inArrayChecksStringExistenceWithinArray($array, $item, $expected)
{
$this->assertEquals($expected, ArrayUtility::inArray($array, $item));
}
示例8: setContentFormat
/**
* Sets the content format for the ajax call
*
* @param string $format Can be one of 'plain' (default), 'xml', 'json', 'javascript', 'jsonbody' or 'jsonhead'
* @return void
*/
public function setContentFormat($format)
{
if (ArrayUtility::inArray(['plain', 'xml', 'json', 'jsonhead', 'jsonbody', 'javascript'], $format)) {
$this->contentFormat = $format;
}
}