|
Revision 45, 2.1 kB
(checked in by argh, 3 years ago)
|
Fixed check for PHP5-only support.
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
class patXMLPretty_Engine_Automatic extends patXMLPretty_Engine |
|---|
| 25 |
{ |
|---|
| 26 |
|
|---|
| 27 |
* Stores the name of the engine |
|---|
| 28 |
* |
|---|
| 29 |
* @access private |
|---|
| 30 |
* @var string |
|---|
| 31 |
*/ |
|---|
| 32 |
var $name = 'Automatic'; |
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
* Stores a reference to the selected parsing engine |
|---|
| 36 |
* once it has been loaded. |
|---|
| 37 |
* |
|---|
| 38 |
* @access private |
|---|
| 39 |
* @var patXMLPretty_Engine |
|---|
| 40 |
* @see getEngine() |
|---|
| 41 |
*/ |
|---|
| 42 |
var $engine = null; |
|---|
| 43 |
|
|---|
| 44 |
|
|---|
| 45 |
* Determines the engine to use, loads it and retrieves the |
|---|
| 46 |
* elements collection from it. |
|---|
| 47 |
* |
|---|
| 48 |
* Note: any options you set for this engine are passed on |
|---|
| 49 |
* to the target engine, so you can use this feature to set |
|---|
| 50 |
* any options you want the target engine to use. |
|---|
| 51 |
* |
|---|
| 52 |
* @access public |
|---|
| 53 |
* @param string |
|---|
| 54 |
* @return array|patError |
|---|
| 55 |
*/ |
|---|
| 56 |
function parse( $xmlSource ) |
|---|
| 57 |
{ |
|---|
| 58 |
$engine =& $this->getEngine(); |
|---|
| 59 |
if( patErrorManager::isError( $engine ) ) { |
|---|
| 60 |
return $engine; |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
$result = $engine->parse( $xmlSource ); |
|---|
| 64 |
return $result; |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
* Retrieves the engine object the automatic renderer |
|---|
| 69 |
* has selected depending on the available resources and |
|---|
| 70 |
* the current system. |
|---|
| 71 |
* |
|---|
| 72 |
* @access public |
|---|
| 73 |
* @return patXMLPretty_Engine|patError |
|---|
| 74 |
* @see |
|---|
| 75 |
*/ |
|---|
| 76 |
function &getEngine() |
|---|
| 77 |
{ |
|---|
| 78 |
if( is_object( $this->engine ) ) { |
|---|
| 79 |
return $this->engine; |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
$engineType = 'Unserializer'; |
|---|
| 83 |
if( substr( phpversion(), 0, 1 ) >= 5 ) { |
|---|
| 84 |
$engineType = 'DOM'; |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|
| 87 |
$engine =& $this->pretty->createEngine( $engineType, $this->options ); |
|---|
| 88 |
if( patErrorManager::isError( $engine ) ) { |
|---|
| 89 |
return $engine; |
|---|
| 90 |
} |
|---|
| 91 |
|
|---|
| 92 |
$this->engine =& $engine; |
|---|
| 93 |
return $engine; |
|---|
| 94 |
} |
|---|
| 95 |
} |
|---|
| 96 |
|
|---|
| 97 |
?> |
|---|