TYPO3 API  SVNRelease
class.tx_em_parser_xmlabstractparser.php
Go to the documentation of this file.
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_parser_xmlabstractparser.php
00027  *
00028  * Module: Extension manager - Extension.xml abstract parser
00029  *
00030  * $Id: class.tx_em_parser_xmlabstractparser.php 1910 2010-02-21 14:31:07Z mkrause $
00031  *
00032  * @author  Marcus Krause <marcus#exp2010@t3sec.info>
00033  * @author  Steffen Kamper <info@sk-typo3.de>
00034  */
00035 
00036 /**
00037  * Abstract parser for EM related TYPO3 xml files.
00038  *
00039  * @author    Marcus Krause <marcus#exp2010@t3sec.info>
00040  * @author    Steffen Kamper <info@sk-typo3.de>
00041  *
00042  * @since      2010-02-09
00043  * @package  TYPO3
00044  * @subpackage  EM
00045  */
00046 abstract class tx_em_Parser_XmlAbstractParser {
00047 
00048 
00049     /**
00050      * Keeps XML parser instance.
00051      *
00052      * @var  mixed
00053      */
00054     protected $objXML;
00055 
00056     /**
00057      * Keeps name of required PHP extension
00058      * for this class to work properly.
00059      *
00060      * @var  string
00061      */
00062     protected $requiredPHPExt;
00063 
00064 
00065     /**
00066      * Method determines if a necessary PHP extension is available.
00067      *
00068      * Method tries to load the extension if necessary and possible.
00069      *
00070      * @access  public
00071      * @return  boolean  true, if PHP extension is available, otherwise false
00072      */
00073     public function isAvailable() {
00074         $isAvailable = TRUE;
00075         if (!extension_loaded($this->requiredPHPExt)) {
00076             $prefix = (PHP_SHLIB_SUFFIX === 'dll') ? 'php_' : '';
00077             if (!((bool) ini_get('enable_dl') && !(bool) ini_get('safe_mode') && function_exists('dl') && dl($prefix . $this->requiredPHPExt . PHP_SHLIB_SUFFIX))) {
00078                 $isAvailable = FALSE;
00079             }
00080         }
00081 
00082         return $isAvailable;
00083     }
00084 
00085     /**
00086      * Method parses an XML file.
00087      *
00088      * @access  public
00089      * @param   string  $file: GZIP stream resource
00090      * @return  void
00091      * @throws  tx_em_XmlException  in case of XML parser errors
00092      */
00093     abstract public function parseXML($file);
00094 
00095     /**
00096      * Method provides a wrapper for an exception call
00097      *
00098      * @access  protected
00099      * @param   string   $message  the exception message to throw
00100      * @param   integer $code  the exception code
00101      * @return  void
00102      */
00103     abstract protected function throwException($message = "", $code = 0);
00104 }
00105 
00106 if (defined('TYPO3_MODE') && isset($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/parser/class.tx_em_parser_xmlabstractparser.php'])) {
00107     include_once($GLOBALS['TYPO3_CONF_VARS'][TYPO3_MODE]['XCLASS']['typo3/sysext/em/classes/parser/class.tx_em_parser_xmlabstractparser.php']);
00108 }
00109 ?>