/**
     * renders the data for all tabs in the user setup and returns
     * everything that is needed with tabs and dyntab menu
     *
     * @return array Ready to use for the dyntabmenu itemarray
     */
    protected function renderUserSetup()
    {
        $result = array();
        $firstTabLabel = '';
        $code = array();
        $i = 0;
        $fieldArray = $this->getFieldsFromShowItem();
        $this->dividers2tabs = isset($GLOBALS['TYPO3_USER_SETTINGS']['ctrl']['dividers2tabs']) ? intval($GLOBALS['TYPO3_USER_SETTINGS']['ctrl']['dividers2tabs']) : 0;
        $tabLabel = '';
        foreach ($fieldArray as $fieldName) {
            $more = '';
            if (substr($fieldName, 0, 8) == '--div--;') {
                if ($firstTabLabel == '') {
                    // First tab
                    $tabLabel = $this->getLabel(substr($fieldName, 8), '', FALSE);
                    $firstTabLabel = $tabLabel;
                } else {
                    if ($this->dividers2tabs) {
                        $result[] = array('label' => $tabLabel, 'content' => count($code) ? $this->doc->spacer(20) . $this->doc->table($code) : '');
                        $tabLabel = $this->getLabel(substr($fieldName, 8), '', FALSE);
                        $i = 0;
                        $code = array();
                    }
                }
                continue;
            }
            $config = $GLOBALS['TYPO3_USER_SETTINGS']['columns'][$fieldName];
            // Field my be disabled in setup.fields
            if (isset($this->tsFieldConf[$fieldName . '.']['disabled']) && $this->tsFieldConf[$fieldName . '.']['disabled'] == 1) {
                continue;
            }
            if (isset($config['access']) && !$this->checkAccess($config)) {
                continue;
            }
            $label = $this->getLabel($config['label'], $fieldName);
            $label = $this->getCSH($config['csh'] ? $config['csh'] : $fieldName, $label);
            $type = $config['type'];
            $eval = $config['eval'];
            $class = $config['class'];
            $style = $config['style'];
            if ($class) {
                $more .= ' class="' . $class . '"';
            }
            if ($style) {
                $more .= ' style="' . $style . '"';
            }
            if ($this->overrideConf[$fieldName]) {
                $more .= ' disabled="disabled"';
            }
            $value = $config['table'] == 'be_users' ? $GLOBALS['BE_USER']->user[$fieldName] : $GLOBALS['BE_USER']->uc[$fieldName];
            if (!$value && isset($config['default'])) {
                $value = $config['default'];
            }
            switch ($type) {
                case 'text':
                case 'password':
                    $dataAdd = '';
                    if ($config['table'] == 'be_users') {
                        $dataAdd = '[be_users]';
                    }
                    if ($eval == 'md5') {
                        $more .= ' onchange="this.value=this.value?MD5(this.value):\'\';"';
                    }
                    if ($type == 'password') {
                        $value = '';
                    }
                    $noAutocomplete = $type == 'password' ? 'autocomplete="off" ' : '';
                    $html = '<input id="field_' . $fieldName . '"
							type="' . $type . '"
							name="data' . $dataAdd . '[' . $fieldName . ']" ' . $noAutocomplete . 'value="' . htmlspecialchars($value) . '" ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . $more . ' />';
                    break;
                case 'check':
                    if (!$class) {
                        $more .= ' class="check"';
                    }
                    $html = '<input id="field_' . $fieldName . '"
									type="checkbox"
									name="data[' . $fieldName . ']"' . ($value ? ' checked="checked"' : '') . $more . ' />';
                    break;
                case 'select':
                    if (!$class) {
                        $more .= ' class="select"';
                    }
                    if ($config['itemsProcFunc']) {
                        $html = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($config['itemsProcFunc'], $config, $this, '');
                    } else {
                        $html = '<select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' id="field_' . $fieldName . '" name="data[' . $fieldName . ']"' . $more . '>' . LF;
                        foreach ($config['items'] as $key => $optionLabel) {
                            $html .= '<option value="' . $key . '"' . ($value == $key ? ' selected="selected"' : '') . '>' . $this->getLabel($optionLabel, '', FALSE) . '</option>' . LF;
                        }
                        $html .= '</select>';
                    }
                    break;
                case 'user':
                    $html = \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($config['userFunc'], $config, $this, '');
                    break;
                case 'button':
                    if ($config['onClick']) {
                        $onClick = $config['onClick'];
                        if ($config['onClickLabels']) {
                            foreach ($config['onClickLabels'] as $key => $labelclick) {
                                $config['onClickLabels'][$key] = $this->getLabel($labelclick, '', FALSE);
                            }
                            $onClick = vsprintf($onClick, $config['onClickLabels']);
                        }
                        $html = '<input ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' type="button" value="' . $this->getLabel($config['buttonlabel'], '', FALSE) . '" onclick="' . $onClick . '" />';
                    }
                    break;
                default:
                    $html = '';
            }
            $code[$i][1] = $label;
            $code[$i++][2] = $html;
        }
        if ($this->dividers2tabs == 0) {
            $tabLabel = $firstTabLabel;
        }
        $result[] = array('label' => $tabLabel, 'content' => count($code) ? $this->doc->spacer(20) . $this->doc->table($code) : '');
        return $result;
    }
 /**
  * Records overview
  *
  * @return void
  * @todo Define visibility
  */
 public function func_records()
 {
     /** @var $admin \TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck */
     $admin = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Integrity\\DatabaseIntegrityCheck');
     $admin->genTree_makeHTML = 0;
     $admin->backPath = $GLOBALS['BACK_PATH'];
     $admin->genTree(0, '');
     $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('records'));
     // Pages stat
     $codeArr = array();
     $codeArr['tableheader'] = array('', $GLOBALS['LANG']->getLL('count'));
     $i++;
     $codeArr[$i][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array());
     $codeArr[$i][] = $GLOBALS['LANG']->getLL('total_pages');
     $codeArr[$i][] = count($admin->page_idArray);
     $i++;
     if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
         $codeArr[$i][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array('hidden' => 1));
         $codeArr[$i][] = $GLOBALS['LANG']->getLL('hidden_pages');
         $codeArr[$i][] = $admin->recStats['hidden'];
         $i++;
     }
     $codeArr[$i][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array('deleted' => 1));
     $codeArr[$i][] = $GLOBALS['LANG']->getLL('deleted_pages');
     $codeArr[$i][] = count($admin->recStats['deleted']['pages']);
     $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('pages'), $this->doc->table($codeArr), FALSE, TRUE);
     // Doktype
     $codeArr = array();
     $codeArr['tableheader'] = array($GLOBALS['LANG']->getLL('doktype_value'), $GLOBALS['LANG']->getLL('count'));
     $doktype = $GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'];
     if (is_array($doktype)) {
         foreach ($doktype as $n => $setup) {
             if ($setup[1] != '--div--') {
                 $codeArr[$n][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array('doktype' => $setup[1]));
                 $codeArr[$n][] = $GLOBALS['LANG']->sL($setup[0]) . ' (' . $setup[1] . ')';
                 $codeArr[$n][] = intval($admin->recStats['doktype'][$setup[1]]);
             }
         }
         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), FALSE, TRUE);
     }
     // Tables and lost records
     $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
     $id_list = rtrim($id_list, ',');
     $admin->lostRecords($id_list);
     if ($admin->fixLostRecord(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('fixLostRecords_table'), \TYPO3\CMS\Core\Utility\GeneralUtility::_GET('fixLostRecords_uid'))) {
         $admin = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Integrity\\DatabaseIntegrityCheck');
         $admin->backPath = $BACK_PATH;
         $admin->genTree(0, '');
         $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
         $id_list = rtrim($id_list, ',');
         $admin->lostRecords($id_list);
     }
     $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:700px!important;">';
     $codeArr = array();
     $codeArr['tableheader'] = array($GLOBALS['LANG']->getLL('label'), $GLOBALS['LANG']->getLL('tablename'), $GLOBALS['LANG']->getLL('total_lost'), '');
     $countArr = $admin->countRecords($id_list);
     if (is_array($GLOBALS['TCA'])) {
         foreach ($GLOBALS['TCA'] as $t => $value) {
             if ($GLOBALS['TCA'][$t]['ctrl']['hideTable']) {
                 continue;
             }
             $codeArr[$t][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($t, array());
             $codeArr[$t][] = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$t]['ctrl']['title']);
             $codeArr[$t][] = $t;
             if ($t === 'pages' && $admin->lostPagesList !== '') {
                 $lostRecordCount = count(explode(',', $admin->lostPagesList));
             } else {
                 $lostRecordCount = count($admin->lRecords[$t]);
             }
             if ($countArr['all'][$t]) {
                 $theNumberOfRe = intval($countArr['non_deleted'][$t]) . '/' . $lostRecordCount;
             } else {
                 $theNumberOfRe = '';
             }
             $codeArr[$t][] = $theNumberOfRe;
             $lr = '';
             if (is_array($admin->lRecords[$t])) {
                 foreach ($admin->lRecords[$t] as $data) {
                     if (!\TYPO3\CMS\Core\Utility\GeneralUtility::inList($admin->lostPagesList, $data[pid])) {
                         $lr .= '<nobr><strong><a href="' . htmlspecialchars(\TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('tools_dbint') . '&SET[function]=records&fixLostRecords_table=' . $t . '&fixLostRecords_uid=' . $data['uid']) . '"><img src="' . $BACK_PATH . 'gfx/required_h.gif" width="10" hspace="3" height="10" border="0" align="top" title="' . $GLOBALS['LANG']->getLL('fixLostRecord') . '"></a>uid:' . $data['uid'] . ', pid:' . $data['pid'] . ', ' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(strip_tags($data['title']), 20)) . '</strong></nobr><br>';
                     } else {
                         $lr .= '<nobr><img src="' . $BACK_PATH . 'clear.gif" width="16" height="1" border="0"><font color="Gray">uid:' . $data['uid'] . ', pid:' . $data['pid'] . ', ' . htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::fixed_lgd_cs(strip_tags($data['title']), 20)) . '</font></nobr><br>';
                     }
                 }
             }
             $codeArr[$t][] = $lr;
         }
         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('tables'), $this->doc->table($codeArr), FALSE, TRUE);
     }
 }