Documentation TYPO3 par Ameos

class.tx_dbal_handler_openoffice.php

00001 <?php
00002 /***************************************************************
00003 *  Copyright notice
00004 *  
00005 *  (c) 2004 Kasper Skaarhoj (kasper@typo3.com)
00006 *  All rights reserved
00007 *
00008 *  This script is part of the TYPO3 project. The TYPO3 project is
00009 *  free software; you can redistribute it and/or modify
00010 *  it under the terms of the GNU General Public License as published by
00011 *  the Free Software Foundation; either version 2 of the License, or
00012 *  (at your option) any later version.
00013 *
00014 *  The GNU General Public License can be found at
00015 *  http://www.gnu.org/copyleft/gpl.html.
00016 *  A copy is found in the textfile GPL.txt and important notices to the license
00017 *  from the author is found in LICENSE.txt distributed with these scripts.
00018 *
00019 *
00020 *  This script is distributed in the hope that it will be useful,
00021 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023 *  GNU General Public License for more details.
00024 *
00025 *  This copyright notice MUST APPEAR in all copies of the script!
00026 ***************************************************************/
00074 class tx_dbal_handler_openoffice extends t3lib_sqlengine {
00075 
00076         var $config = array();
00077         var $pObj;      // Set from DBAL class.
00078 
00079         var $spreadSheetFiles = '';
00080         var $unzip;             // Object
00081 
00089         function init($config, &$pObj)  {
00090                 $this->config = $config['config'];
00091 
00092                 if (t3lib_extMgm::isLoaded('libunzipped'))      {
00093 
00094                                 // Include Unzip library:
00095                         require_once(t3lib_extMgm::extPath('libunzipped').'class.tx_libunzipped.php');
00096 
00097                                 // Find database file:
00098                         $sxc_file = t3lib_div::getFileAbsFileName($this->config['sxc_file']);
00099                         if (@is_file($sxc_file))        {
00100 
00101                                 // Initialize Unzip object:
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                                 // Read content.xml:
00128                 $content_xml = $this->unzip->getFileFromArchive('content.xml');
00129 
00130                         // Testing for writing back:
00131                 $content_xml = str_replace('Felt A1','FELT A1',$content_xml);
00132 
00133                         // Writing file back (to database)
00134                 $this->unzip->putFileToArchive('content.xml', $content_xml['content']);
00135 
00136                         // Writing ZIP content back to zip-archive file:
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          * SQL admin functions
00164          * (For use in the Install Tool and Extension Manager)
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                                 // Process query based on type:
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 ?>


Généré par TYPO3 Ameos avec  doxygen 1.4.6