/**
  * Main function to generate the content
  *
  * @return 	void
  * @todo Define visibility
  */
 public function main()
 {
     $this->content = $this->doc->header('Indexing Engine Statistics');
     $this->content .= $this->doc->spacer(5);
     switch ($this->MOD_SETTINGS['function']) {
         case 'stat':
             $this->content .= $this->doc->section('Records', $this->doc->table($this->getRecordsNumbers()), 0, 1);
             $this->content .= $this->doc->spacer(15);
             $this->content .= $this->doc->section('index_phash TYPES', $this->doc->table($this->getPhashTypes()), 1);
             $this->content .= $this->doc->spacer(15);
             break;
         case 'externalDocs':
             $this->content .= $this->doc->section('External documents', $this->doc->table($this->getPhashExternalDocs()), 0, 1);
             $this->content .= $this->doc->spacer(15);
             break;
         case 'typo3pages':
             $this->content .= $this->doc->section('TYPO3 Pages', $this->doc->table($this->getPhashT3pages()), 0, 1);
             $this->content .= $this->doc->spacer(15);
             break;
     }
     $docHeaderButtons = $this->getButtons();
     $markers = array('CSH' => $docHeaderButtons['csh'], 'FUNC_MENU' => BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']), 'CONTENT' => $this->content);
     $this->content = $this->doc->startPage('Indexing Engine Statistics');
     $this->content .= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
     $this->content .= $this->doc->endPage();
     $this->content = $this->doc->insertStylesAndJS($this->content);
 }
    /**
     * 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']) ? (int) $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->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'] ?: $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 (isset($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'];
            }
            $dataAdd = '';
            if ($config['table'] == 'be_users') {
                $dataAdd = '[be_users]';
            }
            switch ($type) {
                case 'text':
                case 'password':
                    $noAutocomplete = '';
                    if ($type === 'password') {
                        $value = '';
                        $noAutocomplete = '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' . $dataAdd . '[' . $fieldName . ']"' . ($value ? ' checked="checked"' : '') . $more . ' />';
                    break;
                case 'select':
                    if (!$class) {
                        $more .= ' class="select"';
                    }
                    if ($config['itemsProcFunc']) {
                        $html = GeneralUtility::callUserFunction($config['itemsProcFunc'], $config, $this, '');
                    } else {
                        $html = '<select ' . $GLOBALS['TBE_TEMPLATE']->formWidth(20) . ' id="field_' . $fieldName . '" name="data' . $dataAdd . '[' . $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 = GeneralUtility::callUserFunction($config['userFunc'], $config, $this, '');
                    break;
                case 'button':
                    $html = '';
                    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 = '';
            }
            if ($html) {
                $code[$i][1] = $label;
                $code[$i++][2] = $html;
            }
        }
        if ($this->dividers2tabs == 0) {
            $tabLabel = $firstTabLabel;
        }
        $result[] = array('label' => $tabLabel, 'content' => count($code) ? $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 = 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++;
     $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), TRUE, 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][] = (int) $admin->recStats['doktype'][$setup[1]];
             }
         }
         $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), TRUE, 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(GeneralUtility::_GET('fixLostRecords_table'), GeneralUtility::_GET('fixLostRecords_uid'))) {
         $admin = 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);
     }
     $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 = (int) $countArr['non_deleted'][$t] . '/' . $lostRecordCount;
             } else {
                 $theNumberOfRe = '';
             }
             $codeArr[$t][] = $theNumberOfRe;
             $lr = '';
             if (is_array($admin->lRecords[$t])) {
                 foreach ($admin->lRecords[$t] as $data) {
                     if (!GeneralUtility::inList($admin->lostPagesList, $data[pid])) {
                         $lr .= '<nobr><strong><a href="' . htmlspecialchars(BackendUtility::getModuleUrl('system_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(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(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);
     }
 }