TYPO3 CMS  TYPO3_6-2
ExtensionManagerTables.php
Go to the documentation of this file.
1 <?php
3 
23 
27  protected $title = 'Add the default Extension Manager database tables';
28 
32  protected $installToolSqlParser = NULL;
33 
37  protected function getInstallToolSqlParser() {
38  if ($this->installToolSqlParser === NULL) {
39  $this->installToolSqlParser = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Install\\Service\\SqlSchemaMigrationService');
40  }
41 
43  }
44 
50  protected function getUpdateStatements() {
51  $updateStatements = array();
52 
53  // Get all necessary statements for ext_tables.sql file
54  $rawDefinitions = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('extensionmanager') . '/ext_tables.sql');
55  $fieldDefinitionsFromFile = $this->getInstallToolSqlParser()->getFieldDefinitions_fileContent($rawDefinitions);
56  if (count($fieldDefinitionsFromFile)) {
57  $fieldDefinitionsFromCurrentDatabase = $this->getInstallToolSqlParser()->getFieldDefinitions_database();
58  $diff = $this->getInstallToolSqlParser()->getDatabaseExtra($fieldDefinitionsFromFile, $fieldDefinitionsFromCurrentDatabase);
59  $updateStatements = $this->getInstallToolSqlParser()->getUpdateSuggestions($diff);
60  }
61 
62  return $updateStatements;
63  }
64 
71  public function checkForUpdate(&$description) {
72  $result = FALSE;
73  $description = 'Creates necessary database tables and adds static tables for the new Extension Manager.';
74 
75  // First check necessary database update
76  $updateStatements = $this->getUpdateStatements();
77  if (empty($updateStatements)) {
78  // Check for repository database table
79  $databaseTables = $GLOBALS['TYPO3_DB']->admin_get_tables();
80  if (!isset($databaseTables['tx_extensionmanager_domain_model_repository'])) {
81  $result = TRUE;
82  } else {
83  // Get count of rows in repository database table
84  $count = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows('*', 'tx_extensionmanager_domain_model_repository');
85  if ($count === 0) {
86  $result = TRUE;
87  }
88  }
89  } else {
90  $result = TRUE;
91  }
92 
93  return $result;
94  }
95 
101  protected function hasError(&$customMessages) {
102  $result = FALSE;
103  if ($GLOBALS['TYPO3_DB']->sql_error()) {
104  $customMessages .= '<br /><br />SQL-ERROR: ' . htmlspecialchars($GLOBALS['TYPO3_DB']->sql_error());
105  $result = TRUE;
106  }
107 
108  return $result;
109  }
110 
118  public function performUpdate(array &$dbQueries, &$customMessages) {
119  $result = FALSE;
120 
121  // First perform all create, add and change queries
122  $updateStatements = $this->getUpdateStatements();
123  foreach ((array) $updateStatements['add'] as $string) {
124  $GLOBALS['TYPO3_DB']->admin_query($string);
125  $dbQueries[] = $string;
126  $result = ($result || $this->hasError($customMessages));
127  }
128  foreach ((array) $updateStatements['change'] as $string) {
129  $GLOBALS['TYPO3_DB']->admin_query($string);
130  $dbQueries[] = $string;
131  $result = ($result || $this->hasError($customMessages));
132  }
133  foreach ((array) $updateStatements['create_table'] as $string) {
134  $GLOBALS['TYPO3_DB']->admin_query($string);
135  $dbQueries[] = $string;
136  $result = ($result || $this->hasError($customMessages));
137  }
138 
139  // Perform statis import anyway
140  $rawDefinitions = \TYPO3\CMS\Core\Utility\GeneralUtility::getUrl(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('extensionmanager') . 'ext_tables_static+adt.sql');
141  $statements = $this->getInstallToolSqlParser()->getStatementarray($rawDefinitions, 1);
142  foreach ($statements as $statement) {
143  if (trim($statement) !== '') {
144  $GLOBALS['TYPO3_DB']->admin_query($statement);
145  $dbQueries[] = $statement;
146  $result = ($result || $this->hasError($customMessages));
147  }
148  }
149 
150  return !$result;
151  }
152 
153 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.
static getUrl($url, $includeHeader=0, $requestHeaders=FALSE, &$report=NULL)
if(!defined('TYPO3_MODE')) $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['t3lib/class.t3lib_userauth.php']['logoff_pre_processing'][]
performUpdate(array &$dbQueries, &$customMessages)