00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00049 require_once(PATH_t3lib.'class.t3lib_extobjbase.php');
00050 require_once(t3lib_extMgm::extPath('lowlevel').'class.tx_lowlevel_cleaner_core.php');
00051 require_once (PATH_t3lib.'class.t3lib_refindex.php');
00052
00053 die('Not developed...');
00054
00055
00056
00057
00058
00066 class tx_lowlevel_cleaner extends t3lib_extobjbase {
00067
00068
00075 function modMenu() {
00076 global $LANG;
00077
00078 $modMenuAdd = array(
00079 'tx_lowlevel_cleaner' => array(
00080 # 'delete_flush' => 'Flush "deleted" records',
00081 # 'delete_restore' => 'Restore "deleted" records',
00082 # 'versions_flush' => 'Flush published versions',
00083
00084 # 'clean_flexform_xml' => 'Clean up FlexForm XML',
00085 # tt_content element removal: templavoila plugin!
00086 # Check for various: uid>0, pid>-1 , lost swapping operations,
00087 # 'l10n_duplicates' => 'Localization errors',
00088 # Find TCA/FlexForm fields which should probably have a soft reference parser attached!
00089
00090 # TemplaVoila plugs in to display mapping issues.
00091 # Overview of http:
00092
00093 'missing_files' => 'Missing files',
00094 'missing_relations' => 'Missing relations',
00095 # 'lost_records' => 'Orphan records',
00096 'lost_files' => 'Orphan files (from uploads/)',
00097 'RTEmagic_files' => 'RTE Magic Images',
00098 'double_files' => 'Double file references',
00099 )
00100 );
00101
00102 return $modMenuAdd;
00103 }
00104
00110 function main() {
00111 global $BE_USER;
00112
00113 $content = '';
00114
00115 if ($BE_USER->isAdmin()) {
00116 $content.= $this->pObj->doc->spacer(5);
00117 $content.= $this->createMenu().'<hr/>';
00118 $content.= $this->moduleContent();
00119 $content.= $this->quickDBlookUp();
00120 } else {
00121 $content.= $this->pObj->doc->spacer(5);
00122 $content.= 'Only access for admin users, sorry.';
00123 }
00124 return $content;
00125 }
00126
00132 function createMenu() {
00133 if (is_array($this->pObj->MOD_MENU['tx_lowlevel_cleaner'])) {
00134 $menu = '';
00135 foreach($this->pObj->MOD_MENU['tx_lowlevel_cleaner'] as $key => $value) {
00136 $menu.='<a href="index.php?id='.intval(t3lib_div::_GP('id')).'&tx_lowlevel_cleaner='.$key.'">'.htmlspecialchars($value).'</a><br/>';
00137 }
00138 return $menu;
00139 }
00140 }
00141
00147 function moduleContent() {
00148 $cleanerObj = t3lib_div::makeInstance('tx_lowlevel_cleaner_core');
00149 $silent = FALSE;
00150 $filter = 0;
00151
00152 switch(t3lib_div::_GP('tx_lowlevel_cleaner')) {
00153 case 'lost_files':
00154 $res = $cleanerObj->clean_lost_files_analyze();
00155 $output = $cleanerObj->html_printInfo('clean_lost_files_analyze()',$res,$silent,$filter);
00156 break;
00157 case 'RTEmagic_files':
00158 $res = $cleanerObj->RTEmagic_files_analyze();
00159 $output = $cleanerObj->html_printInfo('RTEmagic_files_analyze()',$res,$silent,$filter);
00160 break;
00161 case 'double_files':
00162 $res = $cleanerObj->double_files_analyze();
00163 $output = $cleanerObj->html_printInfo('double_files_analyze()',$res,$silent,$filter);
00164 break;
00165 case 'missing_files':
00166 $res = $cleanerObj->missing_files_analyze();
00167 $output = $cleanerObj->html_printInfo('missing_files_analyze()',$res,$silent,$filter);
00168 break;
00169 case 'missing_relations':
00170 $res = $cleanerObj->missing_relations_analyze();
00171 $output = $cleanerObj->html_printInfo('missing_relations_analyze()',$res,$silent,$filter);
00172 break;
00173 }
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183 return $output;
00184 }
00185
00186 function quickDBlookUp() {
00187 $output = 'Enter [table]:[uid]:[fieldlist (optional)] <input name="table_uid" value="'.htmlspecialchars(t3lib_div::_POST('table_uid')).'" />';
00188 $output.='<input type="submit" name="_" value="REFRESH" /><br/>';
00189
00190
00191 if (t3lib_div::_POST('table_uid')) {
00192 list($table,$uid,$fieldName) = t3lib_div::trimExplode(':',t3lib_div::_POST('table_uid'),1);
00193 if ($GLOBALS['TCA'][$table]) {
00194 $rec = t3lib_BEfunc::getRecordRaw($table,'uid='.intval($uid),$fieldName?$fieldName:'*');
00195
00196 if (count($rec)) {
00197 if (t3lib_div::_POST('_EDIT')) {
00198 $output.='<hr/>Edit:<br/><br/>';
00199 foreach($rec as $field => $value) {
00200 $output.= htmlspecialchars($field).'<br/><input name="record['.$table.']['.$uid.']['.$field.']" value="'.htmlspecialchars($value).'" /><br/>';
00201 }
00202 $output.='<input type="submit" name="_SAVE" value="SAVE" />';
00203 } elseif (t3lib_div::_POST('_SAVE')) {
00204 $incomingData = t3lib_div::_POST('record');
00205 $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.intval($uid),$incomingData[$table][$uid]);
00206 $output.='<br/>Updated '.$table.':'.$uid.'...';
00207 $this->updateRefIndex($table,$uid);
00208 } else if (t3lib_div::_POST('_DELETE')) {
00209 $GLOBALS['TYPO3_DB']->exec_DELETEquery($table,'uid='.intval($uid));
00210 $output.='<br/>Deleted '.$table.':'.$uid.'...';
00211 $this->updateRefIndex($table,$uid);
00212 } else {
00213 $output.='<input type="submit" name="_EDIT" value="EDIT" />';
00214 $output.='<input type="submit" name="_DELETE" value="DELETE" onclick="return confirm(\'Are you sure you wish to delete?\');" />';
00215 $output.=t3lib_div::view_array($rec);
00216 $output.=md5(implode($rec));
00217 }
00218 } else {
00219 $output.='No record existed!';
00220 }
00221 }
00222 }
00223
00224 return $output;
00225 }
00226
00227
00235 function updateRefIndex($table,$id) {
00236 $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
00237 $result = $refIndexObj->updateRefIndexTable($table,$id);
00238 }
00239 }
00240
00241 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_cleaner.php']) {
00242 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/lowlevel/class.tx_lowlevel_cleaner.php']);
00243 }
00244 ?>