00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00074 class tx_dbal_handler_openoffice extends t3lib_sqlengine {
00075
00076 var $config = array();
00077 var $pObj;
00078
00079 var $spreadSheetFiles = '';
00080 var $unzip;
00081
00089 function init($config, &$pObj) {
00090 $this->config = $config['config'];
00091
00092 if (t3lib_extMgm::isLoaded('libunzipped')) {
00093
00094
00095 require_once(t3lib_extMgm::extPath('libunzipped').'class.tx_libunzipped.php');
00096
00097
00098 $sxc_file = t3lib_div::getFileAbsFileName($this->config['sxc_file']);
00099 if (@is_file($sxc_file)) {
00100
00101
00102 $this->unzip = t3lib_div::makeInstance('tx_libunzipped');
00103 $this->spreadSheetFiles = $this->unzip->init($sxc_file);
00104
00105 if (is_array($this->spreadSheetFiles)) {
00106 return TRUE;
00107 } else $this->errorStatus = 'Spreadsheet could not be unzipped...?';
00108 } else $this->errorStatus = 'The Spreadsheet file "'.$sxc_file.'" was not found!';
00109 } else $this->errorStatus = 'This data handler needs the extension "tx_libunzipped" to be installed!';
00110
00111 return FALSE;
00112 }
00113
00120 function readDataSource($table) {
00121 if (!is_array($this->spreadSheetFiles)) {
00122 die('Spreadsheet Data Source FATAL ERROR: No spreadsheet file loaded. Init() must have failed!');
00123 }
00124
00125 $this->data[$table] = array();
00126
00127
00128 $content_xml = $this->unzip->getFileFromArchive('content.xml');
00129
00130
00131 $content_xml = str_replace('Felt A1','FELT A1',$content_xml);
00132
00133
00134 $this->unzip->putFileToArchive('content.xml', $content_xml['content']);
00135
00136
00137 $result = $this->unzip->compileZipFile('fileadmin/dbtest_output.sxc');
00138
00139 debug($result);
00140
00141 exit;
00142 }
00143
00150 function saveDataSource($table) {
00151 }
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00173 function admin_get_tables() {
00174
00175 $whichTables = array();
00176 return $whichTables;
00177 }
00178
00185 function admin_get_fields($tableName) {
00186 return array();
00187 }
00188
00195 function admin_get_keys($tableName) {
00196 return array();
00197 }
00198
00205 function admin_query($query) {
00206
00207 $parsedQuery = $this->parseSQL($query);
00208 $table = $parsedQuery['TABLE'];
00209
00210 if (is_array($parsedQuery)) {
00211
00212 switch($parsedQuery['type']) {
00213 case 'CREATETABLE':
00214 break;
00215 case 'ALTERTABLE':
00216 break;
00217 case 'DROPTABLE':
00218 break;
00219 default:
00220 $this->errorStatus = 'Query type "'.$parsedQuery['type'].'" was not supported!';
00221 break;
00222 }
00223
00224 } else $this->errorStatus = 'SQL parse error: '.$parsedQuery;
00225
00226 return FALSE;
00227 }
00228 }
00229
00230
00231 if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_openoffice.php']) {
00232 include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/dbal/handlers/class.tx_dbal_handler_openoffice.php']);
00233 }
00234 ?>