/**
  * 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;
 }
Esempio n. 2
0
    /**
     * Prints the selector box form-field for the db/file/select elements (multiple)
     *
     * @param string $fName Form element name
     * @param string $mode Mode "db", "file" (internal_type for the "group" type) OR blank (then for the "select" type)
     * @param string $allowed Commalist of "allowed
     * @param array $itemArray The array of items. For "select" and "group"/"file" this is just a set of value. For "db" its an array of arrays with table/uid pairs.
     * @param string $selector Alternative selector box.
     * @param array $params An array of additional parameters, eg: "size", "info", "headers" (array with "selector" and "items"), "noBrowser", "thumbnails
     * @param null $_ unused (onFocus in the past), will be removed in TYPO3 CMS 9
     * @param string $table (optional) Table name processing for
     * @param string $field (optional) Field of table name processing for
     * @param string $uid (optional) uid of table record processing for
     * @param array $config (optional) The TCA field config
     * @return string The form fields for the selection.
     * @throws \UnexpectedValueException
     * @todo: Hack this mess into pieces and inline to group / select element depending on what they need
     */
    protected function dbFileIcons($fName, $mode, $allowed, $itemArray, $selector = '', $params = [], $_ = null, $table = '', $field = '', $uid = '', $config = [])
    {
        $languageService = $this->getLanguageService();
        $disabled = '';
        if ($params['readOnly']) {
            $disabled = ' disabled="disabled"';
        }
        // INIT
        $uidList = [];
        $opt = [];
        $itemArrayC = 0;
        // Creating <option> elements:
        if (is_array($itemArray)) {
            $itemArrayC = count($itemArray);
            switch ($mode) {
                case 'db':
                    foreach ($itemArray as $pp) {
                        $pRec = BackendUtility::getRecordWSOL($pp['table'], $pp['id']);
                        if (is_array($pRec)) {
                            $pTitle = BackendUtility::getRecordTitle($pp['table'], $pRec, false, true);
                            $pUid = $pp['table'] . '_' . $pp['id'];
                            $uidList[] = $pUid;
                            $title = htmlspecialchars($pTitle);
                            $opt[] = '<option value="' . htmlspecialchars($pUid) . '" title="' . $title . '">' . $title . '</option>';
                        }
                    }
                    break;
                case 'file_reference':
                case 'file':
                    foreach ($itemArray as $item) {
                        $itemParts = explode('|', $item);
                        $uidList[] = $pUid = $pTitle = $itemParts[0];
                        $title = htmlspecialchars(rawurldecode($itemParts[1]));
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($itemParts[0])) . '" title="' . $title . '">' . $title . '</option>';
                    }
                    break;
                case 'folder':
                    foreach ($itemArray as $pp) {
                        $pParts = explode('|', $pp);
                        $uidList[] = $pUid = $pTitle = $pParts[0];
                        $title = htmlspecialchars(rawurldecode($pParts[0]));
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($pParts[0])) . '" title="' . $title . '">' . $title . '</option>';
                    }
                    break;
                default:
                    foreach ($itemArray as $pp) {
                        $pParts = explode('|', $pp, 2);
                        $uidList[] = $pUid = $pParts[0];
                        $pTitle = $pParts[1];
                        $title = htmlspecialchars(rawurldecode($pTitle));
                        $opt[] = '<option value="' . htmlspecialchars(rawurldecode($pUid)) . '" title="' . $title . '">' . $title . '</option>';
                    }
            }
        }
        // Create selector box of the options
        $sSize = $params['autoSizeMax'] ? MathUtility::forceIntegerInRange($itemArrayC + 1, MathUtility::forceIntegerInRange($params['size'], 1), $params['autoSizeMax']) : $params['size'];
        if (!$selector) {
            $maxItems = (int) ($params['maxitems'] ?? 0);
            $size = (int) ($params['size'] ?? 0);
            $classes = ['form-control', 'tceforms-multiselect'];
            if ($maxItems === 1) {
                $classes[] = 'form-select-no-siblings';
            }
            $isMultiple = $maxItems !== 1 && $size !== 1;
            $selector = '<select id="' . StringUtility::getUniqueId('tceforms-multiselect-') . '" ' . ($params['noList'] ? 'style="display: none"' : 'size="' . $sSize . '" class="' . implode(' ', $classes) . '"') . ($isMultiple ? ' multiple="multiple"' : '') . ' data-formengine-input-name="' . htmlspecialchars($fName) . '" ' . $this->getValidationDataAsDataAttribute($config) . $params['style'] . $disabled . '>' . implode('', $opt) . '</select>';
        }
        $icons = ['L' => [], 'R' => []];
        $rOnClickInline = '';
        if (!$params['readOnly'] && !$params['noList']) {
            if (!$params['noBrowser']) {
                // Check against inline uniqueness
                /** @var InlineStackProcessor $inlineStackProcessor */
                $inlineStackProcessor = GeneralUtility::makeInstance(InlineStackProcessor::class);
                $inlineStackProcessor->initializeByGivenStructure($this->data['inlineStructure']);
                $aOnClickInline = '';
                if ($this->data['isInlineChild'] && $this->data['inlineParentUid']) {
                    if ($this->data['inlineParentConfig']['foreign_table'] === $table && $this->data['inlineParentConfig']['foreign_unique'] === $field) {
                        $objectPrefix = $inlineStackProcessor->getCurrentStructureDomObjectIdPrefix($this->data['inlineFirstPid']) . '-' . $table;
                        $aOnClickInline = $objectPrefix . '|inline.checkUniqueElement|inline.setUniqueElement';
                        $rOnClickInline = 'inline.revertUnique(' . GeneralUtility::quoteJSvalue($objectPrefix) . ',null,' . GeneralUtility::quoteJSvalue($uid) . ');';
                    }
                }
                if (is_array($config['appearance']) && isset($config['appearance']['elementBrowserType'])) {
                    $elementBrowserType = $config['appearance']['elementBrowserType'];
                } else {
                    $elementBrowserType = $mode;
                }
                if (is_array($config['appearance']) && isset($config['appearance']['elementBrowserAllowed'])) {
                    $elementBrowserAllowed = $config['appearance']['elementBrowserAllowed'];
                } else {
                    $elementBrowserAllowed = $allowed;
                }
                $aOnClick = 'setFormValueOpenBrowser(' . GeneralUtility::quoteJSvalue($elementBrowserType) . ',' . GeneralUtility::quoteJSvalue($fName . '|||' . $elementBrowserAllowed . '|' . $aOnClickInline) . '); return false;';
                $icons['R'][] = '
					<a href="#"
						onclick="' . htmlspecialchars($aOnClick) . '"
						class="btn btn-default"
						title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.browse_' . ($mode == 'db' ? 'db' : 'file'))) . '">
						' . $this->iconFactory->getIcon('actions-insert-record', Icon::SIZE_SMALL)->render() . '
					</a>';
            }
            if (!$params['dontShowMoveIcons']) {
                if ($sSize >= 5) {
                    $icons['L'][] = '
						<a href="#"
							class="btn btn-default t3js-btn-moveoption-top"
							data-fieldname="' . $fName . '"
							title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.move_to_top')) . '">
							' . $this->iconFactory->getIcon('actions-move-to-top', Icon::SIZE_SMALL)->render() . '
						</a>';
                }
                $icons['L'][] = '
					<a href="#"
						class="btn btn-default t3js-btn-moveoption-up"
						data-fieldname="' . $fName . '"
						title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.move_up')) . '">
						' . $this->iconFactory->getIcon('actions-move-up', Icon::SIZE_SMALL)->render() . '
					</a>';
                $icons['L'][] = '
					<a href="#"
						class="btn btn-default t3js-btn-moveoption-down"
						data-fieldname="' . $fName . '"
						title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.move_down')) . '">
						' . $this->iconFactory->getIcon('actions-move-down', Icon::SIZE_SMALL)->render() . '
					</a>';
                if ($sSize >= 5) {
                    $icons['L'][] = '
						<a href="#"
							class="btn btn-default t3js-btn-moveoption-bottom"
							data-fieldname="' . $fName . '"
							title="' . htmlspecialchars($languageService->sL('LLL:EXT:lang/Resources/Private/Language/locallang_core.xlf:labels.move_to_bottom')) . '">
							' . $this->iconFactory->getIcon('actions-move-to-bottom', Icon::SIZE_SMALL)->render() . '
						</a>';
                }
            }
            $clipElements = $this->getClipboardElements($allowed, $mode);
            if (!empty($clipElements)) {
                $aOnClick = '';
                foreach ($clipElements as $elValue) {
                    if ($mode == 'db') {
                        list($itemTable, $itemUid) = explode('|', $elValue);
                        $recordTitle = BackendUtility::getRecordTitle($itemTable, BackendUtility::getRecordWSOL($itemTable, $itemUid));
                        $itemTitle = GeneralUtility::quoteJSvalue($recordTitle);
                        $elValue = $itemTable . '_' . $itemUid;
                    } else {
                        // 'file', 'file_reference' and 'folder' mode
                        $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
        $allowedTables = '';
        if (is_array($params['allowedTables']) && !empty($params['allowedTables']) && !$params['hideAllowedTables']) {
            $allowedTables .= '<div class="help-block">';
            foreach ($params['allowedTables'] as $key => $item) {
                if (is_array($item)) {
                    if (empty($params['readOnly'])) {
                        $allowedTables .= '<a href="#" onClick="' . htmlspecialchars($item['onClick']) . '" class="btn btn-default">' . $item['icon'] . ' ' . htmlspecialchars($item['name']) . '</a> ';
                    } else {
                        $allowedTables .= '<span>' . htmlspecialchars($item['name']) . '</span> ';
                    }
                } elseif ($key === 'name') {
                    $allowedTables .= '<span>' . htmlspecialchars($item) . '</span> ';
                }
            }
            $allowedTables .= '</div>';
        }
        // Allowed
        $allowedList = '';
        if (is_array($params['allowed']) && !empty($params['allowed'])) {
            foreach ($params['allowed'] as $item) {
                $allowedList .= '<span class="label label-success">' . strtoupper($item) . '</span> ';
            }
        }
        // Disallowed
        $disallowedList = '';
        if (is_array($params['disallowed']) && !empty($params['disallowed'])) {
            foreach ($params['disallowed'] as $item) {
                $disallowedList .= '<span class="label label-danger">' . strtoupper($item) . '</span> ';
            }
        }
        // Rightbox
        $rightbox = $params['rightbox'] ?: '';
        // Hook: dbFileIcons_postProcess (requested by FAL-team for use with the "fal" extension)
        if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['dbFileIcons'])) {
            foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_tceforms.php']['dbFileIcons'] as $classRef) {
                $hookObject = GeneralUtility::getUserObj($classRef);
                if (!$hookObject instanceof DatabaseFileIconsHookInterface) {
                    throw new \UnexpectedValueException($classRef . ' must implement interface ' . DatabaseFileIconsHookInterface::class, 1290167704);
                }
                $additionalParams = ['mode' => $mode, 'allowed' => $allowed, 'itemArray' => $itemArray, 'table' => $table, 'field' => $field, 'uid' => $uid, 'config' => $GLOBALS['TCA'][$table]['columns'][$field]];
                $hookObject->dbFileIcons_postProcess($params, $selector, $thumbnails, $icons, $rightbox, $fName, $uidList, $additionalParams, $this);
            }
        }
        // Output
        $str = '
			' . ($params['headers']['selector'] ? '<label>' . $params['headers']['selector'] . '</label>' : '') . '
			<div class="form-wizards-wrap form-wizards-aside">
				<div class="form-wizards-element">
					' . $selector . '
					' . (!$params['noList'] && !empty($allowedTables) ? $allowedTables : '') . '
					' . (!$params['noList'] && (!empty($allowedList) || !empty($disallowedList)) ? '<div class="help-block">' . $allowedList . $disallowedList . ' </div>' : '') . '
				</div>
				' . (!empty($icons['L']) ? '<div class="form-wizards-items"><div class="btn-group-vertical">' . implode('', $icons['L']) . '</div></div>' : '') . '
				' . (!empty($icons['R']) ? '<div class="form-wizards-items"><div class="btn-group-vertical">' . implode('', $icons['R']) . '</div></div>' : '') . '
			</div>
			';
        if ($rightbox) {
            $str = '
				<div class="form-multigroup-wrap t3js-formengine-field-group">
					<div class="form-multigroup-item form-multigroup-element">' . $str . '</div>
					<div class="form-multigroup-item form-multigroup-element">
						' . ($params['headers']['items'] ? '<label>' . $params['headers']['items'] . '</label>' : '') . '
						' . ($params['headers']['selectorbox'] ? '<div class="form-multigroup-item-wizard">' . $params['headers']['selectorbox'] . '</div>' : '') . '
						' . $rightbox . '
					</div>
				</div>
				';
        }
        $str .= $thumbnails;
        // Creating the hidden field which contains the actual value as a comma list.
        $str .= '<input type="hidden" name="' . $fName . '" value="' . htmlspecialchars(implode(',', $uidList)) . '" />';
        return $str;
    }
 /**
  * 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;
 }
Esempio n. 4
0
 /**
  * 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;
 }
Esempio n. 5
0
 /**
  * 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);
 }
Esempio n. 6
0
 /**
  * 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;
         }
     }
 }
Esempio n. 7
0
 /**
  * @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));
 }
Esempio n. 8
0
 /**
  * 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;
     }
 }