Revert "[RELEASE] Release of TYPO3 4.6.0alpha1"
[Packages/TYPO3.CMS.git] / t3lib / class.t3lib_admin.php
index 8fdd380..63e40b9 100644 (file)
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 /**
  *  This copyright notice MUST APPEAR in all copies of the script!
  ***************************************************************/
 /**
- * Contains a class for evaluation of database integrity according to $TCA
+ * Contains a class for evaluation of database integrity according to $GLOBALS['TCA']
  * Most of these functions are considered obsolete!
  *
  * Most of these functions are considered obsolete!
  *
- * $Id$
  * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
  * XHTML compliant
  *
  * Revised for TYPO3 3.6 July/2003 by Kasper Skårhøj
  * XHTML compliant
  *
@@ -231,8 +230,6 @@ class t3lib_admin {
         * @return      void
         */
        function genTree_records($theID, $depthData, $table = '', $versions = FALSE) {
         * @return      void
         */
        function genTree_records($theID, $depthData, $table = '', $versions = FALSE) {
-               global $TCA;
-
                if ($versions) {
                                // Select all records from table pointing to this page:
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                if ($versions) {
                                // Select all records from table pointing to this page:
                        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
@@ -295,7 +292,7 @@ class t3lib_admin {
 
 
                                // Select all versions of this record:
 
 
                                // Select all versions of this record:
-                       if ($this->genTree_includeVersions && $TCA[$table]['ctrl']['versioningWS']) {
+                       if ($this->genTree_includeVersions && $GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
                                $genHTML = $depthData . '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . $LN . '.gif', 'width="18" height="16"') . ' align="top" alt="" />';
 
                                $this->genTree_records($newID, $genHTML, $table, TRUE);
                                $genHTML = $depthData . '<img' . t3lib_iconWorks::skinImg($this->backPath, 'gfx/ol/' . $LN . '.gif', 'width="18" height="16"') . ' align="top" alt="" />';
 
                                $this->genTree_records($newID, $genHTML, $table, TRUE);
@@ -328,26 +325,25 @@ class t3lib_admin {
         * @return      void
         */
        function lostRecords($pid_list) {
         * @return      void
         */
        function lostRecords($pid_list) {
-               global $TCA;
                $this->lostPagesList = '';
                if ($pid_list) {
                $this->lostPagesList = '';
                if ($pid_list) {
-                       foreach ($TCA as $table => $tableConf) {
+                       foreach ($GLOBALS['TCA'] as $table => $tableConf) {
                                t3lib_div::loadTCA($table);
 
                                $pid_list_tmp = $pid_list;
                                t3lib_div::loadTCA($table);
 
                                $pid_list_tmp = $pid_list;
-                               if (!isset($TCA[$table]['ctrl']['versioningWS']) || !$TCA[$table]['ctrl']['versioningWS']) {
+                               if (!isset($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) || !$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
                                                // Remove preceding "-1," for non-versioned tables
                                        $pid_list_tmp = preg_replace('/^\-1,/', '', $pid_list_tmp);
                                }
 
                                $garbage = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                                                // Remove preceding "-1," for non-versioned tables
                                        $pid_list_tmp = preg_replace('/^\-1,/', '', $pid_list_tmp);
                                }
 
                                $garbage = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                                       'uid,pid,' . $TCA[$table]['ctrl']['label'],
+                                       'uid,pid,' . $GLOBALS['TCA'][$table]['ctrl']['label'],
                                        $table,
                                                'pid NOT IN (' . $pid_list_tmp . ')'
                                );
                                $lostIdList = array();
                                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($garbage)) {
                                        $table,
                                                'pid NOT IN (' . $pid_list_tmp . ')'
                                );
                                $lostIdList = array();
                                while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($garbage)) {
-                                       $this->lRecords[$table][$row['uid']] = array('uid' => $row['uid'], 'pid' => $row['pid'], 'title' => strip_tags($row[$TCA[$table]['ctrl']['label']]));
+                                       $this->lRecords[$table][$row['uid']] = array('uid' => $row['uid'], 'pid' => $row['pid'], 'title' => strip_tags($row[$GLOBALS['TCA'][$table]['ctrl']['label']]));
                                        $lostIdList[] = $row['uid'];
                                }
                                if ($table == 'pages') {
                                        $lostIdList[] = $row['uid'];
                                }
                                if ($table == 'pages') {
@@ -362,7 +358,7 @@ class t3lib_admin {
         *
         * @param       string          Database tablename
         * @param       integer         The uid of the record which will have the PID value set to 0 (zero)
         *
         * @param       string          Database tablename
         * @param       integer         The uid of the record which will have the PID value set to 0 (zero)
-        * @return      boolean         True if done.
+        * @return      boolean         TRUE if done.
         */
        function fixLostRecord($table, $uid) {
                if ($table && $GLOBALS['TCA'][$table] && $uid && is_array($this->lRecords[$table][$uid]) && $GLOBALS['BE_USER']->user['admin']) {
         */
        function fixLostRecord($table, $uid) {
                if ($table && $GLOBALS['TCA'][$table] && $uid && is_array($this->lRecords[$table][$uid]) && $GLOBALS['BE_USER']->user['admin']) {
@@ -382,21 +378,20 @@ class t3lib_admin {
        }
 
        /**
        }
 
        /**
-        * Counts records from $TCA-tables that ARE attached to an existing page.
+        * Counts records from $GLOBALS['TCA']-tables that ARE attached to an existing page.
         *
         * @param       string          list of pid's (page-record uid's). This list is probably made by genTree()
         *
         * @param       string          list of pid's (page-record uid's). This list is probably made by genTree()
-        * @return      array           an array with the number of records from all $TCA-tables that are attached to a PID in the pid-list.
+        * @return      array           an array with the number of records from all $GLOBALS['TCA']-tables that are attached to a PID in the pid-list.
         */
        function countRecords($pid_list) {
         */
        function countRecords($pid_list) {
-               global $TCA;
                $list = array();
                $list_n = array();
                if ($pid_list) {
                $list = array();
                $list_n = array();
                if ($pid_list) {
-                       foreach ($TCA as $table => $tableConf) {
+                       foreach ($GLOBALS['TCA'] as $table => $tableConf) {
                                t3lib_div::loadTCA($table);
 
                                $pid_list_tmp = $pid_list;
                                t3lib_div::loadTCA($table);
 
                                $pid_list_tmp = $pid_list;
-                               if (!isset($TCA[$table]['ctrl']['versioningWS']) || !$TCA[$table]['ctrl']['versioningWS']) {
+                               if (!isset($GLOBALS['TCA'][$table]['ctrl']['versioningWS']) || !$GLOBALS['TCA'][$table]['ctrl']['versioningWS']) {
                                                // Remove preceding "-1," for non-versioned tables
                                        $pid_list_tmp = preg_replace('/^\-1,/', '', $pid_list_tmp);
                                }
                                                // Remove preceding "-1," for non-versioned tables
                                        $pid_list_tmp = preg_replace('/^\-1,/', '', $pid_list_tmp);
                                }
@@ -422,11 +417,10 @@ class t3lib_admin {
         * @return      array           An array with all fields listed that somehow are references to other records (foreign-keys) or files
         */
        function getGroupFields($mode) {
         * @return      array           An array with all fields listed that somehow are references to other records (foreign-keys) or files
         */
        function getGroupFields($mode) {
-               global $TCA;
                $result = array();
                $result = array();
-               foreach ($TCA as $table => $tableConf) {
+               foreach ($GLOBALS['TCA'] as $table => $tableConf) {
                        t3lib_div::loadTCA($table);
                        t3lib_div::loadTCA($table);
-                       $cols = $TCA[$table]['columns'];
+                       $cols = $GLOBALS['TCA'][$table]['columns'];
                        foreach ($cols as $field => $config) {
                                if ($config['config']['type'] == 'group') {
                                        if (
                        foreach ($cols as $field => $config) {
                                if ($config['config']['type'] == 'group') {
                                        if (
@@ -454,11 +448,10 @@ class t3lib_admin {
         * @return      array           An array with all fields listed that have references to files in the $uploadfolder
         */
        function getFileFields($uploadfolder) {
         * @return      array           An array with all fields listed that have references to files in the $uploadfolder
         */
        function getFileFields($uploadfolder) {
-               global $TCA;
                $result = array();
                $result = array();
-               foreach ($TCA as $table => $tableConf) {
+               foreach ($GLOBALS['TCA'] as $table => $tableConf) {
                        t3lib_div::loadTCA($table);
                        t3lib_div::loadTCA($table);
-                       $cols = $TCA[$table]['columns'];
+                       $cols = $GLOBALS['TCA'][$table]['columns'];
                        foreach ($cols as $field => $config) {
                                if ($config['config']['type'] == 'group' && $config['config']['internal_type'] == 'file' && $config['config']['uploadfolder'] == $uploadfolder) {
                                        $result[] = array($table, $field);
                        foreach ($cols as $field => $config) {
                                if ($config['config']['type'] == 'group' && $config['config']['internal_type'] == 'file' && $config['config']['uploadfolder'] == $uploadfolder) {
                                        $result[] = array($table, $field);
@@ -469,18 +462,17 @@ class t3lib_admin {
        }
 
        /**
        }
 
        /**
-        * Returns an array with arrays of table/field pairs which are allowed to hold references to the input table name - according to $TCA
+        * Returns an array with arrays of table/field pairs which are allowed to hold references to the input table name - according to $GLOBALS['TCA']
         *
         * @param       string          Table name
         * @return      array
         */
        function getDBFields($theSearchTable) {
         *
         * @param       string          Table name
         * @return      array
         */
        function getDBFields($theSearchTable) {
-               global $TCA;
                $result = array();
                $result = array();
-               reset($TCA);
-               foreach ($TCA as $table => $tableConf) {
+               reset($GLOBALS['TCA']);
+               foreach ($GLOBALS['TCA'] as $table => $tableConf) {
                        t3lib_div::loadTCA($table);
                        t3lib_div::loadTCA($table);
-                       $cols = $TCA[$table]['columns'];
+                       $cols = $GLOBALS['TCA'][$table]['columns'];
                        foreach ($cols as $field => $config) {
                                if ($config['config']['type'] == 'group' && $config['config']['internal_type'] == 'db') {
                                        if (trim($config['config']['allowed']) == '*' || strstr($config['config']['allowed'], $theSearchTable)) {
                        foreach ($cols as $field => $config) {
                                if ($config['config']['type'] == 'group' && $config['config']['internal_type'] == 'db') {
                                        if (trim($config['config']['allowed']) == '*' || strstr($config['config']['allowed'], $theSearchTable)) {
@@ -502,10 +494,9 @@ class t3lib_admin {
         * @see getGroupFields()
         */
        function selectNonEmptyRecordsWithFkeys($fkey_arrays) {
         * @see getGroupFields()
         */
        function selectNonEmptyRecordsWithFkeys($fkey_arrays) {
-               global $TCA;
                if (is_array($fkey_arrays)) {
                        foreach ($fkey_arrays as $table => $field_list) {
                if (is_array($fkey_arrays)) {
                        foreach ($fkey_arrays as $table => $field_list) {
-                               if ($TCA[$table] && trim($field_list)) {
+                               if ($GLOBALS['TCA'][$table] && trim($field_list)) {
                                        t3lib_div::loadTCA($table);
                                        $fieldArr = explode(',', $field_list);
 
                                        t3lib_div::loadTCA($table);
                                        $fieldArr = explode(',', $field_list);
 
@@ -534,7 +525,7 @@ class t3lib_admin {
                                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
                                                foreach ($fieldArr as $field) {
                                                        if (trim($row[$field])) {
                                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
                                                foreach ($fieldArr as $field) {
                                                        if (trim($row[$field])) {
-                                                               $fieldConf = $TCA[$table]['columns'][$field]['config'];
+                                                               $fieldConf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
                                                                if ($fieldConf['type'] == 'group') {
                                                                        if ($fieldConf['internal_type'] == 'file') {
                                                                                        // files...
                                                                if ($fieldConf['type'] == 'group') {
                                                                        if ($fieldConf['internal_type'] == 'file') {
                                                                                        // files...
@@ -673,9 +664,9 @@ class t3lib_admin {
         * @return      string          HTML Error message
         */
        function testDBRefs($theArray) {
         * @return      string          HTML Error message
         */
        function testDBRefs($theArray) {
-               global $TCA;
+               $result = '';
                foreach ($theArray as $table => $dbArr) {
                foreach ($theArray as $table => $dbArr) {
-                       if ($TCA[$table]) {
+                       if ($GLOBALS['TCA'][$table]) {
                                $idlist = array_keys($dbArr);
 
                                $theList = implode(',', $idlist);
                                $idlist = array_keys($dbArr);
 
                                $theList = implode(',', $idlist);
@@ -707,7 +698,6 @@ class t3lib_admin {
         * @return      array           Array with other arrays containing information about where references was found
         */
        function whereIsRecordReferenced($searchTable, $id) {
         * @return      array           Array with other arrays containing information about where references was found
         */
        function whereIsRecordReferenced($searchTable, $id) {
-               global $TCA;
                $fileFields = $this->getDBFields($searchTable); // Gets tables / Fields that reference to files...
                $theRecordList = array();
                foreach ($fileFields as $info) {
                $fileFields = $this->getDBFields($searchTable); // Gets tables / Fields that reference to files...
                $theRecordList = array();
                foreach ($fileFields as $info) {
@@ -715,13 +705,13 @@ class t3lib_admin {
                        $field = $info[1];
                        t3lib_div::loadTCA($table);
                        $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                        $field = $info[1];
                        t3lib_div::loadTCA($table);
                        $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               'uid,pid,' . $TCA[$table]['ctrl']['label'] . ',' . $field,
+                               'uid,pid,' . $GLOBALS['TCA'][$table]['ctrl']['label'] . ',' . $field,
                                $table,
                                        $field . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($id, $table) . '%\''
                        );
                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
                                        // Now this is the field, where the reference COULD come from. But we're not garanteed, so we must carefully examine the data.
                                $table,
                                        $field . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($id, $table) . '%\''
                        );
                        while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($mres)) {
                                        // Now this is the field, where the reference COULD come from. But we're not garanteed, so we must carefully examine the data.
-                               $fieldConf = $TCA[$table]['columns'][$field]['config'];
+                               $fieldConf = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
                                $allowedTables = ($fieldConf['type'] == 'group') ? $fieldConf['allowed'] : $fieldConf['foreign_table'];
                                /** @var $dbAnalysis t3lib_loadDBGroup */
                                $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
                                $allowedTables = ($fieldConf['type'] == 'group') ? $fieldConf['allowed'] : $fieldConf['foreign_table'];
                                /** @var $dbAnalysis t3lib_loadDBGroup */
                                $dbAnalysis = t3lib_div::makeInstance('t3lib_loadDBGroup');
@@ -745,14 +735,13 @@ class t3lib_admin {
         * @return      array           Array with other arrays containing information about where references was found
         */
        function whereIsFileReferenced($uploadfolder, $filename) {
         * @return      array           Array with other arrays containing information about where references was found
         */
        function whereIsFileReferenced($uploadfolder, $filename) {
-               global $TCA;
                $fileFields = $this->getFileFields($uploadfolder); // Gets tables / Fields that reference to files...
                $theRecordList = array();
                foreach ($fileFields as $info) {
                        $table = $info[0];
                        $field = $info[1];
                        $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
                $fileFields = $this->getFileFields($uploadfolder); // Gets tables / Fields that reference to files...
                $theRecordList = array();
                foreach ($fileFields as $info) {
                        $table = $info[0];
                        $field = $info[1];
                        $mres = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
-                               'uid,pid,' . $TCA[$table]['ctrl']['label'] . ',' . $field,
+                               'uid,pid,' . $GLOBALS['TCA'][$table]['ctrl']['label'] . ',' . $field,
                                $table,
                                        $field . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($filename, $table) . '%\''
                        );
                                $table,
                                        $field . ' LIKE \'%' . $GLOBALS['TYPO3_DB']->quoteStr($filename, $table) . '%\''
                        );