Follow-up to bug #13670: Performance optimization: change while(list() to foreach()
[Packages/TYPO3.CMS.git] / typo3 / sysext / lowlevel / dbint / index.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 1999-2009 Kasper Skaarhoj (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 Skaarhoj <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 Skaarhoj <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="c-headLineTable"><img src="' . $this->doc->backPath . 'clear.gif" width="10" height="1" alt="" /></td><td valign="top" class="c-headLineTable"><b>', '</b></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 'tree' => $GLOBALS['LANG']->getLL('totalPageTree', true),
159 'relations' => $GLOBALS['LANG']->getLL('databaseRelations', true),
160 'search' => $GLOBALS['LANG']->getLL('fullSearch', true),
161 'filesearch' => $GLOBALS['LANG']->getLL('findFilename', true),
162 'refindex' => $GLOBALS['LANG']->getLL('manageRefIndex', true),
163 ),
164 'search' => array(
165 'raw' => $GLOBALS['LANG']->getLL('rawSearch', true),
166 'query' => $GLOBALS['LANG']->getLL('advancedQuery', true)
167 ),
168
169 'search_query_smallparts' => '',
170 'search_result_labels' => '',
171 'labels_noprefix' => '',
172 'options_sortlabel' => '',
173 'show_deleted' => '',
174
175 'queryConfig' => '', // Current query
176 'queryTable' => '', // Current table
177 'queryFields' => '', // Current tableFields
178 'queryLimit' => '', // Current limit
179 'queryOrder' => '', // Current Order field
180 'queryOrderDesc' => '', // Current Order field descending flag
181 'queryOrder2' => '', // Current Order2 field
182 'queryOrder2Desc' => '', // Current Order2 field descending flag
183 'queryGroup' => '', // Current Group field
184
185 'storeArray' => '', // Used to store the available Query config memory banks
186 'storeQueryConfigs' => '', // Used to store the available Query configs in memory
187
188 'search_query_makeQuery' => array(
189 'all' => $GLOBALS['LANG']->getLL('selectRecords', true),
190 'count' => $GLOBALS['LANG']->getLL('countResults', true),
191 'explain' => $GLOBALS['LANG']->getLL('explainQuery', true),
192 'csv' => $GLOBALS['LANG']->getLL('csvExport', true),
193 'xml' => $GLOBALS['LANG']->getLL('xmlExport', true)
194 ),
195
196 'sword' => ''
197 );
198 // CLEAN SETTINGS
199 $OLD_MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU,'', $this->MCONF['name'], 'ses');
200 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
201
202 if (t3lib_div::_GP('queryConfig')) {
203 $qA = t3lib_div::_GP('queryConfig');
204 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, array('queryConfig'=>serialize($qA)), $this->MCONF['name'], 'ses');
205 }
206 $addConditionCheck = t3lib_div::_GP('qG_ins');
207 foreach ($OLD_MOD_SETTINGS as $key=>$val) {
208 if (substr($key, 0, 5)=='query' && $this->MOD_SETTINGS[$key]!=$val && $key!='queryLimit' && $key!='use_listview') {
209 $setLimitToStart = 1;
210 if ($key == 'queryTable' && !$addConditionCheck) {
211 $this->MOD_SETTINGS['queryConfig'] = '';
212 }
213 }
214 if ($key=='queryTable' && $this->MOD_SETTINGS[$key]!=$val) {
215 $this->MOD_SETTINGS['queryFields'] = '';
216 }
217 }
218 if ($setLimitToStart) {
219 $currentLimit = explode(',',$this->MOD_SETTINGS['queryLimit']);
220 if ($currentLimit[1]) {
221 $this->MOD_SETTINGS['queryLimit']='0,'.$currentLimit[1];
222 } else {
223 $this->MOD_SETTINGS['queryLimit']='0';
224 }
225 $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, $this->MOD_SETTINGS, $this->MCONF['name'], 'ses');
226 }
227 }
228
229 /**
230 * Main
231 *
232 * @return void
233 */
234 function main() {
235 global $BE_USER,$LANG;
236
237 // Content creation
238 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
239 $this->menu = t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
240 }
241
242 switch($this->MOD_SETTINGS['function']) {
243 case 'search':
244 $this->func_search();
245 break;
246 case 'tree':
247 $this->func_tree();
248 break;
249 case 'records':
250 $this->func_records();
251 break;
252 case 'relations':
253 $this->func_relations();
254 break;
255 case 'filesearch':
256 $this->func_filesearch();
257 break;
258 case 'refindex':
259 $this->func_refindex();
260 break;
261 default:
262 $this->func_default();
263 break;
264 }
265
266 // Setting up the buttons and markers for docheader
267 $docHeaderButtons = $this->getButtons();
268 $markers = array(
269 'CSH' => $docHeaderButtons['csh'],
270 'FUNC_MENU' => $this->getFuncMenu(),
271 'CONTENT' => $this->content
272 );
273
274 // Build the <body> for the module
275 $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
276 $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
277 $this->content.= $this->doc->endPage();
278 $this->content = $this->doc->insertStylesAndJS($this->content);
279 }
280
281 /**
282 * Print content
283 *
284 * @return void
285 */
286 function printContent() {
287 echo $this->content;
288 }
289
290 /**
291 * Create the panel of buttons for submitting the form or otherwise perform operations.
292 *
293 * @return array all available buttons as an assoc. array
294 */
295 protected function getButtons() {
296
297 $buttons = array(
298 'csh' => '',
299 'shortcut' => ''
300 );
301 // CSH
302 //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
303
304 // Shortcut
305 if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
306 $buttons['shortcut'] = $this->doc->makeShortcutIcon('','function,search,search_query_makeQuery',$this->MCONF['name']);
307 }
308 return $buttons;
309 }
310
311 /**
312 * Create the function menu
313 *
314 * @return string HTML of the function menu
315 */
316 protected function getFuncMenu() {
317 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
318 $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
319 }
320 return $funcMenu;
321 }
322
323 /**
324 * Menu
325 *
326 * @return void
327 */
328 function func_default() {
329 global $LANG;
330
331 $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('title'));
332 $this->content.=$this->doc->section('<a href="index.php?SET[function]=records">' . $GLOBALS['LANG']->getLL('records') . '</a>',$GLOBALS['LANG']->getLL('records_description'),1,1,0,1);
333 $this->content.=$this->doc->section('<a href="index.php?SET[function]=tree">' . $GLOBALS['LANG']->getLL('tree') . '</a>',$GLOBALS['LANG']->getLL('tree_description'),1,1,0,1);
334 $this->content.=$this->doc->section('<a href="index.php?SET[function]=relations">' . $GLOBALS['LANG']->getLL('relations') . '</a>',$GLOBALS['LANG']->getLL('relations_description'),1,1,0,1);
335 $this->content.=$this->doc->section('<a href="index.php?SET[function]=search">' . $GLOBALS['LANG']->getLL('search') . '</a>',$GLOBALS['LANG']->getLL('search_description'),1,1,0,1);
336 $this->content.=$this->doc->section('<a href="index.php?SET[function]=filesearch">' . $GLOBALS['LANG']->getLL('filesearch') . '</a>',$GLOBALS['LANG']->getLL('filesearch_description'),1,1,0,1);
337 $this->content.=$this->doc->section('<a href="index.php?SET[function]=refindex">' . $GLOBALS['LANG']->getLL('refindex') . '</a>',$GLOBALS['LANG']->getLL('refindex_description'),1,1,0,1);
338 }
339
340
341
342
343
344
345
346
347 /****************************
348 *
349 * Functionality implementation
350 *
351 ****************************/
352
353 /**
354 * Check and update reference index!
355 *
356 * @return void
357 */
358 function func_refindex() {
359 global $TYPO3_DB,$TCA;
360
361 if (t3lib_div::_GP('_update') || t3lib_div::_GP('_check')) {
362 $testOnly = t3lib_div::_GP('_check')?TRUE:FALSE;
363
364 // Call the functionality
365 $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
366 list($headerContent,$bodyContent) = $refIndexObj->updateIndex($testOnly);
367
368 // Output content:
369 $this->content.=$this->doc->section($headerContent,str_replace(LF,'<br/>',$bodyContent),0,1);
370 }
371
372 // Output content:
373 $content = '<p>' . $GLOBALS['LANG']->getLL('referenceIndex_description') . '</p><br />';
374 $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 />';
375 $content .= '<h3>' . $GLOBALS['LANG']->getLL('checkScript_headline') . '</h3>';
376 $content.= '<p>' . $GLOBALS['LANG']->getLL('checkScript') . '</p>';
377 $content.= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_check_description') . '</h4>' .
378 '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -c</code><br />';
379 $content.= '<h4>' . $GLOBALS['LANG']->getLL('checkScript_update_description') . '</h4>' .
380 '<code>php ' . PATH_typo3 . 'cli_dispatch.phpsh lowlevel_refindex -e</code><br /><br />';
381 $content.= '<div class="typo3-message message-information"><div class="message-body">' . $GLOBALS['LANG']->getLL('checkScript_information') . '</div></div>';
382 $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>';
383
384 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('updateRefIndex'), $content, false, true);
385 }
386
387 /**
388 * Search (Full / Advanced)
389 *
390 * @return void
391 */
392 function func_search() {
393 global $LANG;
394
395 $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
396 $fullsearch->setFormName($this->formName);
397 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('search'));
398 $this->content.= $this->doc->spacer(5);
399
400 $menu2='';
401 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
402 $menu2 = t3lib_BEfunc::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
403 }
404 if ($this->MOD_SETTINGS['search']=='query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
405 $menu2 .= t3lib_BEfunc::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
406 }
407 if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search']=='query') {
408 $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 />';
409 $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 />';
410 $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 />';
411 $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 />';
412 $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>';
413 }
414
415 $this->content.= $this->doc->section('',$menu2).$this->doc->spacer(10);
416
417 switch($this->MOD_SETTINGS['search']) {
418 case 'query':
419 $this->content.=$fullsearch->queryMaker();
420 break;
421 case 'raw':
422 default:
423 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchOptions'), $fullsearch->form(), false, true);
424 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('result'), $fullsearch->search(), false, true);
425 break;
426 }
427 }
428
429 /**
430 * Display page tree
431 *
432 * @return void
433 */
434 function func_tree() {
435 global $LANG,$BACK_PATH;
436
437 $startID = 0;
438 $admin = t3lib_div::makeInstance('t3lib_admin');
439 $admin->genTree_makeHTML=1;
440 $admin->backPath = $BACK_PATH;
441 $admin->genTree(intval($startID),'<img src="' . $BACK_PATH . 'clear.gif" width="1" height="1" align="top" alt="" />');
442
443 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('tree'));
444 $this->content.= $this->doc->spacer(5);
445 $this->content.= $this->doc->sectionEnd();
446
447 $this->content.= $admin->genTree_HTML;
448 $this->content.= $admin->lostRecords($admin->genTree_idlist.'0');
449 }
450
451 /**
452 * Records overview
453 *
454 * @return void
455 */
456 function func_records() {
457 global $LANG,$TCA,$BACK_PATH,$PAGES_TYPES;
458
459 $admin = t3lib_div::makeInstance('t3lib_admin');
460 $admin->genTree_makeHTML = 0;
461 $admin->backPath = $BACK_PATH;
462 $admin->genTree(0,'');
463
464 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('records'));
465 $this->content.= $this->doc->spacer(5);
466
467 // Pages stat
468 $codeArr=array();
469 $codeArr['tableheader'] = array('', $GLOBALS['LANG']->getLL('count'));
470 $i++;
471 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"') . ' hspace="4" align="top" alt="" />';
472 $codeArr[$i][]=$GLOBALS['LANG']->getLL('total_pages');
473 $codeArr[$i][]=count($admin->page_idArray);
474 $i++;
475 if (t3lib_extMgm::isLoaded('cms')) {
476 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
477 $codeArr[$i][]=$GLOBALS['LANG']->getLL('hidden_pages');
478 $codeArr[$i][]=$admin->recStat['hidden'];
479 $i++;
480 }
481 $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
482 $codeArr[$i][]=$GLOBALS['LANG']->getLL('deleted_pages');
483 $codeArr[$i][]=$admin->recStat['deleted'];
484
485 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('pages'), $this->doc->table($codeArr), false, true);
486
487 // Doktype
488 $codeArr=array();
489 $codeArr['tableheader'] = array($GLOBALS['LANG']->getLL('doktype_value'), $GLOBALS['LANG']->getLL('count'));
490 $doktype= $TCA['pages']['columns']['doktype']['config']['items'];
491 if (is_array($doktype)) {
492 foreach ($doktype as $n => $setup) {
493 if ($setup[1]!='--div--') {
494 $codeArr[$n][] = '<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/' . ($PAGES_TYPES[$setup[1]]['icon'] ? $PAGES_TYPES[$setup[1]]['icon'] : $PAGES_TYPES['default']['icon']), 'width="18" height="16"') . ' hspace="4" align="top">';
495 $codeArr[$n][] = $GLOBALS['LANG']->sL($setup[0]) . ' (' . $setup[1] . ')';
496 $codeArr[$n][] = intval($admin->recStat[doktype][$setup[1]]);
497 }
498 }
499 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), false, true);
500 }
501
502 // Tables and lost records
503 $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
504 $id_list = t3lib_div::rm_endcomma($id_list);
505 $admin->lostRecords($id_list);
506
507 if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'),t3lib_div::_GET('fixLostRecords_uid'))) {
508 $admin = t3lib_div::makeInstance('t3lib_admin');
509 $admin->backPath = $BACK_PATH;
510 $admin->genTree(0,'');
511 $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
512 $id_list = t3lib_div::rm_endcomma($id_list);
513 $admin->lostRecords($id_list);
514 }
515
516 $this->doc->table_TABLE = '<table border="0" cellspacing="0" cellpadding="0" class="typo3-dblist" style="width:700px!important;">';
517
518 $codeArr = array();
519 $codeArr['tableheader'] = array(
520 $GLOBALS['LANG']->getLL('label'),
521 $GLOBALS['LANG']->getLL('tablename'),
522 $GLOBALS['LANG']->getLL('total_lost'),
523 ''
524 );
525
526 $countArr = $admin->countRecords($id_list);
527 if (is_array($TCA)) {
528
529 foreach ($TCA as $t => $value) {
530 if ($TCA[$t]['ctrl']['hideTable']) {
531 continue;
532 }
533 $codeArr[$t][]=t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'hspace="4" align="top"');
534 $codeArr[$t][]=$LANG->sL($TCA[$t]['ctrl']['title']);
535 $codeArr[$t][]=$t;
536
537 if ($countArr['all'][$t]) {
538 $theNumberOfRe = intval($countArr['non_deleted'][$t]).'/'.(intval($countArr['all'][$t])-intval($countArr['non_deleted'][$t]));
539 } else {
540 $theNumberOfRe ='';
541 }
542 $codeArr[$t][]=$theNumberOfRe;
543
544 $lr='';
545 if (is_array($admin->lRecords[$t])) {
546 foreach ($admin->lRecords[$t] as $data) {
547 if (!t3lib_div::inList($admin->lostPagesList,$data[pid])) {
548 $lr.= '<nobr><b><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) . '</b></nobr><br>';
549 } else {
550 $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>';
551 }
552 }
553 }
554 $codeArr[$t][]=$lr;
555 }
556 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('tables'), $this->doc->table($codeArr), false, true);
557 }
558 }
559
560 /**
561 * Show list references
562 *
563 * @return void
564 */
565 function func_relations() {
566 global $LANG,$BACK_PATH;
567
568 $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('relations'));
569 $this->content.= $this->doc->spacer(5);
570
571 $admin = t3lib_div::makeInstance('t3lib_admin');
572 $admin->genTree_makeHTML=0;
573 $admin->backPath = $BACK_PATH;
574
575 $fkey_arrays = $admin->getGroupFields('');
576 $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
577
578
579 $fileTest = $admin->testFileRefs();
580
581 $code='';
582 if (is_array($fileTest['noReferences'])) {
583 foreach ($fileTest['noReferences'] as $val) {
584 $code.='<nobr>' . $val[0] . '/<b>' . $val[1] . '</b></nobr><br>';
585 }
586 }
587 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_no_ref'), $code, true, true);
588
589 $code='';
590 if (is_array($fileTest['moreReferences'])) {
591 foreach ($fileTest['moreReferences'] as $val) {
592 $code.='<nobr>' . $val[0] . '/<b>' . $val[1] . '</b>: ' . $val[2] . ' ' . $GLOBALS['LANG']->getLL('references') . '</nobr><br>' . $val[3] . '<br><br>';
593 }
594 }
595 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_many_ref'),$code, true, true);
596
597 $code='';
598 if (is_array($fileTest['noFile'])) {
599 ksort($fileTest['noFile']);
600 foreach ($fileTest['noFile'] as $val) {
601 $code.='<nobr>' . $val[0] . '/<b>' . $val[1] . '</b> ' . $GLOBALS['LANG']->getLL('isMissing') . ' </nobr><br>' . $GLOBALS['LANG']->getLL('referencedFrom') . $val[2] . '<br><br>';
602 }
603 }
604 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('files_no_file'), $code, true, true);
605 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('select_db'), $admin->testDBRefs($admin->checkSelectDBRefs), true, true);
606 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('group_db'), $admin->testDBRefs($admin->checkGroupDBRefs), true, true);
607 }
608
609 /**
610 * Searching for files with a specific pattern
611 *
612 * @return void
613 */
614 function func_filesearch() {
615 $pattern = t3lib_div::_GP('pattern');
616 $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') . '">';
617 $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('pattern'), $pcontent, false, true);
618
619 if (strcmp($pattern,'')) {
620 $dirs = t3lib_div::get_dirs(PATH_site);
621 $lines=array();
622 $depth=10;
623
624 foreach ($dirs as $key => $value) {
625 $matching_files=array();
626 $info='';
627 if (!t3lib_div::inList('typo3,typo3conf,tslib,media,t3lib',$value)) {
628 $info = $this->findFile(PATH_site.$value.'/',$pattern,$matching_files,$depth);
629 }
630 if (is_array($info)) {
631 $lines[]='<hr><b>' . $value . '/</b> ' . $GLOBALS['LANG']->getLL('beingChecked');
632 $lines[]=$GLOBALS['LANG']->getLL('directories') . ' ' . $info[0];
633 if ($info[2]) $lines[]='<span class="typo3-red">' . $GLOBALS['LANG']->getLL('directoriesTooDeep') . ' ' . $depth . '</span>';
634 $lines[]=$GLOBALS['LANG']->getLL('files') . ' ' . $info[1];
635 $lines[]=$GLOBALS['LANG']->getLL('matchingFiles') . '<br><nobr><span class="typo3-red">' . implode('<br>', $matching_files) . '</span></nobr>';
636 } else {
637 $lines[]=$GLOBALS['TBE_TEMPLATE']->dfw('<hr><b>' . $value . '/</b> ' . $GLOBALS['LANG']->getLL('notChecked'));
638 }
639 }
640
641 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchingForFilenames'), implode('<br>', $lines), false, true);
642 }
643 }
644
645 /**
646 * Searching for filename pattern recursively in the specified dir.
647 *
648 * @param string Base directory
649 * @param string Match pattern
650 * @param array Array of matching files, passed by reference
651 * @param integer Depth to recurse
652 * @return array Array with various information about the search result
653 * @see func_filesearch()
654 */
655 function findFile($basedir,$pattern,&$matching_files,$depth) {
656 $files_searched=0;
657 $dirs_searched=0;
658 $dirs_error=0;
659
660 // Traverse files:
661 $files = t3lib_div::getFilesInDir($basedir,'',1);
662 if (is_array($files)) {
663 $files_searched+=count($files);
664 foreach ($files as $value) {
665 if (preg_match('/'.$pattern.'/i',basename($value))) $matching_files[]=substr($value,strlen(PATH_site));
666 }
667 }
668
669
670 // Traverse subdirs
671 if ($depth>0) {
672 $dirs = t3lib_div::get_dirs($basedir);
673 if (is_array($dirs)) {
674 $dirs_searched+=count($dirs);
675
676 foreach ($dirs as $value) {
677 $inf= $this->findFile($basedir.$value.'/',$pattern,$matching_files,$depth-1);
678 $dirs_searched+=$inf[0];
679 $files_searched+=$inf[1];
680 $dirs_error=$inf[2];
681 }
682 }
683 } else {
684 $dirs = t3lib_div::get_dirs($basedir);
685 if (is_array($dirs) && count($dirs)) {
686 $dirs_error=1; // Means error - there were further subdirs!
687 }
688 }
689
690 return array($dirs_searched,$files_searched,$dirs_error);
691 }
692 }
693
694
695 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']) {
696 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']);
697 }
698
699
700
701 // Make instance:
702 $SOBE = t3lib_div::makeInstance('SC_mod_tools_dbint_index');
703 $SOBE->init();
704 $SOBE->main();
705 $SOBE->printContent();
706
707 ?>