Index: typo3/sysext/em/mod1/class.em_index.php =================================================================== --- typo3/sysext/em/mod1/class.em_index.php (révision 9298) +++ typo3/sysext/em/mod1/class.em_index.php (copie de travail) @@ -3315,7 +3315,7 @@ } else { $dataCol = $GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('extInfoArray_exception')); } - + } $lines[] = array($headerCol, $dataCol); @@ -5507,6 +5507,28 @@ return $content; } + protected function getUpdateCheckbox($table, $theInsertCount, $tableExists, $checkboxValue) { + + $result = ' + + ' . $table . ' + + ' . + ($theInsertCount ? + $GLOBALS['LANG']->getLL('checkDBupdates_rows') . ' ' . $theInsertCount + : '') . + ' + + ' . + ($tableExists ? + t3lib_iconWorks::getSpriteIcon('status-dialog-warning') . + $GLOBALS['LANG']->getLL('checkDBupdates_table_exists') + : '') . + ' + '; + return $result; + } + /** * Validates the database according to extension requirements * Prints form for changes if any. If none, returns blank. If an update is ordered, empty is returned as well. @@ -5579,16 +5601,36 @@ $statements = $instObj->getStatementArray($fileContent,1); list($statements_table, $insertCount) = $instObj->getCreateTables($statements,1); - // Execute import of static table content: if (!$infoOnly && is_array($instObj->INSTALL['database_import'])) { // Traverse the tables foreach($instObj->INSTALL['database_import'] as $table => $md5str) { + $bCheckInsert = FALSE; if ($md5str == md5($statements_table[$table])) { - $GLOBALS['TYPO3_DB']->admin_query('DROP TABLE IF EXISTS '.$table); - $GLOBALS['TYPO3_DB']->admin_query($statements_table[$table]); + if ($statements_table[$table] != '') { + $GLOBALS['TYPO3_DB']->admin_query('DROP TABLE IF EXISTS '.$table); + $GLOBALS['TYPO3_DB']->admin_query($statements_table[$table]); + } + $bCheckInsert = TRUE; + } else if($md5str == md5($table)) { + if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/mod/tools/em/index.php']['checkDBinsert'])) { + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/mod/tools/em/index.php']['checkDBinsert'] as $classData) { + $hookObject = t3lib_div::getUserObj($classData); + if (!($hookObject instanceof em_index_checkDatabaseInsertsHook)) { + throw new UnexpectedValueException('$hookObject must implement interface em_index_checkDatabaseInsertsHook', 1285218476); + } + + /* @var $hookObject em_index_checkDatabaseInsertHook */ + $bCheckInsert = $hookObject->preProcessDatabaseInserts($extKey, $extInfo, $table, $instObj, $this); + if ($bCheckInsert) { + break; + } + } + } + } + if ($bCheckInsert) { if ($insertCount[$table]) { $statements_insert = $instObj->getTableInsertStatements($statements, $table); @@ -5600,36 +5642,54 @@ } } else { $whichTables = $instObj->getListOfTables(); + $insertedTables = array(); + $out = ''; + if (count($statements_table)) { - $out = ''; foreach($statements_table as $table => $definition) { $exist = isset($whichTables[$table]); - $dbStatus['static'][$table]['exists'] = $exist; $dbStatus['static'][$table]['count'] = $insertCount[$table]; + $insertedTables[$table] = 1; + $out .= $this->getUpdateCheckbox($table, $insertCount[$table], $exists, md5($definition)); + } + } + // add all those tables which have not been inside of a file named 'ext_tables.sql' + if (count($insertCount)) { + foreach ($insertCount as $table => $count) { + if ($insertedTables[$table]) { + continue; + } + $bCheckInsert = FALSE; + if (is_array($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/mod/tools/em/index.php']['checkDBinsert'])) { + foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/mod/tools/em/index.php']['checkDBinsert'] as $classData) { + $hookObject = t3lib_div::getUserObj($classData); - $out.= ' - - '.$table.' - - ' . - ($insertCount[$table] ? - $GLOBALS['LANG']->getLL('checkDBupdates_rows') . ' ' . $insertCount[$table] - : '') . - ' - - ' . - ($exist ? - t3lib_iconWorks::getSpriteIcon('status-dialog-warning') . - $GLOBALS['LANG']->getLL('checkDBupdates_table_exists') - : '') . - ' - '; + if (!($hookObject instanceof em_index_checkDatabaseInsertsHook)) { + throw new UnexpectedValueException('$hookObject must implement interface em_index_checkDatabaseInsertsHook', 1285218476); + } + + /* @var $hookObject em_index_checkDatabaseInsertHook */ + $bCheckInsert = $hookObject->preProcessDatabaseInserts($extKey, $extInfo, $table, $instObj, $this); + if ($bCheckInsert) { + break; + } + } + } + + if ($bCheckInsert) { + $exist = isset($whichTables[$table]); + $dbStatus['static'][$table]['exists'] = $exist; + $dbStatus['static'][$table]['count'] = $count; + $out .= $this->getUpdateCheckbox($table, $count, $exists, md5($table)); + } } - $content.= ' + } + if ($out != '') { + $content .= '

' . $GLOBALS['LANG']->getLL('checkDBupdates_import_static_data') . '

- '.$out.'
+ ' . $out . '
'; } } Index: typo3/sysext/em/ext_autoload.php =================================================================== --- typo3/sysext/em/ext_autoload.php (révision 9298) +++ typo3/sysext/em/ext_autoload.php (copie de travail) @@ -6,5 +6,6 @@ 'em_connection_exception' => $emClassesPath . 'exception/class.em_connection_exception.php', 'em_tasks_updateextensionlist' => $emClassesPath . 'tasks/class.em_tasks_updateextensionlist.php', 'em_index_checkdatabaseupdateshook' => $emInterfacesPath . 'interface.em_index_checkdatabaseupdateshook.php', + 'em_index_checkdatabaseinsertshook' => $emInterfacesPath . 'interface.em_index_checkdatabaseinsertshook.php', ); ?> \ No newline at end of file