Documentation TYPO3 par Ameos |
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 1999-2005 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 ***************************************************************/ 00056 class tx_lowlevel_deleted extends tx_lowlevel_cleaner_core { 00057 00063 function tx_lowlevel_deleted() { 00064 parent::tx_lowlevel_cleaner_core(); 00065 00066 // Setting up help: 00067 $this->cli_options[] = array('--echotree level', 'When "level" is set to 1 or higher you will see the page of the page tree outputted as it is traversed. A value of 2 for "level" will show even more information.'); 00068 $this->cli_options[] = array('--pid id', 'Setting start page in page tree. Default is the page tree root, 0 (zero)'); 00069 $this->cli_options[] = array('--depth int', 'Setting traversal depth. 0 (zero) will only analyse start page (see --pid), 1 will traverse one level of subpages etc.'); 00070 00071 $this->cli_help['name'] = 'deleted -- To find and flush deleted records in the page tree'; 00072 $this->cli_help['description'] = trim(' 00073 Traversing page tree and finding deleted records 00074 00075 Automatic Repair: 00076 Although deleted records are not errors to be repaired, this tool allows you to flush the deleted records completely from the system as an automatic action. Limiting this lookup by --pid and --depth can help you to narrow in the operation to a part of the page tree. 00077 '); 00078 00079 $this->cli_help['examples'] = ''; 00080 } 00081 00088 function main() { 00089 global $TYPO3_DB; 00090 00091 // Initialize result array: 00092 $resultArray = array( 00093 'message' => $this->cli_help['name'].chr(10).chr(10).$this->cli_help['description'], 00094 'headers' => array( 00095 'deleted' => array('Index of deleted records','These are records from the page tree having the deleted-flag set. The --AUTOFIX option will flush them completely!',1), 00096 ), 00097 'deleted' => array(), 00098 ); 00099 00100 $startingPoint = $this->cli_isArg('--pid') ? t3lib_div::intInRange($this->cli_argValue('--pid'),0) : 0; 00101 $depth = $this->cli_isArg('--depth') ? t3lib_div::intInRange($this->cli_argValue('--depth'),0) : 1000; 00102 $this->genTree($startingPoint,$depth,(int)$this->cli_argValue('--echotree')); 00103 00104 $resultArray['deleted'] = $this->recStats['deleted']; 00105 00106 return $resultArray; 00107 } 00108 00116 function main_autoFix($resultArray) { 00117 00118 // Putting "tx_templavoila_datastructure" table in the bottom: 00119 if (isset($resultArray['deleted']['tx_templavoila_datastructure'])) { 00120 $_tx_templavoila_datastructure = $resultArray['deleted']['tx_templavoila_datastructure']; 00121 unset($resultArray['deleted']['tx_templavoila_datastructure']); 00122 $resultArray['deleted']['tx_templavoila_datastructure'] = $_tx_templavoila_datastructure; 00123 } 00124 00125 // Putting "pages" table in the bottom: 00126 if (isset($resultArray['deleted']['pages'])) { 00127 $_pages = $resultArray['deleted']['pages']; 00128 unset($resultArray['deleted']['pages']); 00129 $resultArray['deleted']['pages'] = array_reverse($_pages); // To delete sub pages first assuming they are accumulated from top of page tree. 00130 } 00131 00132 // Traversing records: 00133 foreach($resultArray['deleted'] as $table => $list) { 00134 echo 'Flushing deleted records from table "'.$table.'":'.chr(10); 00135 foreach($list as $uid) { 00136 echo ' Flushing record "'.$table.':'.$uid.'": '; 00137 if ($bypass = $this->cli_noExecutionCheck($table.':'.$uid)) { 00138 echo $bypass; 00139 } else { 00140 00141 // Execute CMD array: 00142 $tce = t3lib_div::makeInstance('t3lib_TCEmain'); 00143 $tce->stripslashes_values = FALSE; 00144 $tce->start(array(),array()); 00145 $tce->deleteRecord($table,$uid, TRUE, TRUE); // Notice, we are deleting pages with no regard to subpages/subrecords - we do this since they should also be included in the set of deleted pages of course (no un-deleted record can exist under a deleted page...) 00146 00147 // Return errors if any: 00148 if (count($tce->errorLog)) { 00149 echo ' ERROR from "TCEmain":'.chr(10).'TCEmain:'.implode(chr(10).'TCEmain:',$tce->errorLog); 00150 } else echo "DONE"; 00151 } 00152 echo chr(10); 00153 } 00154 } 00155 } 00156 } 00157 00158 ?>