109 'allValid' => array(),
110 'published_versions' => array(),
136 public function genTree($theID, $depthData, $versions = FALSE) {
138 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid,title,doktype,deleted,t3ver_wsid,t3ver_id,t3ver_count,hidden',
'pages',
'pid=-1 AND t3ver_oid=' . (
int)$theID .
' ' . (!$this->genTree_includeDeleted ?
'AND deleted=0' :
'') . $this->perms_clause,
'',
'sorting');
140 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid,title,doktype,deleted,hidden',
'pages',
'pid=' . (
int)$theID .
' ' . (!$this->genTree_includeDeleted ?
'AND deleted=0' :
'') . $this->perms_clause,
'',
'sorting');
144 $c =
$GLOBALS[
'TYPO3_DB']->sql_num_rows($res);
145 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
148 $versionLabel =
'[v1.' . $row[
't3ver_id'] .
'; WS#' . $row[
't3ver_wsid'] .
']';
153 $newID = $row[
'uid'];
155 if ($this->genTree_makeHTML) {
156 $this->genTree_HTML .= LF .
'<div><span class="nobr">';
158 $LN = $a == $c ?
'blank' :
'line';
159 $BTM = $a == $c ?
'bottom' :
'';
163 $this->page_idArray[$newID] = $row;
164 $this->recStats[
'all_valid'][
'pages'][$newID] = $newID;
165 if ($row[
'deleted']) {
166 $this->recStats[
'deleted'][
'pages'][$newID] = $newID;
168 if ($versions && $row[
't3ver_count'] >= 1) {
169 $this->recStats[
'published_versions'][
'pages'][$newID] = $newID;
171 if ($row[
'deleted']) {
172 $this->recStats[
'deleted']++;
174 if ($row[
'hidden']) {
175 $this->recStats[
'hidden']++;
177 $this->recStats[
'doktype'][$row[
'doktype']]++;
181 if ($this->genTree_includeRecords) {
182 foreach (
$GLOBALS[
'TCA'] as $tableName => $cfg) {
183 if ($tableName !=
'pages') {
184 $this->
genTree_records($newID, $this->genTree_HTML ? $genHTML :
'', $tableName);
189 $this->
genTree($newID, $this->genTree_HTML ? $genHTML :
'');
191 if ($this->genTree_includeVersions) {
192 $this->
genTree($newID, $this->genTree_HTML ? $genHTML :
'', TRUE);
195 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
209 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
216 $res =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
224 $c =
$GLOBALS[
'TYPO3_DB']->sql_num_rows($res);
225 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($res)) {
228 $versionLabel =
'[v1.' . $row[
't3ver_id'] .
'; WS#' . $row[
't3ver_wsid'] .
']';
233 $newID = $row[
'uid'];
235 if ($this->genTree_makeHTML) {
236 $this->genTree_HTML .= LF .
'<div><span class="nobr">';
238 $LN = $a == $c ?
'blank' :
'line';
239 $BTM = $a == $c ?
'bottom' :
'';
243 $this->rec_idArray[$table][$newID] = $row;
244 $this->recStats[
'all_valid'][$table][$newID] = $newID;
245 if ($row[
'deleted']) {
246 $this->recStats[
'deleted'][$table][$newID] = $newID;
248 if ($versions && $row[
't3ver_count'] >= 1 && $row[
't3ver_wsid'] == 0) {
249 $this->recStats[
'published_versions'][$table][$newID] = $newID;
252 if ($this->genTree_includeVersions &&
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
257 $GLOBALS[
'TYPO3_DB']->sql_free_result($res);
268 $this->lostPagesList =
'';
270 foreach (
$GLOBALS[
'TCA'] as $table => $tableConf) {
271 $pid_list_tmp = $pid_list;
272 if (!isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) || !
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
274 $pid_list_tmp = preg_replace(
'/^\\-1,/',
'', $pid_list_tmp);
276 $garbage =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid,pid,' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'label'], $table,
'pid NOT IN (' . $pid_list_tmp .
')');
277 $lostIdList = array();
278 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($garbage)) {
279 $this->lRecords[$table][$row[
'uid']] = array(
280 'uid' => $row[
'uid'],
281 'pid' => $row[
'pid'],
284 $lostIdList[] = $row[
'uid'];
286 $GLOBALS[
'TYPO3_DB']->sql_free_result($garbage);
287 if ($table ==
'pages') {
288 $this->lostPagesList = implode(
',', $lostIdList);
304 if ($table &&
$GLOBALS[
'TCA'][$table] &&
$uid && is_array($this->lRecords[$table][
$uid]) &&
$GLOBALS[
'BE_USER']->user[
'admin']) {
305 $updateFields = array();
306 $updateFields[
'pid'] = 0;
308 if (
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled']) {
309 $updateFields[
$GLOBALS[
'TCA'][$table][
'ctrl'][
'enablecolumns'][
'disabled']] = 1;
311 $GLOBALS[
'TYPO3_DB']->exec_UPDATEquery($table,
'uid=' . (
int)$uid, $updateFields);
329 foreach (
$GLOBALS[
'TCA'] as $table => $tableConf) {
330 $pid_list_tmp = $pid_list;
331 if (!isset(
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) || !
$GLOBALS[
'TCA'][$table][
'ctrl'][
'versioningWS']) {
333 $pid_list_tmp = preg_replace(
'/^\\-1,/',
'', $pid_list_tmp);
335 $count =
$GLOBALS[
'TYPO3_DB']->exec_SELECTcountRows(
'uid', $table,
'pid IN (' . $pid_list_tmp .
')');
337 $list[$table] = $count;
341 $list_n[$table] = $count;
345 return array(
'all' => $list,
'non_deleted' => $list_n);
357 foreach (
$GLOBALS[
'TCA'] as $table => $tableConf) {
358 $cols =
$GLOBALS[
'TCA'][$table][
'columns'];
359 foreach ($cols as $field => $config) {
360 if ($config[
'config'][
'type'] ==
'group') {
361 if ((!$mode || $mode ==
'file') && $config[
'config'][
'internal_type'] ==
'file' || (!$mode || $mode ==
'db') && $config[
'config'][
'internal_type'] ==
'db') {
365 if ((!$mode || $mode ==
'db') && $config[
'config'][
'type'] ==
'select' && $config[
'config'][
'foreign_table']) {
385 foreach (
$GLOBALS[
'TCA'] as $table => $tableConf) {
386 $cols =
$GLOBALS[
'TCA'][$table][
'columns'];
387 foreach ($cols as $field => $config) {
388 if ($config[
'config'][
'type'] ==
'group' && $config[
'config'][
'internal_type'] ==
'file' && $config[
'config'][
'uploadfolder'] == $uploadfolder) {
389 $result[] = array($table, $field);
405 foreach (
$GLOBALS[
'TCA'] as $table => $tableConf) {
406 $cols =
$GLOBALS[
'TCA'][$table][
'columns'];
407 foreach ($cols as $field => $config) {
408 if ($config[
'config'][
'type'] ==
'group' && $config[
'config'][
'internal_type'] ==
'db') {
409 if (trim($config[
'config'][
'allowed']) ==
'*' || strstr($config[
'config'][
'allowed'], $theSearchTable)) {
410 $result[] = array($table, $field);
412 } elseif ($config[
'config'][
'type'] ==
'select' && $config[
'config'][
'foreign_table'] == $theSearchTable) {
413 $result[] = array($table, $field);
428 public function selectNonEmptyRecordsWithFkeys($fkey_arrays) {
429 if (is_array($fkey_arrays)) {
430 foreach ($fkey_arrays as $table => $field_list) {
431 if (
$GLOBALS[
'TCA'][$table] && trim($field_list)) {
432 $fieldArr = explode(
',', $field_list);
433 if (\
TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded(
'dbal')) {
434 $fields =
$GLOBALS[
'TYPO3_DB']->admin_get_fields($table);
435 $field = array_shift($fieldArr);
436 $cl_fl =
$GLOBALS[
'TYPO3_DB']->MetaType($fields[$field][
'type'], $table) ==
'I' ||
$GLOBALS[
'TYPO3_DB']->MetaType($fields[$field][
'type'], $table) ==
'N' ||
$GLOBALS[
'TYPO3_DB']->MetaType($fields[$field][
'type'], $table) ==
'R' ? $field .
'<>0' : $field .
'<>\'\'';
437 foreach ($fieldArr as $field) {
438 $cl_fl .=
$GLOBALS[
'TYPO3_DB']->MetaType($fields[$field][
'type'], $table) ==
'I' ||
$GLOBALS[
'TYPO3_DB']->MetaType($fields[$field][
'type'], $table) ==
'N' ||
$GLOBALS[
'TYPO3_DB']->MetaType($fields[$field][
'type'], $table) ==
'R' ?
' OR ' . $field .
'<>0' :
' OR ' . $field .
'<>\'\'';
442 $cl_fl = implode(
'<>\'\' OR ', $fieldArr) .
'<>\'\'';
444 $mres =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid,' . $field_list, $table, $cl_fl);
445 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres)) {
446 foreach ($fieldArr as $field) {
447 if (trim($row[$field])) {
448 $fieldConf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
449 if ($fieldConf[
'type'] ==
'group') {
450 if ($fieldConf[
'internal_type'] ==
'file') {
452 if ($fieldConf[
'MM']) {
456 $dbAnalysis->start(
'',
'files', $fieldConf[
'MM'], $row[
'uid']);
457 foreach ($dbAnalysis->itemArray as $somekey => $someval) {
458 if ($someval[
'id']) {
459 $tempArr[] = $someval[
'id'];
463 $tempArr = explode(
',', trim($row[$field]));
465 foreach ($tempArr as $file) {
468 $this->checkFileRefs[$fieldConf[
'uploadfolder']][$file] += 1;
472 if ($fieldConf[
'internal_type'] ==
'db') {
475 $dbAnalysis->start($row[$field], $fieldConf[
'allowed'], $fieldConf[
'MM'], $row[
'uid'], $table, $fieldConf);
476 foreach ($dbAnalysis->itemArray as $tempArr) {
477 $this->checkGroupDBRefs[$tempArr[
'table']][$tempArr[
'id']] += 1;
481 if ($fieldConf[
'type'] ==
'select' && $fieldConf[
'foreign_table']) {
484 $dbAnalysis->start($row[$field], $fieldConf[
'foreign_table'], $fieldConf[
'MM'], $row[
'uid'], $table, $fieldConf);
485 foreach ($dbAnalysis->itemArray as $tempArr) {
486 if ($tempArr[
'id'] > 0) {
487 $this->checkGroupDBRefs[$fieldConf[
'foreign_table']][$tempArr[
'id']] += 1;
494 $GLOBALS[
'TYPO3_DB']->sql_free_result($mres);
509 $newCheckFileRefs = array();
510 foreach ($this->checkFileRefs as $folder => $files) {
512 if ($folder !==
'') {
513 $newCheckFileRefs[$folder] = $files;
516 foreach ($files as $file => $references) {
518 if ($references > 1) {
522 $directory = dirname($file);
523 if ($directory !==
'') {
524 $newCheckFileRefs[$directory][basename($file)] = $references;
528 $this->checkFileRefs = $newCheckFileRefs;
529 foreach ($this->checkFileRefs as $folder => $fileArr) {
530 $path = PATH_site . $folder;
531 if (@is_dir($path) && @is_readable($path)) {
533 while ($entry = $d->read()) {
534 if (@is_file(($path .
'/' . $entry))) {
535 if (isset($fileArr[$entry])) {
536 if ($fileArr[$entry] > 1) {
539 foreach ($temp as $inf) {
540 $tempList .=
'[' . $inf[
'table'] .
'][' . $inf[
'uid'] .
'][' . $inf[
'field'] .
'] (pid:' . $inf[
'pid'] .
') - ';
542 $output[
'moreReferences'][] = array($path, $entry, $fileArr[$entry], $tempList);
544 unset($fileArr[$entry]);
547 if (!strstr($entry,
'index.htm') && !preg_match((
'/^' . preg_quote(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'],
'/') .
'/'), $folder)) {
548 $output[
'noReferences'][] = array($path, $entry);
555 foreach ($fileArr as $file => $value) {
557 if (preg_match(
'/^' . preg_quote(
$GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'],
'/') .
'/', $folder)) {
558 $file = $folder .
'/' . $file;
560 $path = substr(PATH_site, 0, -1);
564 foreach ($temp as $inf) {
565 $tempList .=
'[' . $inf[
'table'] .
'][' . $inf[
'uid'] .
'][' . $inf[
'field'] .
'] (pid:' . $inf[
'pid'] .
') - ';
568 $output[
'noFile'][substr($path, -3) .
'_' . substr($file, 0, 3) .
'_' . $tempCounter] = array($path, $file, $tempList);
571 $output[
'error'][] = array($path);
586 foreach ($theArray as $table => $dbArr) {
588 $idlist = array_keys($dbArr);
589 $theList = implode(
',', $idlist);
592 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres)) {
593 if (isset($dbArr[$row[
'uid']])) {
594 unset($dbArr[$row[
'uid']]);
596 $result .=
'Strange Error. ...<br />';
599 $GLOBALS[
'TYPO3_DB']->sql_free_result($mres);
600 foreach ($dbArr as $theId => $theC) {
601 $result .=
'There are ' . $theC .
' records pointing to this missing or deleted record; [' . $table .
'][' . $theId .
']<br />';
605 $result .=
'Codeerror. Table is not a table...<br />';
619 public function whereIsRecordReferenced($searchTable, $id) {
622 $theRecordList = array();
623 foreach ($fileFields as $info) {
626 $mres =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid,pid,' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'label'] .
',' . $field, $table, $field .
' LIKE \'%' .
$GLOBALS[
'TYPO3_DB']->quoteStr($id, $table) .
'%\'');
627 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres)) {
629 $fieldConf =
$GLOBALS[
'TCA'][$table][
'columns'][$field][
'config'];
630 $allowedTables = $fieldConf[
'type'] ==
'group' ? $fieldConf[
'allowed'] : $fieldConf[
'foreign_table'];
633 $dbAnalysis->start($row[$field], $allowedTables, $fieldConf[
'MM'], $row[
'uid'], $table, $fieldConf);
634 foreach ($dbAnalysis->itemArray as $tempArr) {
635 if ($tempArr[
'table'] == $searchTable && $tempArr[
'id'] == $id) {
636 $theRecordList[] = array(
'table' => $table,
'uid' => $row[
'uid'],
'field' => $field,
'pid' => $row[
'pid']);
640 $GLOBALS[
'TYPO3_DB']->sql_free_result($mres);
642 return $theRecordList;
656 $theRecordList = array();
657 foreach ($fileFields as $info) {
660 $mres =
$GLOBALS[
'TYPO3_DB']->exec_SELECTquery(
'uid,pid,' .
$GLOBALS[
'TCA'][$table][
'ctrl'][
'label'] .
',' . $field, $table, $field .
' LIKE \'%' .
$GLOBALS[
'TYPO3_DB']->quoteStr($filename, $table) .
'%\'');
661 while ($row =
$GLOBALS[
'TYPO3_DB']->sql_fetch_assoc($mres)) {
664 $tempArr = explode(
',', trim($row[$field]));
665 foreach ($tempArr as $file) {
667 if ($file == $filename) {
668 $theRecordList[] = array(
'table' => $table,
'uid' => $row[
'uid'],
'field' => $field,
'pid' => $row[
'pid']);
672 $GLOBALS[
'TYPO3_DB']->sql_free_result($mres);
674 return $theRecordList;
whereIsFileReferenced($uploadfolder, $filename)
static skinImg($backPath, $src, $wHattribs='', $outputMode=0)
fixLostRecord($table, $uid)
getFileFields($uploadfolder)
static makeInstance($className)
static getRecordTitle($table, $row, $prep=FALSE, $forceResult=TRUE)
static getSpriteIconForRecord($table, array $row, array $options=array())
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren't numeric.
static getCommonSelectFields($table, $prefix='', $fields=array())
genTree_records($theID, $depthData, $table='', $versions=FALSE)
genTree($theID, $depthData, $versions=FALSE)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
static deleteClause($table, $tableAlias='')
getDBFields($theSearchTable)