|
TYPO3 API
SVNRelease
|
00001 <?php 00002 /*************************************************************** 00003 * Copyright notice 00004 * 00005 * (c) 2010 Marcus Krause <marcus#exp2010@t3sec.info> 00006 * Steffen Kamper <info@sk-typo3.de> 00007 * All rights reserved 00008 * 00009 * This script is part of the TYPO3 project. The TYPO3 project is 00010 * free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * The GNU General Public License can be found at 00016 * http://www.gnu.org/copyleft/gpl.html. 00017 * 00018 * This script is distributed in the hope that it will be useful, 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00021 * GNU General Public License for more details. 00022 * 00023 * This copyright notice MUST APPEAR in all copies of the script! 00024 ***************************************************************/ 00025 /** 00026 * class.tx_em_import_mirrorlistimporter.php 00027 * 00028 * Module: Extension manager - Mirror list importer 00029 * 00030 * $Id: class.tx_em_import_mirrorlistimporter.php 1982 2010-03-09 06:29:55Z mkrause $ 00031 * 00032 * @author Marcus Krause <marcus#exp2010@t3sec.info> 00033 * @author Steffen Kamper <info@sk-typo3.de> 00034 */ 00035 00036 00037 /** 00038 * Importer object for mirror list. 00039 * 00040 * @author Marcus Krause <marcus#exp2010@t3sec.info> 00041 * @author Steffen Kamper <info@sk-typo3.de> 00042 * 00043 * @since 2010-02-10 00044 * @package TYPO3 00045 * @subpackage EM 00046 */ 00047 class tx_em_Import_MirrorListImporter implements SplObserver { 00048 00049 /** 00050 * Keeps instance of a XML parser. 00051 * 00052 * @var tx_em_Parser_MirrorXmlAbstractParser 00053 */ 00054 protected $parser; 00055 00056 /** 00057 * Keeps mirrors' details. 00058 * 00059 * @var array 00060 */ 00061 protected $arrTmpMirrors = array(); 00062 00063 00064 /** 00065 * Class constructor. 00066 * 00067 * Method retrieves and initializes extension XML parser instance. 00068 * 00069 * @access public 00070 * @return void 00071 * @throws tx_em_XmlException in case no valid parser instance is available 00072 */ 00073 function __construct() { 00074 // TODO catch parser exception 00075 $this->parser = tx_em_Parser_XmlParserFactory::getParserInstance('mirror'); 00076 if (is_object($this->parser)) { 00077 $this->parser->attach($this); 00078 } else { 00079 throw new tx_em_XmlException(get_class($this) . ': ' . 'No XML parser available.'); 00080 } 00081 } 00082 00083 /** 00084 * Method collects mirrors' details and returns instance of em_repository_mirrors 00085 * with retrieved details. 00086 * 00087 * @access public 00088 * @param string $localMirrorListFile bsolute path to (gzipped) local mirror list xml file 00089 * @return em_repository_mirrors 00090 */ 00091 public function getMirrors($localMirrorListFile) { 00092 $zlibStream = 'compress.zlib://'; 00093 00094 $this->parser->parseXML($zlibStream . $localMirrorListFile); 00095 $objRepositoryMirrors = t3lib_div::makeInstance('tx_em_Repository_Mirrors'); 00096 $objRepositoryMirrors->setMirrors($this->arrTmpMirrors); 00097 $this->arrTmpMirrors = array(); 00098 return $objRepositoryMirrors; 00099 } 00100 00101 /** 00102 * Method receives an update from a subject. 00103 * 00104 * @access public 00105 * @param SplSubject $subject a subject notifying this observer 00106 * @return void 00107 */ 00108 public function update(SplSubject $subject) { 00109 // TODO mirrorxml_abstract_parser 00110 if (is_subclass_of($subject, 'tx_em_Parser_XmlAbstractParser')) { 00111 $this->arrTmpMirrors[] = $subject->getAll(); 00112 } 00113 } 00114 } 00115 00116 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/import/class.tx_em_import_mirrorlistimporter.php'])) { 00117 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/import/class.tx_em_import_mirrorlistimporter.php']); 00118 } 00119 00120 ?>
1.8.0