Feature #23965 ยป EMinsert.diff
typo3/sysext/em/mod1/class.em_index.php (copie de travail) | ||
---|---|---|
} else {
|
||
$dataCol = $GLOBALS['TBE_TEMPLATE']->dfw($GLOBALS['LANG']->getLL('extInfoArray_exception'));
|
||
}
|
||
|
||
}
|
||
$lines[] = array($headerCol, $dataCol);
|
||
... | ... | |
return $content;
|
||
}
|
||
protected function getUpdateCheckbox($table, $theInsertCount, $tableExists, $checkboxValue) {
|
||
$result = '<tr>
|
||
<td><input type="checkbox" name="TYPO3_INSTALL[database_import][' . $table . ']" checked="checked" value="' . $checkboxValue . '" /></td>
|
||
<td><strong>' . $table . '</strong></td>
|
||
<td><img src="clear.gif" width="10" height="1" alt="" /></td>
|
||
<td nowrap="nowrap">' .
|
||
($theInsertCount ?
|
||
$GLOBALS['LANG']->getLL('checkDBupdates_rows') . ' ' . $theInsertCount
|
||
: '') .
|
||
'</td>
|
||
<td><img src="clear.gif" width="10" height="1" alt="" /></td>
|
||
<td nowrap="nowrap">' .
|
||
($tableExists ?
|
||
t3lib_iconWorks::getSpriteIcon('status-dialog-warning') .
|
||
$GLOBALS['LANG']->getLL('checkDBupdates_table_exists')
|
||
: '') .
|
||
'</td>
|
||
</tr>';
|
||
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.
|
||
... | ... | |
$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);
|
||
... | ... | |
}
|
||
} 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.= '<tr>
|
||
<td><input type="checkbox" name="TYPO3_INSTALL[database_import]['.$table.']" checked="checked" value="'.md5($definition).'" /></td>
|
||
<td><strong>'.$table.'</strong></td>
|
||
<td><img src="clear.gif" width="10" height="1" alt="" /></td>
|
||
<td nowrap="nowrap">' .
|
||
($insertCount[$table] ?
|
||
$GLOBALS['LANG']->getLL('checkDBupdates_rows') . ' ' . $insertCount[$table]
|
||
: '') .
|
||
'</td>
|
||
<td><img src="clear.gif" width="10" height="1" alt="" /></td>
|
||
<td nowrap="nowrap">' .
|
||
($exist ?
|
||
t3lib_iconWorks::getSpriteIcon('status-dialog-warning') .
|
||
$GLOBALS['LANG']->getLL('checkDBupdates_table_exists')
|
||
: '') .
|
||
'</td>
|
||
</tr>';
|
||
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 .= '
|
||
<br />
|
||
<h3>' . $GLOBALS['LANG']->getLL('checkDBupdates_import_static_data') . '</h3>
|
||
<table border="0" cellpadding="0" cellspacing="0">'.$out.'</table>
|
||
<table border="0" cellpadding="0" cellspacing="0">' . $out . '</table>
|
||
';
|
||
}
|
||
}
|
typo3/sysext/em/ext_autoload.php (copie de travail) | ||
---|---|---|
'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',
|
||
);
|
||
?>
|