Cleanup: Updated copyright comments
[Packages/TYPO3.CMS.git] / typo3 / sysext / em / classes / parser / class.tx_em_parser_xmlparserfactory.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010-2011 Marcus Krause <marcus#exp2010@t3sec.info>
6 * Steffen Kamper <info@sk-typo3.de>
7 * All rights reserved
8 *
9 * This script is part of the TYPO3 project. The TYPO3 project is
10 * free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * The GNU General Public License can be found at
16 * http://www.gnu.org/copyleft/gpl.html.
17 *
18 * This script is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * This copyright notice MUST APPEAR in all copies of the script!
24 ***************************************************************/
25 /**
26 * class.tx_em_parser_xmlparserfactory.php
27 *
28 * Module: Extension manager - XML parser factory
29 *
30 * $Id: class.tx_em_parser_xmlparserfactory.php 1911 2010-02-21 14:50:40Z mkrause $
31 *
32 * @author Marcus Krause <marcus#exp2010@t3sec.info>
33 * @author Steffen Kamper <info@sk-typo3.de>
34 */
35
36 /**
37 * Factory for XML parsers.
38 *
39 * @author Marcus Krause <marcus#exp2010@t3sec.info>
40 * @author Steffen Kamper <info@sk-typo3.de>
41 *
42 * @since 2010-02-10
43 * @package TYPO3
44 * @subpackage EM
45 */
46 class tx_em_Parser_XmlParserFactory {
47
48 /**
49 * An array with instances of xml parsers.
50 * This member is set in the getParserInstance() function.
51 *
52 * @var array
53 */
54 static protected $instance = array();
55
56 /**
57 * Keeps array of all available parsers.
58 *
59 * TODO: This would better be moved to
60 * a global configuration array like
61 * $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS'].
62 * (might require EM to be moved in a sysext)
63 *
64 * @var array
65 */
66 static protected $parsers = array(
67 'extension' => array(
68 'tx_em_parser_extensionxmlpullparser' => 'class.tx_em_parser_extensionxmlpullparser.php',
69 'tx_em_parser_extensionxmlpushparser' => 'class.tx_em_parser_extensionxmlpushparser.php',
70 ),
71 'mirror' => array(
72 'tx_em_parser_mirrorxmlpullparser' => 'class.tx_em_parser_mirrorxmlpullparser.php',
73 'tx_em_parser_mirrorxmlpushparser' => 'class.tx_em_parser_mirrorxmlpushparser.php',
74 ),
75 );
76
77
78 /**
79 * Obtains a xml parser instance.
80 *
81 * This function will return an instance of a class that implements
82 * em_extensionxml_abstract_parser.
83 *
84 * TODO use autoload if possible (might require EM to be moved in a sysext)
85 *
86 * @access public
87 * @param string $parserType: type of parser, one of extension and mirror
88 * @param string $excludeClassNames: (optional) comma-separated list of class names
89 * @return em_extensionxml_abstract_parser an instance of an extension.xml parser
90 */
91 static public function getParserInstance($parserType, $excludeClassNames = '') {
92 if (!isset(self::$instance[$parserType]) || !is_object(self::$instance[$parserType]) || !empty($excludeClassNames)) {
93 // reset instance
94 self::$instance[$parserType] = $objParser = NULL;
95 foreach (self::$parsers[$parserType] as $className => $file) {
96 if (!t3lib_div::inList($excludeClassNames, $className)) {
97 //require_once(dirname(__FILE__) . '/' . $file);
98 $objParser = t3lib_div::makeInstance($className);
99 if ($objParser->isAvailable()) {
100 self::$instance[$parserType] = &$objParser;
101 break;
102 }
103 $objParser = NULL;
104 }
105 }
106 }
107 return self::$instance[$parserType];
108 }
109 }
110
111 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/parser/class.tx_em_parser_xmlparserfactory.php'])) {
112 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/parser/class.tx_em_parser_xmlparserfactory.php']);
113 }
114
115 ?>