[TASK] Remove XCLASS definitions from typo3/
[Packages/TYPO3.CMS.git] / typo3 / sysext / lowlevel / class.tx_lowlevel_cleaner.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 * Web > Functions module plugin for cleaning up.
29 *
30 * XHTML compliant
31 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
32 */
33
34 require_once(t3lib_extMgm::extPath('lowlevel').'class.tx_lowlevel_cleaner_core.php');
35
36 die('Not developed...');
37
38 // @deprecated TODO: remove
39
40
41
42 /**
43 * Web > Functions module plugin for cleaning up.
44 *
45 * @author Kasper Skårhøj <kasperYYYY@typo3.com>
46 * @package TYPO3
47 * @subpackage tx_lowlevel
48 */
49 class tx_lowlevel_cleaner extends t3lib_extobjbase {
50
51
52 /**
53 * Modifies parent objects internal MOD_MENU array, adding items this module needs.
54 *
55 * @return array Items merged with the parent objects.
56 * @see t3lib_extobjbase::init()
57 */
58 function modMenu() {
59 global $LANG;
60
61 $modMenuAdd = array(
62 'tx_lowlevel_cleaner' => array(
63 # 'delete_flush' => 'Flush "deleted" records', // ID/depth related
64 # 'delete_restore' => 'Restore "deleted" records', // ID/depth related
65 # 'versions_flush' => 'Flush published versions', // ID/depth related
66
67 # 'clean_flexform_xml' => 'Clean up FlexForm XML', // ID/depth related
68 # tt_content element removal: templavoila plugin! // ID/depth related
69 # Check for various: uid>0, pid>-1 , lost swapping operations,
70 # 'l10n_duplicates' => 'Localization errors',
71 # Find TCA/FlexForm fields which should probably have a soft reference parser attached!
72
73 # TemplaVoila plugs in to display mapping issues.
74 # Overview of http:// and emails // UPDATE index!
75
76 'missing_files' => 'Missing files', // UPDATE index!
77 'missing_relations' => 'Missing relations', // UPDATE index!
78 # 'lost_records' => 'Orphan records',
79 'lost_files' => 'Orphan files (from uploads/)', // UPDATE index!
80 'RTEmagic_files' => 'RTE Magic Images', // UPDATE index!
81 'double_files' => 'Double file references', // UPDATE index!
82 )
83 );
84
85 return $modMenuAdd;
86 }
87
88 /**
89 * Creation of the main content.
90 *
91 * @return string The content
92 */
93 function main() {
94 $content = '';
95
96 if ($GLOBALS['BE_USER']->isAdmin()) {
97 $content.= $this->pObj->doc->spacer(5);
98 $content.= $this->createMenu().'<hr/>';
99 $content.= $this->moduleContent();
100 $content.= $this->quickDBlookUp();
101 } else {
102 $content.= $this->pObj->doc->spacer(5);
103 $content.= 'Only access for admin users, sorry.';
104 }
105 return $content;
106 }
107
108 /**
109 * Creates HTML menu for the module.
110 *
111 * @return string HTML code for menu
112 */
113 function createMenu() {
114 if (is_array($this->pObj->MOD_MENU['tx_lowlevel_cleaner'])) {
115 $menu = '';
116 foreach($this->pObj->MOD_MENU['tx_lowlevel_cleaner'] as $key => $value) {
117 $menu .= '<a href="index.php?id=' . intval(t3lib_div::_GP('id')) . '&tx_lowlevel_cleaner=' . $key . '">' . htmlspecialchars($value) . '</a><br />';
118 }
119 return $menu;
120 }
121 }
122
123 /**
124 * Branching out to the specified module functionality.
125 *
126 * @return string HTML
127 */
128 function moduleContent() {
129 $cleanerObj = t3lib_div::makeInstance('tx_lowlevel_cleaner_core');
130 $silent = FALSE;
131 $filter = 0;
132
133 switch(t3lib_div::_GP('tx_lowlevel_cleaner')) {
134 case 'lost_files':
135 $res = $cleanerObj->clean_lost_files_analyze();
136 $output = $cleanerObj->html_printInfo('clean_lost_files_analyze()',$res,$silent,$filter);
137 break;
138 case 'RTEmagic_files':
139 $res = $cleanerObj->RTEmagic_files_analyze();
140 $output = $cleanerObj->html_printInfo('RTEmagic_files_analyze()',$res,$silent,$filter);
141 break;
142 case 'double_files':
143 $res = $cleanerObj->double_files_analyze();
144 $output = $cleanerObj->html_printInfo('double_files_analyze()',$res,$silent,$filter);
145 break;
146 case 'missing_files':
147 $res = $cleanerObj->missing_files_analyze();
148 $output = $cleanerObj->html_printInfo('missing_files_analyze()',$res,$silent,$filter);
149 break;
150 case 'missing_relations':
151 $res = $cleanerObj->missing_relations_analyze();
152 $output = $cleanerObj->html_printInfo('missing_relations_analyze()',$res,$silent,$filter);
153 break;
154 }
155
156 /*
157 // TEST of how we can get the used Content Elements on a TemplaVoila page:
158 require_once(t3lib_extMgm::extPath('templavoila').'class.tx_templavoila_api.php');
159 $apiObj = t3lib_div::makeInstance('tx_templavoila_api', 'pages');
160 $contentTreeData = $apiObj->getContentTree('pages', t3lib_BEfunc::getRecordWSOL('pages',33),FALSE);
161 debug($contentTreeData);
162 */
163 return $output;
164 }
165
166 function quickDBlookUp() {
167 $output = 'Enter [table]:[uid]:[fieldlist (optional)] <input name="table_uid" value="'.htmlspecialchars(t3lib_div::_POST('table_uid')).'" />';
168 $output .= '<input type="submit" name="_" value="REFRESH" /><br />';
169
170 // Show record:
171 if (t3lib_div::_POST('table_uid')) {
172 list($table,$uid,$fieldName) = t3lib_div::trimExplode(':',t3lib_div::_POST('table_uid'),1);
173 if ($GLOBALS['TCA'][$table]) {
174 $rec = t3lib_BEfunc::getRecordRaw($table,'uid='.intval($uid),$fieldName?$fieldName:'*');
175
176 if (count($rec)) {
177 if (t3lib_div::_POST('_EDIT')) {
178 $output .= '<hr />Edit:<br /><br />';
179 foreach($rec as $field => $value) {
180 $output .= htmlspecialchars($field) . '<br /><input name="record[' . $table . '][' . $uid . '][' . $field . ']" value="' . htmlspecialchars($value) . '" /><br />';
181 }
182 $output.='<input type="submit" name="_SAVE" value="SAVE" />';
183 } elseif (t3lib_div::_POST('_SAVE')) {
184 $incomingData = t3lib_div::_POST('record');
185 $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table,'uid='.intval($uid),$incomingData[$table][$uid]);
186 $output .= '<br />Updated ' . $table . ':' . $uid . '...';
187 $this->updateRefIndex($table,$uid);
188 } elseif (t3lib_div::_POST('_DELETE')) {
189 $GLOBALS['TYPO3_DB']->exec_DELETEquery($table,'uid='.intval($uid));
190 $output .= '<br />Deleted ' . $table . ':' . $uid . '...';
191 $this->updateRefIndex($table,$uid);
192 } else {
193 $output.='<input type="submit" name="_EDIT" value="EDIT" />';
194 $output.='<input type="submit" name="_DELETE" value="DELETE" onclick="return confirm(\'Are you sure you wish to delete?\');" />';
195 $output.= t3lib_utility_Debug::viewArray($rec);
196 $output.=md5(implode('', $rec));
197 }
198 } else {
199 $output.='No record existed!';
200 }
201 }
202 }
203
204 return $output;
205 }
206
207
208 /**
209 * Update Reference Index (sys_refindex) for a record
210 *
211 * @param string Table name
212 * @param integer Record UID
213 * @return void
214 */
215 function updateRefIndex($table,$id) {
216 $refIndexObj = t3lib_div::makeInstance('t3lib_refindex');
217 $result = $refIndexObj->updateRefIndexTable($table,$id);
218 }
219 }
220 ?>