19751174b972ed13c440dbdd2b7a13eed1e9e953
[Packages/TYPO3.CMS.git] / typo3 / sysext / em / classes / parser / class.tx_em_parser_xmlabstractparser.php
1 <?php
2 /***************************************************************
3 * Copyright notice
4 *
5 * (c) 2010 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_xmlabstractparser.php
27 *
28 * Module: Extension manager - Extension.xml abstract parser
29 *
30 * $Id: class.tx_em_parser_xmlabstractparser.php 1910 2010-02-21 14:31:07Z mkrause $
31 *
32 * @author Marcus Krause <marcus#exp2010@t3sec.info>
33 * @author Steffen Kamper <info@sk-typo3.de>
34 */
35
36 /**
37 * Abstract parser for EM related TYPO3 xml files.
38 *
39 * @author Marcus Krause <marcus#exp2010@t3sec.info>
40 * @author Steffen Kamper <info@sk-typo3.de>
41 *
42 * @since 2010-02-09
43 * @package TYPO3
44 * @subpackage EM
45 */
46 abstract class tx_em_Parser_XmlAbstractParser {
47
48
49 /**
50 * Keeps XML parser instance.
51 *
52 * @var mixed
53 */
54 protected $objXML;
55
56 /**
57 * Keeps name of required PHP extension
58 * for this class to work properly.
59 *
60 * @var string
61 */
62 protected $requiredPHPExt;
63
64
65 /**
66 * Method determines if a necessary PHP extension is available.
67 *
68 * Method tries to load the extension if necessary and possible.
69 *
70 * @access public
71 * @return boolean true, if PHP extension is available, otherwise false
72 */
73 public function isAvailable() {
74 $isAvailable = TRUE;
75 if (!extension_loaded($this->requiredPHPExt)) {
76 $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
77 if (!((bool) ini_get('enable_dl') && !(bool) ini_get('safe_mode') && function_exists('dl') && dl($prefix . $this->requiredPHPExt . PHP_SHLIB_SUFFIX))) {
78 $isAvailable = FALSE;
79 }
80 }
81
82 return $isAvailable;
83 }
84
85 /**
86 * Method parses an XML file.
87 *
88 * @access public
89 * @param string $file: GZIP stream resource
90 * @return void
91 * @throws tx_em_XmlException in case of XML parser errors
92 */
93 abstract public function parseXML($file);
94
95 /**
96 * Method provides a wrapper for an exception call
97 *
98 * @access protected
99 * @param string $message the exception message to throw
100 * @param integer $code the exception code
101 * @return void
102 */
103 abstract protected function throwException($message = "", $code = 0);
104 }
105
106 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/parser/class.tx_em_parser_xmlabstractparser.php'])) {
107 include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/parser/class.tx_em_parser_xmlabstractparser.php']);
108 }
109 ?>