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