index.php

Go to the documentation of this file.
00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *
00005 *  (c) 1999-2008 Kasper Skaarhoj (kasperYYYY@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00027 /**
00028  * Module: Database integrity check
00029  *
00030  * This module lets you check if all pages and the records relate properly to each other
00031  *
00032  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00033  * @coauthor    Jo Hasenau <info@cybercraft.de>
00034  */
00035 /**
00036  * [CLASS/FUNCTION INDEX of SCRIPT]
00037  *
00038  *
00039  *
00040  *   89: class SC_mod_tools_dbint_index
00041  *  105:     function init()
00042  *  119:     function jumpToUrl(URL)
00043  *  139:     function menuConfig()
00044  *  226:     function main()
00045  *  270:     function printContent()
00046  *  281:     function func_default()
00047  *
00048  *              SECTION: Functionality implementation
00049  *  314:     function func_refindex()
00050  *  344:     function func_search()
00051  *  386:     function func_tree()
00052  *  409:     function func_records()
00053  *  507:     function func_relations()
00054  *  558:     function func_filesearch()
00055  *  607:     function findFile($basedir,$pattern,&$matching_files,$depth)
00056  *
00057  * TOTAL FUNCTIONS: 13
00058  * (This index is automatically created/updated by the extension "extdeveval")
00059  *
00060  */
00061 
00062 
00063 unset($MCONF);
00064 require ('conf.php');
00065 require ($BACK_PATH.'init.php');
00066 require ($BACK_PATH.'template.php');
00067 require_once (PATH_t3lib.'class.t3lib_admin.php');
00068 require_once (PATH_t3lib.'class.t3lib_loaddbgroup.php');
00069 require_once (PATH_t3lib.'class.t3lib_querygenerator.php');
00070 require_once (PATH_t3lib.'class.t3lib_parsehtml.php');
00071 require_once (PATH_t3lib.'class.t3lib_xml.php');
00072 require_once (PATH_t3lib.'class.t3lib_fullsearch.php');
00073 require_once (PATH_t3lib.'class.t3lib_refindex.php');
00074 
00075 $GLOBALS['LANG']->includeLLFile('EXT:lowlevel/dbint/locallang.xml');
00076 $BE_USER->modAccess($MCONF,1);
00077 
00078 
00079 
00080 
00081 
00082 
00083 /**
00084  * Script class for the DB int module
00085  *
00086  * @author  Kasper Skaarhoj <kasperYYYY@typo3.com>
00087  * @package TYPO3
00088  * @subpackage tx_lowlevel
00089  */
00090 class SC_mod_tools_dbint_index {
00091 
00092     var $MCONF = array();
00093     var $MOD_MENU = array();
00094     var $MOD_SETTINGS = array();
00095 
00096     /**
00097      * document template object
00098      *
00099      * @var mediumDoc
00100      */
00101     var $doc;
00102 
00103     var $content;
00104     var $menu;
00105 
00106     protected $formName = 'queryform';
00107 
00108 
00109     /**
00110      * Initialization
00111      *
00112      * @return  void
00113      */
00114     function init() {
00115         global $LANG,$BACK_PATH;
00116         $this->MCONF = $GLOBALS['MCONF'];
00117 
00118         $this->menuConfig();
00119 
00120         $this->doc = t3lib_div::makeInstance('template');
00121         $this->doc->backPath = $BACK_PATH;
00122         $this->doc->setModuleTemplate('templates/dbint.html');
00123         $this->doc->form='<form action="" method="post" name="'.$this->formName.'">';
00124 
00125                 // JavaScript
00126         $this->doc->JScode = '
00127         <script language="javascript" type="text/javascript">
00128             script_ended = 0;
00129             function jumpToUrl(URL) {
00130                 window.location.href = URL;
00131             }
00132         </script>
00133         ';
00134 
00135         $this->doc->tableLayout = Array (
00136             'defRow' => Array (
00137                 '0' => Array('<td valign="top">','</td>'),
00138                 '1' => Array('<td valign="top">','</td>'),
00139                 'defCol' => Array('<td><img src="'.$this->doc->backPath.'clear.gif" width="15" height="1" alt="" /></td><td valign="top">','</td>')
00140             )
00141         );
00142     }
00143 
00144     /**
00145      * Configure menu
00146      *
00147      * @return  void
00148      */
00149     function menuConfig()   {
00150         global $LANG;
00151 
00152         // MENU-ITEMS:
00153             // If array, then it's a selector box menu
00154             // If empty string it's just a variable, that'll be saved.
00155             // Values NOT in this array will not be saved in the settings-array for the module.
00156         $this->MOD_MENU = array(
00157             'function' => array(
00158                 0 => $GLOBALS['LANG']->getLL('menu', true),
00159                 'records' => $GLOBALS['LANG']->getLL('recordStatistics', true),
00160                 'tree' => $GLOBALS['LANG']->getLL('totalPageTree', true),
00161                 'relations' => $GLOBALS['LANG']->getLL('databaseRelations', true),
00162                 'search' => $GLOBALS['LANG']->getLL('fullSearch', true),
00163                 'filesearch' => $GLOBALS['LANG']->getLL('findFilename', true),
00164                 'refindex' => $GLOBALS['LANG']->getLL('manageRefIndex', true),
00165             ),
00166             'search' => array(
00167                 'raw' => $GLOBALS['LANG']->getLL('rawSearch', true),
00168                 'query' => $GLOBALS['LANG']->getLL('advancedQuery', true)
00169             ),
00170 
00171             'search_query_smallparts' => '',
00172             'search_result_labels' => '',
00173             'labels_noprefix' => '',
00174             'options_sortlabel' => '',
00175             'show_deleted' => '',
00176 
00177             'queryConfig' => '',    // Current query
00178             'queryTable' => '', // Current table
00179             'queryFields' => '',    // Current tableFields
00180             'queryLimit' => '', // Current limit
00181             'queryOrder' => '', // Current Order field
00182             'queryOrderDesc' => '', // Current Order field descending flag
00183             'queryOrder2' => '',    // Current Order2 field
00184             'queryOrder2Desc' => '',    // Current Order2 field descending flag
00185             'queryGroup' => '', // Current Group field
00186 
00187             'storeArray' => '', // Used to store the available Query config memory banks
00188             'storeQueryConfigs' => '',  // Used to store the available Query configs in memory
00189 
00190             'search_query_makeQuery' => array(
00191                 'all' => $GLOBALS['LANG']->getLL('selectRecords', true),
00192                 'count' => $GLOBALS['LANG']->getLL('countResults', true),
00193                 'explain' => $GLOBALS['LANG']->getLL('explainQuery', true),
00194                 'csv' => $GLOBALS['LANG']->getLL('csvExport', true),
00195                 'xml' => $GLOBALS['LANG']->getLL('xmlExport', true)
00196             ),
00197 
00198             'sword' => ''
00199         );
00200             // CLEAN SETTINGS
00201         $OLD_MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU,'', $this->MCONF['name'], 'ses');
00202         $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, t3lib_div::_GP('SET'), $this->MCONF['name'], 'ses');
00203 
00204         if (t3lib_div::_GP('queryConfig'))  {
00205             $qA = t3lib_div::_GP('queryConfig');
00206             $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, array('queryConfig'=>serialize($qA)), $this->MCONF['name'], 'ses');
00207         }
00208         $addConditionCheck = t3lib_div::_GP('qG_ins');
00209         foreach ($OLD_MOD_SETTINGS as $key=>$val)   {
00210             if (substr($key, 0, 5)=='query' && $this->MOD_SETTINGS[$key]!=$val && $key!='queryLimit' && $key!='use_listview')   {
00211                 $setLimitToStart = 1;
00212                 if ($key == 'queryTable' && !$addConditionCheck) {
00213                     $this->MOD_SETTINGS['queryConfig'] = '';
00214                 }
00215             }
00216             if ($key=='queryTable' && $this->MOD_SETTINGS[$key]!=$val)  {
00217                 $this->MOD_SETTINGS['queryFields'] = '';
00218             }
00219         }
00220         if ($setLimitToStart)   {
00221             $currentLimit = explode(',',$this->MOD_SETTINGS['queryLimit']);
00222             if ($currentLimit[1])   {
00223                 $this->MOD_SETTINGS['queryLimit']='0,'.$currentLimit[1];
00224             } else {
00225                 $this->MOD_SETTINGS['queryLimit']='0';
00226             }
00227             $this->MOD_SETTINGS = t3lib_BEfunc::getModuleData($this->MOD_MENU, $this->MOD_SETTINGS, $this->MCONF['name'], 'ses');
00228         }
00229     }
00230 
00231     /**
00232      * Main
00233      *
00234      * @return  void
00235      */
00236     function main() {
00237         global $BE_USER,$LANG;
00238 
00239             // Content creation
00240         if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu'])   {
00241             $this->menu = t3lib_BEfunc::getFuncMenu(0,'SET[function]',$this->MOD_SETTINGS['function'],$this->MOD_MENU['function']);
00242         }
00243 
00244         switch($this->MOD_SETTINGS['function']) {
00245             case 'search':
00246                 $this->func_search();
00247             break;
00248             case 'tree':
00249                 $this->func_tree();
00250             break;
00251             case 'records':
00252                 $this->func_records();
00253             break;
00254             case 'relations':
00255                 $this->func_relations();
00256             break;
00257             case 'filesearch':
00258                 $this->func_filesearch();
00259             break;
00260             case 'refindex':
00261                 $this->func_refindex();
00262             break;
00263             default:
00264                 $this->func_default();
00265             break;
00266         }
00267 
00268             // Setting up the buttons and markers for docheader
00269         $docHeaderButtons = $this->getButtons();
00270         $markers = array(
00271             'CSH' => $docHeaderButtons['csh'],
00272             'FUNC_MENU' => $this->getFuncMenu(),
00273             'CONTENT' => $this->content
00274         );
00275 
00276             // Build the <body> for the module
00277         $this->content = $this->doc->startPage($GLOBALS['LANG']->getLL('title'));
00278         $this->content.= $this->doc->moduleBody($this->pageinfo, $docHeaderButtons, $markers);
00279         $this->content.= $this->doc->endPage();
00280         $this->content = $this->doc->insertStylesAndJS($this->content);
00281     }
00282 
00283     /**
00284      * Print content
00285      *
00286      * @return  void
00287      */
00288     function printContent() {
00289         echo $this->content;
00290     }
00291 
00292     /**
00293      * Create the panel of buttons for submitting the form or otherwise perform operations.
00294      *
00295      * @return  array   all available buttons as an assoc. array
00296      */
00297     protected function getButtons() {
00298 
00299         $buttons = array(
00300             'csh' => '',
00301             'shortcut' => ''
00302         );
00303             // CSH
00304         //$buttons['csh'] = t3lib_BEfunc::cshItem('_MOD_web_func', '', $GLOBALS['BACK_PATH']);
00305 
00306             // Shortcut
00307         if ($GLOBALS['BE_USER']->mayMakeShortcut()) {
00308             $buttons['shortcut'] = $this->doc->makeShortcutIcon('','function,search,search_query_makeQuery',$this->MCONF['name']);
00309         }
00310         return $buttons;
00311     }
00312 
00313     /**
00314      * Create the function menu
00315      *
00316      * @return  string  HTML of the function menu
00317      */
00318     protected function getFuncMenu() {
00319         if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
00320             $funcMenu = t3lib_BEfunc::getFuncMenu(0, 'SET[function]', $this->MOD_SETTINGS['function'], $this->MOD_MENU['function']);
00321         }
00322         return $funcMenu;
00323     }
00324 
00325     /**
00326      * Menu
00327      *
00328      * @return  void
00329      */
00330     function func_default() {
00331         global $LANG;
00332 
00333         $this->content.=$this->doc->header($GLOBALS['LANG']->getLL('title'));
00334         $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);
00335         $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);
00336         $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);
00337         $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);
00338         $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);
00339         $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);
00340     }
00341 
00342 
00343 
00344 
00345 
00346 
00347 
00348 
00349     /****************************
00350      *
00351      * Functionality implementation
00352      *
00353      ****************************/
00354 
00355     /**
00356      * Check and update reference index!
00357      *
00358      * @return  void
00359      */
00360     function func_refindex()    {
00361         global $TYPO3_DB,$TCA;
00362 
00363         if (t3lib_div::_GP('_update') || t3lib_div::_GP('_check'))  {
00364             $testOnly = t3lib_div::_GP('_check')?TRUE:FALSE;
00365 
00366                 // Call the functionality
00367             $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
00368             list($headerContent,$bodyContent) = $refIndexObj->updateIndex($testOnly);
00369 
00370                 // Output content:
00371             $this->content.=$this->doc->section($headerContent,str_replace(chr(10),'<br/>',$bodyContent),0,1);
00372         }
00373 
00374             // Output content:
00375         $content = $GLOBALS['LANG']->getLL('clickToUpdateRefIndex') . ' <input type="submit" name="_update" value="' . $GLOBALS['LANG']->getLL('updateNow') . '" /><br/>';
00376         $content.= $GLOBALS['LANG']->getLL('clickToTestRefIndex') . ' <input type="submit" name="_check" value="' . $GLOBALS['LANG']->getLL('checkNow') . '" /><br/>';
00377         $content.= $GLOBALS['LANG']->getLL('checkScript') . '<br/>' . t3lib_extMgm::extPath('lowlevel').'dbint/cli/refindex_cli.phpsh';
00378         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('updateRefIndex'), $content, false, true);
00379     }
00380 
00381     /**
00382      * Search (Full / Advanced)
00383      *
00384      * @return  void
00385      */
00386     function func_search()  {
00387         global $LANG;
00388 
00389         $fullsearch = t3lib_div::makeInstance('t3lib_fullsearch');
00390         $fullsearch->setFormName($this->formName);
00391         $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('search'));
00392         $this->content.= $this->doc->spacer(5);
00393 
00394         $menu2='';
00395         if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu'])   {
00396             $menu2 = t3lib_BEfunc::getFuncMenu(0, 'SET[search]', $this->MOD_SETTINGS['search'], $this->MOD_MENU['search']);
00397         }
00398         if ($this->MOD_SETTINGS['search']=='query' && !$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopMenu']) {
00399             $menu2 .= t3lib_BEfunc::getFuncMenu(0, 'SET[search_query_makeQuery]', $this->MOD_SETTINGS['search_query_makeQuery'], $this->MOD_MENU['search_query_makeQuery']) . '<br />';
00400         }
00401         if (!$GLOBALS['BE_USER']->userTS['mod.']['dbint.']['disableTopCheckboxes'] && $this->MOD_SETTINGS['search']=='query')   {
00402             $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 />';
00403             $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 />';
00404             $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 />';
00405             $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 />';
00406             $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>';
00407         }
00408 
00409         $this->content.= $this->doc->section('',$menu2).$this->doc->spacer(10);
00410 
00411         switch($this->MOD_SETTINGS['search'])       {
00412             case 'query':
00413                 $this->content.=$fullsearch->queryMaker();
00414             break;
00415             case 'raw':
00416             default:
00417                 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchOptions'), $fullsearch->form(), false, true);
00418                 $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('result'), $fullsearch->search(), false, true);
00419             break;
00420         }
00421     }
00422 
00423     /**
00424      * Display page tree
00425      *
00426      * @return  void
00427      */
00428     function func_tree()    {
00429         global $LANG,$BACK_PATH;
00430 
00431         $startID = 0;
00432         $admin = t3lib_div::makeInstance('t3lib_admin');
00433         $admin->genTree_makeHTML=1;
00434         $admin->backPath = $BACK_PATH;
00435         $admin->genTree(intval($startID),'<img src="' . $BACK_PATH . 'clear.gif" width="1" height="1" align="top" alt="" />');
00436 
00437         $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('tree'));
00438         $this->content.= $this->doc->spacer(5);
00439         $this->content.= $this->doc->sectionEnd();
00440 
00441         $this->content.= $admin->genTree_HTML;
00442         $this->content.= $admin->lostRecords($admin->genTree_idlist.'0');
00443     }
00444 
00445     /**
00446      * Records overview
00447      *
00448      * @return  void
00449      */
00450     function func_records() {
00451         global $LANG,$TCA,$BACK_PATH,$PAGES_TYPES;
00452 
00453         $admin = t3lib_div::makeInstance('t3lib_admin');
00454         $admin->genTree_makeHTML = 0;
00455         $admin->backPath = $BACK_PATH;
00456         $admin->genTree(0,'');
00457 
00458         $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('records'));
00459         $this->content.= $this->doc->spacer(5);
00460 
00461             // Pages stat
00462         $codeArr=Array();
00463         $i++;
00464         $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/i/pages.gif','width="18" height="16"') . ' hspace="4" align="top" alt="" />';
00465         $codeArr[$i][]=$GLOBALS['LANG']->getLL('total_pages');
00466         $codeArr[$i][]=count($admin->page_idArray);
00467         $i++;
00468         if (t3lib_extMgm::isLoaded('cms'))  {
00469             $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/hidden_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
00470             $codeArr[$i][]=$GLOBALS['LANG']->getLL('hidden_pages');
00471             $codeArr[$i][]=$admin->recStat['hidden'];
00472             $i++;
00473         }
00474         $codeArr[$i][]='<img' . t3lib_iconWorks::skinImg($BACK_PATH,'gfx/deleted_page.gif','width="18" height="16"') . ' hspace="4" align="top">';
00475         $codeArr[$i][]=$GLOBALS['LANG']->getLL('deleted_pages');
00476         $codeArr[$i][]=$admin->recStat['deleted'];
00477 
00478         $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('pages'), $this->doc->table($codeArr), false, true);
00479 
00480             // Doktype
00481         $codeArr=Array();
00482         $doktype= $TCA['pages']['columns']['doktype']['config']['items'];
00483         if (is_array($doktype)) {
00484             reset($doktype);
00485             while(list($n,$setup) = each($doktype)) {
00486                 if ($setup[1]!='--div--')   {
00487                     $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">';
00488                     $codeArr[$n][] = $GLOBALS['LANG']->sL($setup[0]) . ' (' . $setup[1] . ')';
00489                     $codeArr[$n][] = intval($admin->recStat[doktype][$setup[1]]);
00490                 }
00491             }
00492             $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('doktype'), $this->doc->table($codeArr), false, true);
00493         }
00494 
00495             // Tables and lost records
00496         $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
00497         $id_list = t3lib_div::rm_endcomma($id_list);
00498         $admin->lostRecords($id_list);
00499 
00500         if ($admin->fixLostRecord(t3lib_div::_GET('fixLostRecords_table'),t3lib_div::_GET('fixLostRecords_uid')))   {
00501             $admin = t3lib_div::makeInstance('t3lib_admin');
00502             $admin->backPath = $BACK_PATH;
00503             $admin->genTree(0,'');
00504             $id_list = '-1,0,'.implode(array_keys($admin->page_idArray),',');
00505             $id_list = t3lib_div::rm_endcomma($id_list);
00506             $admin->lostRecords($id_list);
00507         }
00508 
00509         $codeArr = Array();
00510         $countArr = $admin->countRecords($id_list);
00511         if (is_array($TCA)) {
00512             reset($TCA);
00513             while(list($t)=each($TCA))  {
00514                 $codeArr[$t][]=t3lib_iconWorks::getIconImage($t,array(),$BACK_PATH,'hspace="4" align="top"');
00515                 $codeArr[$t][]=$LANG->sL($TCA[$t]['ctrl']['title']);
00516                 $codeArr[$t][]=$t;
00517 
00518                 if ($countArr['all'][$t])   {
00519                     $theNumberOfRe = intval($countArr['non_deleted'][$t]).'/'.(intval($countArr['all'][$t])-intval($countArr['non_deleted'][$t]));
00520                 } else {
00521                     $theNumberOfRe ='';
00522                 }
00523                 $codeArr[$t][]=$theNumberOfRe;
00524 
00525                 $lr='';
00526                 if (is_array($admin->lRecords[$t])) {
00527                     reset($admin->lRecords[$t]);
00528                     while(list(,$data)=each($admin->lRecords[$t]))  {
00529                         if (!t3lib_div::inList($admin->lostPagesList,$data[pid]))   {
00530                             $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(strip_tags($data[title]), 20) . '</b></nobr><br>';
00531                         } else {
00532                             $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(strip_tags($data[title]), 20) . '</font></nobr><br>';
00533                         }
00534                     }
00535                 }
00536                 $codeArr[$t][]=$lr;
00537             }
00538             $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('tables'), $this->doc->table($codeArr), false, true);
00539         }
00540     }
00541 
00542     /**
00543      * Show list references
00544      *
00545      * @return  void
00546      */
00547     function func_relations()   {
00548         global $LANG,$BACK_PATH;
00549 
00550         $this->content.= $this->doc->header($GLOBALS['LANG']->getLL('relations'));
00551         $this->content.= $this->doc->spacer(5);
00552 
00553         $admin = t3lib_div::makeInstance('t3lib_admin');
00554         $admin->genTree_makeHTML=0;
00555         $admin->backPath = $BACK_PATH;
00556 
00557         $fkey_arrays = $admin->getGroupFields('');
00558         $admin->selectNonEmptyRecordsWithFkeys($fkey_arrays);
00559 
00560 
00561         $fileTest = $admin->testFileRefs();
00562 
00563         $code='';
00564         if (is_array($fileTest['noReferences']))    {
00565             while(list(,$val)=each($fileTest['noReferences']))  {
00566                 $code.='<nobr>' . $val[0] . '/<b>' . $val[1] . '</b></nobr><br>';
00567             }
00568         }
00569         $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_no_ref'), $code, true, true);
00570 
00571         $code='';
00572         if (is_array($fileTest['moreReferences']))  {
00573             while(list(,$val)=each($fileTest['moreReferences']))    {
00574                 $code.='<nobr>' . $val[0] . '/<b>' . $val[1] . '</b>: ' . $val[2] . ' ' . $GLOBALS['LANG']->getLL('references') . '</nobr><br>' . $val[3] . '<br><br>';
00575             }
00576         }
00577         $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('files_many_ref'),$code, true, true);
00578 
00579         $code='';
00580         if (is_array($fileTest['noFile']))  {
00581             ksort($fileTest['noFile']);
00582             reset($fileTest['noFile']);
00583             while(list(,$val)=each($fileTest['noFile']))    {
00584                 $code.='<nobr>' . $val[0] . '/<b>' . $val[1] . '</b> ' . $GLOBALS['LANG']->getLL('isMissing') . ' </nobr><br>' . $GLOBALS['LANG']->getLL('referencedFrom') . $val[2] . '<br><br>';
00585             }
00586         }
00587         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('files_no_file'), $code, true, true);
00588         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('select_db'), $admin->testDBRefs($admin->checkSelectDBRefs), true, true);
00589         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('group_db'), $admin->testDBRefs($admin->checkGroupDBRefs), true, true);
00590     }
00591 
00592     /**
00593      * Searching for files with a specific pattern
00594      *
00595      * @return  void
00596      */
00597     function func_filesearch()  {
00598         $pattern = t3lib_div::_GP('pattern');
00599         $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') . '">';
00600         $this->content.= $this->doc->section($GLOBALS['LANG']->getLL('pattern'), $pcontent, false, true);
00601 
00602         if (strcmp($pattern,''))    {
00603             $dirs = t3lib_div::get_dirs(PATH_site);
00604             $lines=array();
00605             $depth=10;
00606 
00607             foreach ($dirs as $key => $value) {
00608                 $matching_files=array();
00609                 $info='';
00610                 if (!t3lib_div::inList('typo3,typo3conf,tslib,media,t3lib',$value)) {
00611                     $info = $this->findFile(PATH_site.$value.'/',$pattern,$matching_files,$depth);
00612                 }
00613                 if (is_array($info))    {
00614                     $lines[]='<hr><b>' . $value . '/</b> ' . $GLOBALS['LANG']->getLL('beingChecked');
00615                     $lines[]=$GLOBALS['LANG']->getLL('directories') . ' ' . $info[0];
00616                     if ($info[2])   $lines[]='<span class="typo3-red">' . $GLOBALS['LANG']->getLL('directoriesTooDeep') . ' ' . $depth . '</span>';
00617                     $lines[]=$GLOBALS['LANG']->getLL('files') . ' ' . $info[1];
00618                     $lines[]=$GLOBALS['LANG']->getLL('matchingFiles') . '<br><nobr><span class="typo3-red">' . implode('<br>', $matching_files) . '</span></nobr>';
00619                 } else {
00620                     $lines[]=$GLOBALS['TBE_TEMPLATE']->dfw('<hr><b>' . $value . '/</b> ' . $GLOBALS['LANG']->getLL('notChecked'));
00621                 }
00622             }
00623 
00624             $this->content.=$this->doc->section($GLOBALS['LANG']->getLL('searchingForFilenames'), implode('<br>', $lines), false, true);
00625         }
00626     }
00627 
00628     /**
00629      * Searching for filename pattern recursively in the specified dir.
00630      *
00631      * @param   string      Base directory
00632      * @param   string      Match pattern
00633      * @param   array       Array of matching files, passed by reference
00634      * @param   integer     Depth to recurse
00635      * @return  array       Array with various information about the search result
00636      * @see func_filesearch()
00637      */
00638     function findFile($basedir,$pattern,&$matching_files,$depth)    {
00639         $files_searched=0;
00640         $dirs_searched=0;
00641         $dirs_error=0;
00642 
00643             // Traverse files:
00644         $files = t3lib_div::getFilesInDir($basedir,'',1);
00645         if (is_array($files))   {
00646             $files_searched+=count($files);
00647             foreach ($files as $value) {
00648                 if (eregi($pattern,basename($value)))   $matching_files[]=substr($value,strlen(PATH_site));
00649             }
00650         }
00651 
00652 
00653             // Traverse subdirs
00654         if ($depth>0)   {
00655             $dirs = t3lib_div::get_dirs($basedir);
00656             if (is_array($dirs))    {
00657                 $dirs_searched+=count($dirs);
00658 
00659                 foreach ($dirs as $value) {
00660                     $inf= $this->findFile($basedir.$value.'/',$pattern,$matching_files,$depth-1);
00661                     $dirs_searched+=$inf[0];
00662                     $files_searched+=$inf[1];
00663                     $dirs_error=$inf[2];
00664                 }
00665             }
00666         } else {
00667             $dirs = t3lib_div::get_dirs($basedir);
00668             if (is_array($dirs) && count($dirs))    {
00669                 $dirs_error=1;  // Means error - there were further subdirs!
00670             }
00671         }
00672 
00673         return array($dirs_searched,$files_searched,$dirs_error);
00674     }
00675 }
00676 
00677 
00678 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php'])    {
00679     include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/dbint/index.php']);
00680 }
00681 
00682 
00683 
00684 // Make instance:
00685 $SOBE = t3lib_div::makeInstance('SC_mod_tools_dbint_index');
00686 $SOBE->init();
00687 $SOBE->main();
00688 $SOBE->printContent();
00689 
00690 ?>

Generated on Sat Jan 3 04:23:25 2009 for TYPO3 API by  doxygen 1.4.7