1 | <?php |
||
8 | class OPMLParser |
||
9 | { |
||
10 | /** |
||
11 | * Encoding |
||
12 | */ |
||
13 | const ENCODING = 'UTF-8'; |
||
14 | |||
15 | /** |
||
16 | * Optional <head> elements |
||
17 | */ |
||
18 | const OPTIONAL_HEAD_ELEMENTS = [ |
||
19 | 'title', |
||
20 | 'dateCreated', |
||
21 | 'dateModified', |
||
22 | 'ownerName', |
||
23 | 'ownerEmail', |
||
24 | 'ownerId', |
||
25 | 'docs', |
||
26 | 'expansionState', |
||
27 | 'vertScrollState', |
||
28 | 'windowTop', |
||
29 | 'windowLeft', |
||
30 | 'windowBottom', |
||
31 | 'windowRight' |
||
32 | ]; |
||
33 | |||
34 | /** |
||
35 | * XML content |
||
36 | * @var string |
||
37 | */ |
||
38 | protected $xml; |
||
39 | |||
40 | /** |
||
41 | * Array containing the parsed XML |
||
42 | * @var array |
||
43 | */ |
||
44 | protected $result = []; |
||
45 | |||
46 | /** |
||
47 | * Constructor |
||
48 | * |
||
49 | * @param string $xml is the string we want to parse |
||
50 | * @throws Exceptions\ParseException |
||
51 | */ |
||
52 | public function __construct($xml) |
||
92 | |||
93 | /** |
||
94 | * Parse an XML object as an outline object and return corresponding array |
||
95 | * |
||
96 | * @param SimpleXMLElement $outline_xml the XML object we want to parse |
||
97 | * @return array corresponding to an outline and following format described above |
||
98 | */ |
||
99 | protected function parse_outline(SimpleXMLElement $outline_xml) |
||
117 | |||
118 | /** |
||
119 | * Return the parsed XML as an Array |
||
120 | * |
||
121 | * @return array |
||
122 | */ |
||
123 | public function getResult() |
||
127 | |||
128 | /** |
||
129 | * Validate the parsed XML array |
||
130 | * Note: The parser support parsing of OPMLs with missing content |
||
131 | * |
||
132 | * @return string|false Validated string on success, false on failure |
||
133 | */ |
||
134 | public function validate() |
||
143 | } |
||
144 |