0004877.patch

Administrator Admin, 2007-01-29 12:21

Download (4.77 KB)

View differences:

t3lib/class.t3lib_extmgm.php (Arbeitskopie)
1143 1143
				}
1144 1144
				if ($conf['ext_tables.php'])	{
1145 1145
					$cFiles['ext_tables'].=t3lib_extMgm::_makeIncludeHeader($key,$conf['ext_tables.php']);
1146
					$cFiles['ext_tables'].=t3lib_extMgm::watchTablesInclude($key, 'begin');
1146 1147
					$cFiles['ext_tables'].=trim(t3lib_div::getUrl($conf['ext_tables.php']));
1148
					$cFiles['ext_tables'].=t3lib_extMgm::watchTablesInclude($key, 'end');
1147 1149
				}
1148 1150
			}
1149 1151
		}
......
1175 1177
		}
1176 1178
		return $out;
1177 1179
	}
1180

  
1181
	/**
1182
	 * Returns the watchTable code for the compiled cache-files.
1183
	 *
1184
	 * @param	string		$key: The extension key
1185
	 * @param	string		$action: One of 'begin' or 'end'
1186
	 * @return	string		PHP code like "<?php t3lib_extMgm::watchTables('my_extension','begin'); ?>"
1187
	 */
1188
	function watchTablesInclude($key, $action) {
1189
		return "<?php t3lib_extMgm::watchTables('".addslashes($key)."','$action'); ?>";
1190
	}
1191

  
1192
	/**
1193
	 * watchTable handler to determine which table belongs to which extension key (and vice versa).
1194
	 * The $action 'begin' puts a new level on the TYPO3_WATCH_TABLES stack. If there was already an
1195
	 * element on the stack, the state for the previous extension has to be stored temporarily and updated
1196
	 * afterwards. This could happen if an extension includes anonther extension, what isn't a good style,
1197
	 * but could happen!
1198
	 * The $action 'end' searches the differences between the 'begin' call and the 'end' call and writes
1199
	 * the information, if any, to TYPO3_CONF_VARS/EXT/extTables and ~/extKeys.
1200
	 * extKeys: <key> -> array of tables
1201
	 * extTables: <table> -> string of extension key
1202
	 *
1203
	 * @param	string		$key: The extension key
1204
	 * @param	string		$action: One of 'begin' or 'end'
1205
	 * @return	void
1206
	 */
1207
	function watchTables($key, $action) {
1208
			// Initialize TYPO3_WATCH_TABLES and TYPO3_LOADED_TABLES as array:
1209
		if (!is_array($GLOBALS['TYPO3_WATCH_TABLES'])) {
1210
			$GLOBALS['TYPO3_WATCH_TABLES'] = array();
1211
			$GLOBALS['TYPO3_LOADED_TABLES'] = array();
1212
		}
1213
			// Get the current structure depth (normally this should be 0 or 1):
1214
		$structureDepth = count($GLOBALS['TYPO3_WATCH_TABLES']);
1215
			// Put a new level on the stack:
1216
		if ($action == 'begin') {
1217
				// If the previous extension included loads an extension (not good, but could happen):
1218
			if ($structureDepth > 0) {
1219
				$previousIndex = $structureDepth-1;
1220
				$GLOBALS['TYPO3_WATCH_TABLES'][$previousIndex]['tables'] = array_diff(
1221
					array_keys($GLOBALS['TCA']),
1222
					$GLOBALS['TYPO3_WATCH_TABLES'][$previousIndex]['tca']
1223
				);
1224
			}
1225
				// Put the current extension on the stack and store current tables in TCA:
1226
			$GLOBALS['TYPO3_WATCH_TABLES'][] = array(
1227
				'tca' => array_keys($GLOBALS['TCA']),
1228
				'tables' => array()
1229
			);
1230
			
1231
			// Remove the last element from the stack and process differences (tables, that have been set):
1232
		} elseif ($action == 'end') {
1233
				// If the previous extension included loads an extension (not good, but could happen):
1234
			if ($structureDepth > 1) {
1235
				$previousIndex = $structureDepth-2;
1236
				$GLOBALS['TYPO3_WATCH_TABLES'][$previousIndex]['tca'] = array_keys($GLOBALS['TCA']);
1237
			}
1238
				// Remove the current extension from the stack:
1239
			$currentLevel = array_pop($GLOBALS['TYPO3_WATCH_TABLES']);
1240
				// Get differences between 'begin' and 'end' call of this extension:
1241
			$tables = array_diff(
1242
				array_keys($GLOBALS['TCA']),
1243
				$currentLevel['tca']
1244
			);
1245
				// If this extension included a different extension, there is addional information - merge it to $tables:
1246
			if (count($currentLevel['tables'])) {
1247
				$tables = array_merge($currentLevel['tables'], $tables);
1248
			}
1249
				// If this extension has set tables at all, store them to TYPO3_LOADED_TABLES and TYPO3_LOADED_EXT:
1250
			if (count($tables)) {
1251
				sort($tables);
1252
				$GLOBALS['TYPO3_LOADED_EXT'][$key]['tables'] = implode(',', $tables);
1253
				foreach ($tables as $tableName) {
1254
					$GLOBALS['TYPO3_LOADED_TABLES'][$tableName] = $key;
1255
				}
1256
			}
1257
		}
1258
	}
1178 1259
}
1179 1260

  
1180 1261
?>
typo3/sysext/lowlevel/config/index.php (Arbeitskopie)
127 127
				1 => '$TCA (tables.php)',
128 128
				3 => '$TYPO3_LOADED_EXT',
129 129
				4 => '$TBE_STYLES',
130
				5 => 'TYPO3_LOADED_TABLES',
130 131
			),
131 132
			'regexsearch' => '',
132 133
			'fixedLgd' => ''
......
175 176
				$theVar = $GLOBALS['TBE_STYLES'];
176 177
				$arrayBrowser->varName = '$TBE_STYLES';
177 178
			break;
179
			case 5:
180
				$theVar = $GLOBALS['TYPO3_LOADED_TABLES'];
181
				$arrayBrowser->varName = '$TYPO3_LOADED_TABLES';
182
			break;
178 183
			default:
179 184
				$theVar = array();
180 185
			break;