[FEATURE] Intgrate CSS class "lead" for introductions
[Packages/TYPO3.CMS.git] / typo3 / sysext / lowlevel / Classes / View / DatabaseIntegrityView.php
1 <?php
2 namespace TYPO3\CMS\Lowlevel\View;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 1999-2013 Kasper Skårhøj (kasperYYYY@typo3.com)
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Core\Utility\GeneralUtility;
31 use TYPO3\CMS\Backend\Utility\BackendUtility;
32
33 /**
34 * Script class for the DB int module
35 *
36 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
37 */
38 class DatabaseIntegrityView {
39
40 /**
41 * @todo Define visibility
42 */
43 public $MCONF = array();
44
45 /**
46 * @todo Define visibility
47 */
48 public $MOD_MENU = array();
49
50 /**
51 * @todo Define visibility
52 */
53 public $MOD_SETTINGS = array();
54
55 /**
56 * Document template object
57 *
58 * @var \TYPO3\CMS\Backend\Template\DocumentTemplate
59 * @todo Define visibility
60 */
61 public $doc;
62
63 /**
64 * @todo Define visibility
65 */
66 public $content;
67
68 /**
69 * @todo Define visibility
70 */
71 public $menu;
72
73 protected $formName = 'queryform';
74
75 /**
76 * Constructor
77 */
78 public function __construct() {
79 $GLOBALS['LANG']->includeLLFile('EXT:lowlevel/dbint/locallang.xlf');
80 $GLOBALS['BE_USER']->modAccess($GLOBALS['MCONF'], 1);
81 }
82
83 /**
84 * Initialization
85 *
86 * @return void
87 * @todo Define visibility
88 */
89 public function init() {
90 global $LANG, $BACK_PATH;
91 $this->MCONF = $GLOBALS['MCONF'];
92 $this->menuConfig();
93 $this->doc = GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\Template\\DocumentTemplate');
94 $this->doc->backPath = $BACK_PATH;
95 $this->doc->setModuleTemplate('EXT:lowlevel/Resources/Private/Templates/dbint.html');
96 $this->doc->form = '<form action="" method="post" name="' . $this->formName . '">';
97 // JavaScript
98 $this->doc->JScode = '
99 <script language="javascript" type="text/javascript">
100 script_ended = 0;
101 function jumpToUrl(URL) {
102 window.location.href = URL;
103 }
104 </script>
105 ';
106 $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:400px!important;">
107 <colgroup><col width="24"><col width="300"><col width="76"></colgroup>';
108 $this->doc->tableLayout = array(
109 '0' => array(
110 'defCol' => array('<td class="t3-row-header"><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top" class="t3-row-header"><strong>', '</strong></td>')
111 ),
112 'defRow' => array(
113 '0' => array('<td valign="top">', '</td>'),
114 '1' => array('<td valign="top">', '</td>'),
115 'defCol' => array('<td><img src="' . $this->doc->backPath . 'clear.gif" width="15" height="1" alt="" /></td><td valign="top">', '</td>')
116 )
117 );
118 }
119
120 /**
121 * Configure menu
122 *
123 * @return void
124 * @todo Define visibility
125 */
126 public function menuConfig() {
127 global $LANG;
128 // MENU-ITEMS:
129 // If array, then it's a selector box menu
130 // If empty string it's just a variable, that'll be saved.
131 // Values NOT in this array will not be saved in the settings-array for the module.
132 $this->MOD_MENU = array(
133 'function' => array(
134 0 => $GLOBALS['LANG']->getLL('menu', TRUE),
135 'records' => $GLOBALS['LANG']->getLL('recordStatistics', TRUE),
136 'relations' => $GLOBALS['LANG']->getLL('databaseRelations', TRUE),
137 'search' => $GLOBALS['LANG']->getLL('fullSearch', TRUE),
138 'filesearch' => $GLOBALS['LANG']->getLL('findFilename', TRUE),
139 'refindex' => $GLOBALS['LANG']->getLL('manageRefIndex', TRUE)
140 ),
141 'search' => array(
142 'raw' => $GLOBALS['LANG']->getLL('rawSearch', TRUE),
143 'query' => $GLOBALS['LANG']->getLL('advancedQuery', TRUE)
144 ),
145 'search_query_smallparts' => '',
146 'search_result_labels' => '',
147 'labels_noprefix' => '',
148 'options_sortlabel' => '',
149 'show_deleted' => '',
150 'queryConfig' => '',
151 // Current query
152 'queryTable' => '',
153 // Current table
154 'queryFields' => '',
155 // Current tableFields
156 'queryLimit' => '',
157 // Current limit
158 'queryOrder' => '',
159 // Current Order field
160 'queryOrderDesc' => '',
161 // Current Order field descending flag
162 'queryOrder2' => '',
163 // Current Order2 field
164 'queryOrder2Desc' => '',
165 // Current Order2 field descending flag
166 'queryGroup' => '',
167 // Current Group field
168 'storeArray' => '',
169 // Used to store the available Query config memory banks
170 'storeQueryConfigs' => '',
171 // Used to store the available Query configs in memory
172 'search_query_makeQuery' => array(
173 'all' => $GLOBALS['LANG']->getLL('selectRecords', TRUE),
174 'count' => $GLOBALS['LANG']->getLL('countResults', TRUE),
175 'explain' => $GLOBALS['LANG']->getLL('explainQuery', TRUE),
176 'csv' => $GLOBALS['LANG']->getLL('csvExport', TRUE)
177 ),
178 'sword' => ''
179 );
180 // CLEAN SETTINGS
181 $OLD_MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, '', $this->MCONF['name'], 'ses');
182 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, GeneralUtility::_GP('SET'), $this->MCONF['name'], 'ses');
183 if (GeneralUtility::_GP('queryConfig')) {
184 $qA = GeneralUtility::_GP('queryConfig');
185 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, array('queryConfig' => serialize($qA)), $this->MCONF['name'], 'ses');
186 }
187 $addConditionCheck = GeneralUtility::_GP('qG_ins');
188 foreach ($OLD_MOD_SETTINGS as $key => $val) {
189 if (substr($key, 0, 5) == 'query' && $this->MOD_SETTINGS[$key] != $val && $key != 'queryLimit' && $key != 'use_listview') {
190 $setLimitToStart = 1;
191 if ($key == 'queryTable' && !$addConditionCheck) {
192 $this->MOD_SETTINGS['queryConfig'] = '';
193 }
194 }
195 if ($key == 'queryTable' && $this->MOD_SETTINGS[$key] != $val) {
196 $this->MOD_SETTINGS['queryFields'] = '';
197 }
198 }
199 if ($setLimitToStart) {
200 $currentLimit = explode(',', $this->MOD_SETTINGS['queryLimit']);
201 if ($currentLimit[1]) {
202 $this->MOD_SETTINGS['queryLimit'] = '0,' . $currentLimit[1];
203 } else {
204 $this->MOD_SETTINGS['queryLimit'] = '0';
205 }
206 $this->MOD_SETTINGS = BackendUtility::getModuleData($this->MOD_MENU, $this->MOD_SETTINGS, $this->MCONF['name'], 'ses');
207 }
208 }
209
210 /**
211 * Main
212 *
213 * @return void
214 * @todo Define visibility
215 */
216 public function main() {
217 // Content creation
218 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
219 $this->menu = BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
220 }
221 switch ($this->MOD_SETTINGS['function']) {
222 case 'search':
223 $this->func_search();
224 break;
225 case 'records':
226 $this->func_records();
227 break;
228 case 'relations':
229 $this->func_relations();
230 break;
231 case 'filesearch':
232 $this->func_filesearch();
233 break;
234 case 'refindex':
235 $this->func_refindex();
236 break;
237 default:
238 $this->func_default();
239 }
240 // Setting up the buttons and markers for docheader
241 $docHeaderButtons = $this->getButtons();
242 $markers = array(
243 'CSH' => $docHeaderButtons['csh'],
244 'FUNC_MENU' => $this->getFuncMenu(),
245 'CONTENT' => $this->content
246 );
247 // Build the <body> for the module
248 $this->content = $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
249 // Renders the module page
250 $this->content = $this->doc->render($GLOBALS['LANG']->getLL('title'), $this->content);
251 }
252
253 /**
254 * Print content
255 *
256 * @return void
257 * @todo Define visibility
258 */
259 public function printContent() {
260 echo $this->content;
261 }
262
263 /**
264 * Create the panel of buttons for submitting the form or otherwise perform operations.
265 *
266 * @return array All available buttons as an assoc. array
267 */
268 protected function getButtons() {
269 $buttons = array(
270 'csh' => '',
271 'shortcut' => ''
272 );
273 // Shortcut
274 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
275 $buttons['shortcut'] = $this->doc->makeShortcutIcon('', 'function,search,search_query_makeQuery', $this->MCONF['name']);
276 }
277 return $buttons;
278 }
279
280 /**
281 * Create the function menu
282 *
283 * @return string HTML of the function menu
284 */
285 protected function getFuncMenu() {
286 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
287 $funcMenu = BackendUtility::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
288 }
289 return $funcMenu;
290 }
291
292 /**
293 * Creates the overview menu.
294 *
295 * @return void
296 */
297 protected function func_default() {
298 $availableModFuncs = array('records', 'relations', 'search', 'filesearch', 'refindex');
299 $content = '<dl class="t3-overview-list">';
300 foreach ($availableModFuncs as $modFunc) {
301 $functionUrl = BackendUtility::getModuleUrl('system_dbint') . '&SET[function]=' . $modFunc;
302 $title = $GLOBALS['LANG']->getLL($modFunc);
303 $description = $GLOBALS['LANG']->getLL($modFunc . '_description');
304 $icon = '<img src="' . \TYPO3\CMS\Backend\Utility\IconUtility::skinImg($GLOBALS['BACK_PATH'], 'MOD:system_dbint/db.gif', '', 1) . '" width="16" height="16" title="' . $title . '" alt="' . $title . '" />';
305 $content .= '
306 <dt><a href="' . htmlspecialchars($functionUrl) . '">' . $icon . $title . '</a></dt>
307 <dd>' . $description . '</dd>
308 ';
309 }
310 $content .= '</dl>';
311 $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('title'));
312 $this->content .= $this->doc->section('', $content, FALSE, TRUE);
313 }
314
315 /****************************
316 *
317 * Functionality implementation
318 *
319 ****************************/
320 /**
321 * Check and update reference index!
322 *
323 * @return void
324 * @todo Define visibility
325 */
326 public function func_refindex() {
327 $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('manageRefIndex', TRUE));
328 if (GeneralUtility::_GP('_update') || GeneralUtility::_GP('_check')) {
329 $testOnly = GeneralUtility::_GP('_check') ? TRUE : FALSE;
330 // Call the functionality
331 $refIndexObj = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\ReferenceIndex');
332 list($headerContent, $bodyContent) = $refIndexObj->updateIndex($testOnly);
333 // Output content:
334 $this->content .= $this->doc->section('', str_replace(LF, '<br/>', $bodyContent), FALSE, TRUE);
335 }
336
337 // Output content:
338 $content = '<p class="lead">' . $GLOBALS['LANG']->getLL('referenceIndex_description') . '</p>';
339 $content .= '<input type="submit" name="_check" value="' . $GLOBALS['LANG']->getLL('referenceIndex_buttonCheck') . '" /> <input type="submit" name="_update" value="' . $GLOBALS['LANG']->getLL('referenceIndex_buttonUpdate') . '" /><br /><br />';
340 $this->content .= $this->doc->section('', $content, FALSE, TRUE);
341
342 // Command Line Interface
343 $content = '';
344 $content .= '<p>' . $GLOBALS['LANG']->getLL('checkScript') . '</p>';
345
346 $content .= '<h3>' . $GLOBALS['LANG']->getLL('checkScript_check_description') . '</h3>';
347 $content .= '<p><code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -c</code></p>';
348
349 $content .= '<h3>' . $GLOBALS['LANG']->getLL('checkScript_update_description') . '</h3>';
350 $content .= '<p><code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -e</code></p>';
351 $content .= '<div class="typo3-message message-information"><div class="message-body">' . $GLOBALS['LANG']->getLL('checkScript_information') . '</div></div>';
352
353 $content .= '<p>' . $GLOBALS['LANG']->getLL('checkScript_moreDetails') . '<br />';
354 $content .= '<a href="' . $GLOBALS['BACK_PATH'] . 'sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt" target="_new">' . PATH_typo3 . 'sysext/lowlevel/HOWTO_clean_up_TYPO3_installations.txt</a></p>';
355 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('checkScript_headline'), $content, FALSE, TRUE);
356 }
357
358 /**
359 * Search (Full / Advanced)
360 *
361 * @return void
362 * @todo Define visibility
363 */
364 public function func_search() {
365 global $LANG;
366 $fullsearch = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Database\\QueryView');
367 $fullsearch->setFormName($this->formName);
368 $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('search'));
369 $this->content .= $this->doc->spacer(5);
370 $menu2 = '';
371 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
372 $menu2 = BackendUtility::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
373 }
374 if ($this->MOD_SETTINGS['search'] == 'query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
375 $menu2 .= BackendUtility::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
376 }
377 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search'] == 'query') {
378 $menu2 .= BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_query_smallparts]', $this->MOD_SETTINGS['search_query_smallparts'], '', '', 'id="checkSearch_query_smallparts"') . '&nbsp;<label for="checkSearch_query_smallparts">' . $GLOBALS['LANG']->getLL('showSQL') . '</label><br />';
379 $menu2 .= BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[search_result_labels]', $this->MOD_SETTINGS['search_result_labels'], '', '', 'id="checkSearch_result_labels"') . '&nbsp;<label for="checkSearch_result_labels">' . $GLOBALS['LANG']->getLL('useFormattedStrings') . '</label><br />';
380 $menu2 .= BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[labels_noprefix]', $this->MOD_SETTINGS['labels_noprefix'], '', '', 'id="checkLabels_noprefix"') . '&nbsp;<label for="checkLabels_noprefix">' . $GLOBALS['LANG']->getLL('dontUseOrigValues') . '</label><br />';
381 $menu2 .= BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[options_sortlabel]', $this->MOD_SETTINGS['options_sortlabel'], '', '', 'id="checkOptions_sortlabel"') . '&nbsp;<label for="checkOptions_sortlabel">' . $GLOBALS['LANG']->getLL('sortOptions') . '</label><br />';
382 $menu2 .= BackendUtility::getFuncCheck($GLOBALS['SOBE']->id, 'SET[show_deleted]', $this->MOD_SETTINGS['show_deleted'], '', '', 'id="checkShow_deleted"') . '&nbsp;<label for="checkShow_deleted">' . $GLOBALS['LANG']->getLL('showDeleted') . '</label>';
383 }
384 $this->content .= $this->doc->section('', $menu2) . $this->doc->spacer(10);
385 switch ($this->MOD_SETTINGS['search']) {
386 case 'query':
387 $this->content .= $fullsearch->queryMaker();
388 break;
389 case 'raw':
390
391 default:
392 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('searchOptions'), $fullsearch->form(), FALSE, TRUE);
393 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('result'), $fullsearch->search(), FALSE, TRUE);
394 }
395 }
396
397 /**
398 * Records overview
399 *
400 * @return void
401 * @todo Define visibility
402 */
403 public function func_records() {
404 /** @var $admin \TYPO3\CMS\Core\Integrity\DatabaseIntegrityCheck */
405 $admin = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Integrity\\DatabaseIntegrityCheck');
406 $admin->genTree_makeHTML = 0;
407 $admin->backPath = $GLOBALS['BACK_PATH'];
408 $admin->genTree(0, '');
409 $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('records'));
410 // Pages stat
411 $codeArr = array();
412 $codeArr['tableheader'] = array('', $GLOBALS['LANG']->getLL('count'));
413 $i++;
414 $codeArr[$i][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array());
415 $codeArr[$i][] = $GLOBALS['LANG']->getLL('total_pages');
416 $codeArr[$i][] = count($admin->page_idArray);
417 $i++;
418 if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('cms')) {
419 $codeArr[$i][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array('hidden' => 1));
420 $codeArr[$i][] = $GLOBALS['LANG']->getLL('hidden_pages');
421 $codeArr[$i][] = $admin->recStats['hidden'];
422 $i++;
423 }
424 $codeArr[$i][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array('deleted' => 1));
425 $codeArr[$i][] = $GLOBALS['LANG']->getLL('deleted_pages');
426 $codeArr[$i][] = count($admin->recStats['deleted']['pages']);
427 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('pages'), $this->doc->table($codeArr), FALSE, TRUE);
428 // Doktype
429 $codeArr = array();
430 $codeArr['tableheader'] = array($GLOBALS['LANG']->getLL('doktype_value'), $GLOBALS['LANG']->getLL('count'));
431 $doktype = $GLOBALS['TCA']['pages']['columns']['doktype']['config']['items'];
432 if (is_array($doktype)) {
433 foreach ($doktype as $n => $setup) {
434 if ($setup[1] != '--div--') {
435 $codeArr[$n][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord('pages', array('doktype' => $setup[1]));
436 $codeArr[$n][] = $GLOBALS['LANG']->sL($setup[0]) . ' (' . $setup[1] . ')';
437 $codeArr[$n][] = intval($admin->recStats['doktype'][$setup[1]]);
438 }
439 }
440 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), FALSE, TRUE);
441 }
442 // Tables and lost records
443 $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
444 $id_list = rtrim($id_list, ',');
445 $admin->lostRecords($id_list);
446 if ($admin->fixLostRecord(GeneralUtility::_GET('fixLostRecords_table'), GeneralUtility::_GET('fixLostRecords_uid'))) {
447 $admin = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Integrity\\DatabaseIntegrityCheck');
448 $admin->backPath = $BACK_PATH;
449 $admin->genTree(0, '');
450 $id_list = '-1,0,' . implode(',', array_keys($admin->page_idArray));
451 $id_list = rtrim($id_list, ',');
452 $admin->lostRecords($id_list);
453 }
454 $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:700px!important;">';
455 $codeArr = array();
456 $codeArr['tableheader'] = array(
457 $GLOBALS['LANG']->getLL('label'),
458 $GLOBALS['LANG']->getLL('tablename'),
459 $GLOBALS['LANG']->getLL('total_lost'),
460 ''
461 );
462 $countArr = $admin->countRecords($id_list);
463 if (is_array($GLOBALS['TCA'])) {
464 foreach ($GLOBALS['TCA'] as $t => $value) {
465 if ($GLOBALS['TCA'][$t]['ctrl']['hideTable']) {
466 continue;
467 }
468 $codeArr[$t][] = \TYPO3\CMS\Backend\Utility\IconUtility::getSpriteIconForRecord($t, array());
469 $codeArr[$t][] = $GLOBALS['LANG']->sL($GLOBALS['TCA'][$t]['ctrl']['title']);
470 $codeArr[$t][] = $t;
471 if ($t === 'pages' && $admin->lostPagesList !== '') {
472 $lostRecordCount = count(explode(',', $admin->lostPagesList));
473 } else {
474 $lostRecordCount = count($admin->lRecords[$t]);
475 }
476 if ($countArr['all'][$t]) {
477 $theNumberOfRe = intval($countArr['non_deleted'][$t]) . '/' . $lostRecordCount;
478 } else {
479 $theNumberOfRe = '';
480 }
481 $codeArr[$t][] = $theNumberOfRe;
482 $lr = '';
483 if (is_array($admin->lRecords[$t])) {
484 foreach ($admin->lRecords[$t] as $data) {
485 if (!GeneralUtility::inList($admin->lostPagesList, $data[pid])) {
486 $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>';
487 } else {
488 $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>';
489 }
490 }
491 }
492 $codeArr[$t][] = $lr;
493 }
494 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('tables'), $this->doc->table($codeArr), FALSE, TRUE);
495 }
496 }
497
498 /**
499 * Show list references
500 *
501 * @return void
502 * @todo Define visibility
503 */
504 public function func_relations() {
505 global $LANG, $BACK_PATH;
506 $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('relations'));
507 $admin = GeneralUtility::makeInstance('TYPO3\\CMS\\Core\\Integrity\\DatabaseIntegrityCheck');
508 $admin->genTree_makeHTML = 0;
509 $admin->backPath = $BACK_PATH;
510 $fkey_arrays = $admin->getGroupFields('');
511 $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
512 $fileTest = $admin->testFileRefs();
513 $code = '';
514 if (is_array($fileTest['noReferences'])) {
515 foreach ($fileTest['noReferences'] as $val) {
516 $code .= '<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong></nobr><br>';
517 }
518 } else {
519 $code = $GLOBALS['LANG']->getLL('no_files_found');
520 }
521 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('files_no_ref'), $code, FALSE, TRUE);
522 $code = '';
523 if (is_array($fileTest['moreReferences'])) {
524 foreach ($fileTest['moreReferences'] as $val) {
525 $code .= '<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong>: ' . $val[2] . ' ' . $GLOBALS['LANG']->getLL('references') . '</nobr><br>' . $val[3] . '<br><br>';
526 }
527 } else {
528 $code = $GLOBALS['LANG']->getLL('no_files_found');
529 }
530 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('files_many_ref'), $code, FALSE, TRUE);
531 $code = '';
532 if (is_array($fileTest['noFile'])) {
533 ksort($fileTest['noFile']);
534 foreach ($fileTest['noFile'] as $val) {
535 $code .= '<nobr>' . $val[0] . '/<strong>' . $val[1] . '</strong> ' . $GLOBALS['LANG']->getLL('isMissing') . ' </nobr><br>' . $GLOBALS['LANG']->getLL('referencedFrom') . $val[2] . '<br><br>';
536 }
537 } else {
538 $code = $GLOBALS['LANG']->getLL('no_files_found');
539 }
540 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('files_no_file'), $code, FALSE, TRUE);
541 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('select_db'), $admin->testDBRefs($admin->checkSelectDBRefs), FALSE, TRUE);
542 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('group_db'), $admin->testDBRefs($admin->checkGroupDBRefs), FALSE, TRUE);
543 }
544
545 /**
546 * Searching for files with a specific pattern
547 *
548 * @return void
549 * @todo Define visibility
550 */
551 public function func_filesearch() {
552 $pattern = GeneralUtility::_GP('pattern');
553 $pcontent = $GLOBALS['LANG']->getLL('enterRegexPattern') . ' <input type="text" name="pattern" value="' . htmlspecialchars(($pattern ? $pattern : $GLOBALS['TYPO3_CONF_VARS']['BE']['fileDenyPattern'])) . '"> <input type="submit" name="' . $GLOBALS['LANG']->getLL('SearchButton') . '">';
554 $this->content .= $this->doc->header($GLOBALS['LANG']->getLL('findFilename'));
555 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('pattern'), $pcontent, FALSE, TRUE);
556 if (strcmp($pattern, '')) {
557 $dirs = GeneralUtility::get_dirs(PATH_site);
558 $lines = array();
559 $depth = 10;
560 foreach ($dirs as $key => $value) {
561 $matching_files = array();
562 $info = '';
563 if (!GeneralUtility::inList('typo3,typo3conf,tslib,media,t3lib', $value)) {
564 $info = $this->findFile(PATH_site . $value . '/', $pattern, $matching_files, $depth);
565 }
566 if (is_array($info)) {
567 $lines[] = '<hr><strong>' . $value . '/</strong> ' . $GLOBALS['LANG']->getLL('beingChecked');
568 $lines[] = $GLOBALS['LANG']->getLL('directories') . ' ' . $info[0];
569 if ($info[2]) {
570 $lines[] = '<span class="typo3-red">' . $GLOBALS['LANG']->getLL('directoriesTooDeep') . ' ' . $depth . '</span>';
571 }
572 $lines[] = $GLOBALS['LANG']->getLL('files') . ' ' . $info[1];
573 $lines[] = $GLOBALS['LANG']->getLL('matchingFiles') . '<br><nobr><span class="typo3-red">' . implode('<br>', $matching_files) . '</span></nobr>';
574 } else {
575 $lines[] = $GLOBALS['TBE_TEMPLATE']->dfw('<hr><strong>' . $value . '/</strong> ' . $GLOBALS['LANG']->getLL('notChecked'));
576 }
577 }
578 $this->content .= $this->doc->section($GLOBALS['LANG']->getLL('searchingForFilenames'), implode('<br>', $lines), FALSE, TRUE);
579 }
580 }
581
582 /**
583 * Searching for filename pattern recursively in the specified dir.
584 *
585 * @param string $basedir Base directory
586 * @param string $pattern Match pattern
587 * @param array $matching_files Array of matching files, passed by reference
588 * @param integer $depth Depth to recurse
589 * @return array Array with various information about the search result
590 * @see func_filesearch()
591 * @todo Define visibility
592 */
593 public function findFile($basedir, $pattern, &$matching_files, $depth) {
594 $files_searched = 0;
595 $dirs_searched = 0;
596 $dirs_error = 0;
597 // Traverse files:
598 $files = GeneralUtility::getFilesInDir($basedir, '', 1);
599 if (is_array($files)) {
600 $files_searched += count($files);
601 // Escape the regexp. Note: we cannot use preg_quote here because it will escape more than we need!
602 $regExpPattern = str_replace('/', '\\/', $pattern);
603 foreach ($files as $value) {
604 if (preg_match('/' . $regExpPattern . '/i', basename($value))) {
605 $matching_files[] = substr($value, strlen(PATH_site));
606 }
607 }
608 }
609 // Traverse subdirs
610 if ($depth > 0) {
611 $dirs = GeneralUtility::get_dirs($basedir);
612 if (is_array($dirs)) {
613 $dirs_searched += count($dirs);
614 foreach ($dirs as $value) {
615 $inf = $this->findFile($basedir . $value . '/', $pattern, $matching_files, $depth - 1);
616 $dirs_searched += $inf[0];
617 $files_searched += $inf[1];
618 $dirs_error = $inf[2];
619 }
620 }
621 } else {
622 $dirs = GeneralUtility::get_dirs($basedir);
623 if (is_array($dirs) && count($dirs)) {
624 // Means error - there were further subdirs!
625 $dirs_error = 1;
626 }
627 }
628 return array($dirs_searched, $files_searched, $dirs_error);
629 }
630
631 }
632
633
634 ?>