1
|
|
|
<?php |
2
|
|
|
/* |
3
|
|
|
* You may not change or alter any portion of this comment or credits |
4
|
|
|
* of supporting developers from this source code or any supporting source code |
5
|
|
|
* which is considered copyrighted (c) material of the original comment or credit authors. |
6
|
|
|
* |
7
|
|
|
* This program is distributed in the hope that it will be useful, |
8
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
9
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @copyright XOOPS Project https://xoops.org/ |
14
|
|
|
* @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
15
|
|
|
* @package |
16
|
|
|
* @since |
17
|
|
|
* @author XOOPS Development Team, Kazumi Ono (AKA onokazu) |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined'); |
21
|
|
|
require_once(XOOPS_ROOT_PATH . '/class/xml/saxparser.php'); |
22
|
|
|
require_once(XOOPS_ROOT_PATH . '/class/xml/xmltaghandler.php'); |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Class XoopsXmlRss2Parser |
26
|
|
|
*/ |
27
|
|
|
class XoopsXmlRss2Parser extends SaxParser |
28
|
|
|
{ |
29
|
|
|
public $_tempArr = []; |
30
|
|
|
public $_channelData = []; |
31
|
|
|
public $_imageData = []; |
32
|
|
|
public $_items = []; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @param $input |
36
|
|
|
*/ |
37
|
|
|
public function __construct($input) |
38
|
|
|
{ |
39
|
|
|
parent::__construct($input); |
40
|
|
|
$this->useUtfEncoding(); |
41
|
|
|
$this->addTagHandler(new RssChannelHandler()); |
42
|
|
|
$this->addTagHandler(new RssTitleHandler()); |
43
|
|
|
$this->addTagHandler(new RssLinkHandler()); |
44
|
|
|
$this->addTagHandler(new RssGeneratorHandler()); |
45
|
|
|
$this->addTagHandler(new RssDescriptionHandler()); |
46
|
|
|
$this->addTagHandler(new RssCopyrightHandler()); |
47
|
|
|
$this->addTagHandler(new RssNameHandler()); |
48
|
|
|
$this->addTagHandler(new RssManagingEditorHandler()); |
49
|
|
|
$this->addTagHandler(new RssLanguageHandler()); |
50
|
|
|
$this->addTagHandler(new RssLastBuildDateHandler()); |
51
|
|
|
$this->addTagHandler(new RssWebMasterHandler()); |
52
|
|
|
$this->addTagHandler(new RssImageHandler()); |
53
|
|
|
$this->addTagHandler(new RssUrlHandler()); |
54
|
|
|
$this->addTagHandler(new RssWidthHandler()); |
55
|
|
|
$this->addTagHandler(new RssHeightHandler()); |
56
|
|
|
$this->addTagHandler(new RssItemHandler()); |
57
|
|
|
$this->addTagHandler(new RssCategoryHandler()); |
58
|
|
|
$this->addTagHandler(new RssPubDateHandler()); |
59
|
|
|
$this->addTagHandler(new RssCommentsHandler()); |
60
|
|
|
$this->addTagHandler(new RssSourceHandler()); |
61
|
|
|
$this->addTagHandler(new RssAuthorHandler()); |
62
|
|
|
$this->addTagHandler(new RssGuidHandler()); |
63
|
|
|
$this->addTagHandler(new RssTextInputHandler()); |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @param $name |
68
|
|
|
* @param $value |
69
|
|
|
*/ |
70
|
|
|
public function setChannelData($name, &$value) |
71
|
|
|
{ |
72
|
|
|
if (!isset($this->_channelData[$name])) { |
73
|
|
|
$this->_channelData[$name] = & $value; |
74
|
|
|
} else { |
75
|
|
|
$this->_channelData[$name] .= $value; |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* @param null $name |
|
|
|
|
81
|
|
|
* |
82
|
|
|
* @return array|bool |
83
|
|
|
*/ |
84
|
|
|
public function getChannelData($name = null) |
85
|
|
|
{ |
86
|
|
|
if ($name !== null) { |
|
|
|
|
87
|
|
|
return $this->_channelData[$name] ?? false; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
return $this->_channelData; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
/** |
94
|
|
|
* @param $name |
95
|
|
|
* @param $value |
96
|
|
|
*/ |
97
|
|
|
public function setImageData($name, &$value) |
98
|
|
|
{ |
99
|
|
|
$this->_imageData[$name] = & $value; |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* @param null $name |
|
|
|
|
104
|
|
|
* |
105
|
|
|
* @return array|bool |
106
|
|
|
*/ |
107
|
|
|
public function &getImageData($name = null) |
108
|
|
|
{ |
109
|
|
|
if (isset($name)) { |
110
|
|
|
if (isset($this->_imageData[$name])) { |
111
|
|
|
return $this->_imageData[$name]; |
112
|
|
|
} |
113
|
|
|
$return = false; |
114
|
|
|
|
115
|
|
|
return $return; |
116
|
|
|
} |
117
|
|
|
|
118
|
|
|
return $this->_imageData; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* @param $itemarr |
123
|
|
|
*/ |
124
|
|
|
public function setItems(&$itemarr) |
125
|
|
|
{ |
126
|
|
|
$this->_items[] = & $itemarr; |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
/** |
130
|
|
|
* @return array |
131
|
|
|
*/ |
132
|
|
|
public function &getItems() |
133
|
|
|
{ |
134
|
|
|
return $this->_items; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
/** |
138
|
|
|
* @param $name |
139
|
|
|
* @param $value |
140
|
|
|
* @param string $delim |
141
|
|
|
*/ |
142
|
|
|
public function setTempArr($name, &$value, $delim = '') |
143
|
|
|
{ |
144
|
|
|
if (!isset($this->_tempArr[$name])) { |
145
|
|
|
$this->_tempArr[$name] = & $value; |
146
|
|
|
} else { |
147
|
|
|
$this->_tempArr[$name] .= $delim . $value; |
148
|
|
|
} |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* @return array |
153
|
|
|
*/ |
154
|
|
|
public function getTempArr() |
155
|
|
|
{ |
156
|
|
|
return $this->_tempArr; |
157
|
|
|
} |
158
|
|
|
|
159
|
|
|
public function resetTempArr() |
160
|
|
|
{ |
161
|
|
|
unset($this->_tempArr); |
162
|
|
|
$this->_tempArr = []; |
163
|
|
|
} |
164
|
|
|
} |
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Class RssChannelHandler |
168
|
|
|
*/ |
169
|
|
|
class RssChannelHandler extends XmlTagHandler |
170
|
|
|
{ |
171
|
|
|
/** |
172
|
|
|
* RssChannelHandler constructor. |
173
|
|
|
*/ |
174
|
|
|
public function __construct() {} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @return string |
178
|
|
|
*/ |
179
|
|
|
public function getName() |
180
|
|
|
{ |
181
|
|
|
return 'channel'; |
182
|
|
|
} |
183
|
|
|
} |
184
|
|
|
|
185
|
|
|
/** |
186
|
|
|
* Class RssTitleHandler |
187
|
|
|
*/ |
188
|
|
|
class RssTitleHandler extends XmlTagHandler |
189
|
|
|
{ |
190
|
|
|
/** |
191
|
|
|
* RssTitleHandler constructor. |
192
|
|
|
*/ |
193
|
|
|
public function __construct() {} |
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* @return string |
197
|
|
|
*/ |
198
|
|
|
public function getName() |
199
|
|
|
{ |
200
|
|
|
return 'title'; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* @param $parser |
205
|
|
|
* @param $data |
206
|
|
|
*/ |
207
|
|
|
public function handleCharacterData($parser, &$data) |
208
|
|
|
{ |
209
|
|
|
switch ($parser->getParentTag()) { |
210
|
|
|
case 'channel': |
211
|
|
|
$parser->setChannelData('title', $data); |
212
|
|
|
break; |
213
|
|
|
case 'image': |
214
|
|
|
$parser->setImageData('title', $data); |
215
|
|
|
break; |
216
|
|
|
case 'item': |
217
|
|
|
case 'textInput': |
218
|
|
|
$parser->setTempArr('title', $data); |
219
|
|
|
break; |
220
|
|
|
default: |
221
|
|
|
break; |
222
|
|
|
} |
223
|
|
|
} |
224
|
|
|
} |
225
|
|
|
|
226
|
|
|
/** |
227
|
|
|
* Class RssLinkHandler |
228
|
|
|
*/ |
229
|
|
|
class RssLinkHandler extends XmlTagHandler |
230
|
|
|
{ |
231
|
|
|
/** |
232
|
|
|
* RssLinkHandler constructor. |
233
|
|
|
*/ |
234
|
|
|
public function __construct() {} |
235
|
|
|
|
236
|
|
|
/** |
237
|
|
|
* @return string |
238
|
|
|
*/ |
239
|
|
|
public function getName() |
240
|
|
|
{ |
241
|
|
|
return 'link'; |
242
|
|
|
} |
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* @param $parser |
246
|
|
|
* @param $data |
247
|
|
|
*/ |
248
|
|
|
public function handleCharacterData($parser, &$data) |
249
|
|
|
{ |
250
|
|
|
switch ($parser->getParentTag()) { |
251
|
|
|
case 'channel': |
252
|
|
|
$parser->setChannelData('link', $data); |
253
|
|
|
break; |
254
|
|
|
case 'image': |
255
|
|
|
$parser->setImageData('link', $data); |
256
|
|
|
break; |
257
|
|
|
case 'item': |
258
|
|
|
case 'textInput': |
259
|
|
|
$parser->setTempArr('link', $data); |
260
|
|
|
break; |
261
|
|
|
default: |
262
|
|
|
break; |
263
|
|
|
} |
264
|
|
|
} |
265
|
|
|
} |
266
|
|
|
|
267
|
|
|
/** |
268
|
|
|
* Class RssDescriptionHandler |
269
|
|
|
*/ |
270
|
|
|
class RssDescriptionHandler extends XmlTagHandler |
271
|
|
|
{ |
272
|
|
|
/** |
273
|
|
|
* RssDescriptionHandler constructor. |
274
|
|
|
*/ |
275
|
|
|
public function __construct() {} |
276
|
|
|
|
277
|
|
|
/** |
278
|
|
|
* @return string |
279
|
|
|
*/ |
280
|
|
|
public function getName() |
281
|
|
|
{ |
282
|
|
|
return 'description'; |
283
|
|
|
} |
284
|
|
|
|
285
|
|
|
/** |
286
|
|
|
* @param $parser |
287
|
|
|
* @param $data |
288
|
|
|
*/ |
289
|
|
|
public function handleCharacterData($parser, &$data) |
290
|
|
|
{ |
291
|
|
|
switch ($parser->getParentTag()) { |
292
|
|
|
case 'channel': |
293
|
|
|
$parser->setChannelData('description', $data); |
294
|
|
|
break; |
295
|
|
|
case 'image': |
296
|
|
|
$parser->setImageData('description', $data); |
297
|
|
|
break; |
298
|
|
|
case 'item': |
299
|
|
|
case 'textInput': |
300
|
|
|
$parser->setTempArr('description', $data); |
301
|
|
|
break; |
302
|
|
|
default: |
303
|
|
|
break; |
304
|
|
|
} |
305
|
|
|
} |
306
|
|
|
} |
307
|
|
|
|
308
|
|
|
/** |
309
|
|
|
* Class RssGeneratorHandler |
310
|
|
|
*/ |
311
|
|
|
class RssGeneratorHandler extends XmlTagHandler |
312
|
|
|
{ |
313
|
|
|
/** |
314
|
|
|
* RssGeneratorHandler constructor. |
315
|
|
|
*/ |
316
|
|
|
public function __construct() {} |
317
|
|
|
|
318
|
|
|
/** |
319
|
|
|
* @return string |
320
|
|
|
*/ |
321
|
|
|
public function getName() |
322
|
|
|
{ |
323
|
|
|
return 'generator'; |
324
|
|
|
} |
325
|
|
|
|
326
|
|
|
/** |
327
|
|
|
* @param $parser |
328
|
|
|
* @param $data |
329
|
|
|
*/ |
330
|
|
|
public function handleCharacterData($parser, &$data) |
331
|
|
|
{ |
332
|
|
|
switch ($parser->getParentTag()) { |
333
|
|
|
case 'channel': |
334
|
|
|
$parser->setChannelData('generator', $data); |
335
|
|
|
break; |
336
|
|
|
default: |
337
|
|
|
break; |
338
|
|
|
} |
339
|
|
|
} |
340
|
|
|
} |
341
|
|
|
|
342
|
|
|
/** |
343
|
|
|
* Class RssCopyrightHandler |
344
|
|
|
*/ |
345
|
|
|
class RssCopyrightHandler extends XmlTagHandler |
346
|
|
|
{ |
347
|
|
|
/** |
348
|
|
|
* RssCopyrightHandler constructor. |
349
|
|
|
*/ |
350
|
|
|
public function __construct() {} |
351
|
|
|
|
352
|
|
|
/** |
353
|
|
|
* @return string |
354
|
|
|
*/ |
355
|
|
|
public function getName() |
356
|
|
|
{ |
357
|
|
|
return 'copyright'; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
/** |
361
|
|
|
* @param $parser |
362
|
|
|
* @param $data |
363
|
|
|
*/ |
364
|
|
|
public function handleCharacterData($parser, &$data) |
365
|
|
|
{ |
366
|
|
|
switch ($parser->getParentTag()) { |
367
|
|
|
case 'channel': |
368
|
|
|
$parser->setChannelData('copyright', $data); |
369
|
|
|
break; |
370
|
|
|
default: |
371
|
|
|
break; |
372
|
|
|
} |
373
|
|
|
} |
374
|
|
|
} |
375
|
|
|
|
376
|
|
|
/** |
377
|
|
|
* Class RssNameHandler |
378
|
|
|
*/ |
379
|
|
|
class RssNameHandler extends XmlTagHandler |
380
|
|
|
{ |
381
|
|
|
/** |
382
|
|
|
* RssNameHandler constructor. |
383
|
|
|
*/ |
384
|
|
|
public function __construct() {} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* @return string |
388
|
|
|
*/ |
389
|
|
|
public function getName() |
390
|
|
|
{ |
391
|
|
|
return 'name'; |
392
|
|
|
} |
393
|
|
|
|
394
|
|
|
/** |
395
|
|
|
* @param $parser |
396
|
|
|
* @param $data |
397
|
|
|
*/ |
398
|
|
|
public function handleCharacterData($parser, &$data) |
399
|
|
|
{ |
400
|
|
|
switch ($parser->getParentTag()) { |
401
|
|
|
case 'textInput': |
402
|
|
|
$parser->setTempArr('name', $data); |
403
|
|
|
break; |
404
|
|
|
default: |
405
|
|
|
break; |
406
|
|
|
} |
407
|
|
|
} |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
/** |
411
|
|
|
* Class RssManagingEditorHandler |
412
|
|
|
*/ |
413
|
|
|
class RssManagingEditorHandler extends XmlTagHandler |
414
|
|
|
{ |
415
|
|
|
/** |
416
|
|
|
* RssManagingEditorHandler constructor. |
417
|
|
|
*/ |
418
|
|
|
public function __construct() {} |
419
|
|
|
|
420
|
|
|
/** |
421
|
|
|
* @return string |
422
|
|
|
*/ |
423
|
|
|
public function getName() |
424
|
|
|
{ |
425
|
|
|
return 'managingEditor'; |
426
|
|
|
} |
427
|
|
|
|
428
|
|
|
/** |
429
|
|
|
* @param $parser |
430
|
|
|
* @param $data |
431
|
|
|
*/ |
432
|
|
|
public function handleCharacterData($parser, &$data) |
433
|
|
|
{ |
434
|
|
|
switch ($parser->getParentTag()) { |
435
|
|
|
case 'channel': |
436
|
|
|
$parser->setChannelData('editor', $data); |
437
|
|
|
break; |
438
|
|
|
default: |
439
|
|
|
break; |
440
|
|
|
} |
441
|
|
|
} |
442
|
|
|
} |
443
|
|
|
|
444
|
|
|
/** |
445
|
|
|
* Class RssLanguageHandler |
446
|
|
|
*/ |
447
|
|
|
class RssLanguageHandler extends XmlTagHandler |
448
|
|
|
{ |
449
|
|
|
/** |
450
|
|
|
* RssLanguageHandler constructor. |
451
|
|
|
*/ |
452
|
|
|
public function __construct() {} |
453
|
|
|
|
454
|
|
|
/** |
455
|
|
|
* @return string |
456
|
|
|
*/ |
457
|
|
|
public function getName() |
458
|
|
|
{ |
459
|
|
|
return 'language'; |
460
|
|
|
} |
461
|
|
|
|
462
|
|
|
/** |
463
|
|
|
* @param $parser |
464
|
|
|
* @param $data |
465
|
|
|
*/ |
466
|
|
|
public function handleCharacterData($parser, &$data) |
467
|
|
|
{ |
468
|
|
|
switch ($parser->getParentTag()) { |
469
|
|
|
case 'channel': |
470
|
|
|
$parser->setChannelData('language', $data); |
471
|
|
|
break; |
472
|
|
|
default: |
473
|
|
|
break; |
474
|
|
|
} |
475
|
|
|
} |
476
|
|
|
} |
477
|
|
|
|
478
|
|
|
/** |
479
|
|
|
* Class RssWebMasterHandler |
480
|
|
|
*/ |
481
|
|
|
class RssWebMasterHandler extends XmlTagHandler |
482
|
|
|
{ |
483
|
|
|
/** |
484
|
|
|
* RssWebMasterHandler constructor. |
485
|
|
|
*/ |
486
|
|
|
public function __construct() {} |
487
|
|
|
|
488
|
|
|
/** |
489
|
|
|
* @return string |
490
|
|
|
*/ |
491
|
|
|
public function getName() |
492
|
|
|
{ |
493
|
|
|
return 'webMaster'; |
494
|
|
|
} |
495
|
|
|
|
496
|
|
|
/** |
497
|
|
|
* @param $parser |
498
|
|
|
* @param $data |
499
|
|
|
*/ |
500
|
|
|
public function handleCharacterData($parser, &$data) |
501
|
|
|
{ |
502
|
|
|
switch ($parser->getParentTag()) { |
503
|
|
|
case 'channel': |
504
|
|
|
$parser->setChannelData('webmaster', $data); |
505
|
|
|
break; |
506
|
|
|
default: |
507
|
|
|
break; |
508
|
|
|
} |
509
|
|
|
} |
510
|
|
|
} |
511
|
|
|
|
512
|
|
|
/** |
513
|
|
|
* Class RssDocsHandler |
514
|
|
|
*/ |
515
|
|
|
class RssDocsHandler extends XmlTagHandler |
516
|
|
|
{ |
517
|
|
|
/** |
518
|
|
|
* RssDocsHandler constructor. |
519
|
|
|
*/ |
520
|
|
|
public function __construct() {} |
521
|
|
|
|
522
|
|
|
/** |
523
|
|
|
* @return string |
524
|
|
|
*/ |
525
|
|
|
public function getName() |
526
|
|
|
{ |
527
|
|
|
return 'docs'; |
528
|
|
|
} |
529
|
|
|
|
530
|
|
|
/** |
531
|
|
|
* @param $parser |
532
|
|
|
* @param $data |
533
|
|
|
*/ |
534
|
|
|
public function handleCharacterData($parser, &$data) |
535
|
|
|
{ |
536
|
|
|
switch ($parser->getParentTag()) { |
537
|
|
|
case 'channel': |
538
|
|
|
$parser->setChannelData('docs', $data); |
539
|
|
|
break; |
540
|
|
|
default: |
541
|
|
|
break; |
542
|
|
|
} |
543
|
|
|
} |
544
|
|
|
} |
545
|
|
|
|
546
|
|
|
/** |
547
|
|
|
* Class RssTtlHandler |
548
|
|
|
*/ |
549
|
|
|
class RssTtlHandler extends XmlTagHandler |
550
|
|
|
{ |
551
|
|
|
/** |
552
|
|
|
* RssTtlHandler constructor. |
553
|
|
|
*/ |
554
|
|
|
public function __construct() {} |
555
|
|
|
|
556
|
|
|
/** |
557
|
|
|
* @return string |
558
|
|
|
*/ |
559
|
|
|
public function getName() |
560
|
|
|
{ |
561
|
|
|
return 'ttl'; |
562
|
|
|
} |
563
|
|
|
|
564
|
|
|
/** |
565
|
|
|
* @param $parser |
566
|
|
|
* @param $data |
567
|
|
|
*/ |
568
|
|
|
public function handleCharacterData($parser, &$data) |
569
|
|
|
{ |
570
|
|
|
switch ($parser->getParentTag()) { |
571
|
|
|
case 'channel': |
572
|
|
|
$parser->setChannelData('ttl', $data); |
573
|
|
|
break; |
574
|
|
|
default: |
575
|
|
|
break; |
576
|
|
|
} |
577
|
|
|
} |
578
|
|
|
} |
579
|
|
|
|
580
|
|
|
/** |
581
|
|
|
* Class RssTextInputHandler |
582
|
|
|
*/ |
583
|
|
|
class RssTextInputHandler extends XmlTagHandler |
584
|
|
|
{ |
585
|
|
|
public function RssWebMasterHandler() {} |
586
|
|
|
|
587
|
|
|
/** |
588
|
|
|
* @return string |
589
|
|
|
*/ |
590
|
|
|
public function getName() |
591
|
|
|
{ |
592
|
|
|
return 'textInput'; |
593
|
|
|
} |
594
|
|
|
|
595
|
|
|
/** |
596
|
|
|
* @param $parser |
597
|
|
|
* @param $attributes |
598
|
|
|
*/ |
599
|
|
|
public function handleBeginElement($parser, &$attributes) |
600
|
|
|
{ |
601
|
|
|
$parser->resetTempArr(); |
602
|
|
|
} |
603
|
|
|
|
604
|
|
|
/** |
605
|
|
|
* @param $parser |
606
|
|
|
*/ |
607
|
|
|
public function handleEndElement($parser) |
608
|
|
|
{ |
609
|
|
|
$parser->setChannelData('textinput', $parser->getTempArr()); |
610
|
|
|
} |
611
|
|
|
} |
612
|
|
|
|
613
|
|
|
/** |
614
|
|
|
* Class RssLastBuildDateHandler |
615
|
|
|
*/ |
616
|
|
|
class RssLastBuildDateHandler extends XmlTagHandler |
617
|
|
|
{ |
618
|
|
|
/** |
619
|
|
|
* RssLastBuildDateHandler constructor. |
620
|
|
|
*/ |
621
|
|
|
public function __construct() {} |
622
|
|
|
|
623
|
|
|
/** |
624
|
|
|
* @return string |
625
|
|
|
*/ |
626
|
|
|
public function getName() |
627
|
|
|
{ |
628
|
|
|
return 'lastBuildDate'; |
629
|
|
|
} |
630
|
|
|
|
631
|
|
|
/** |
632
|
|
|
* @param $parser |
633
|
|
|
* @param $data |
634
|
|
|
*/ |
635
|
|
|
public function handleCharacterData($parser, &$data) |
636
|
|
|
{ |
637
|
|
|
switch ($parser->getParentTag()) { |
638
|
|
|
case 'channel': |
639
|
|
|
$parser->setChannelData('lastbuilddate', $data); |
640
|
|
|
break; |
641
|
|
|
default: |
642
|
|
|
break; |
643
|
|
|
} |
644
|
|
|
} |
645
|
|
|
} |
646
|
|
|
|
647
|
|
|
/** |
648
|
|
|
* Class RssImageHandler |
649
|
|
|
*/ |
650
|
|
|
class RssImageHandler extends XmlTagHandler |
651
|
|
|
{ |
652
|
|
|
/** |
653
|
|
|
* RssImageHandler constructor. |
654
|
|
|
*/ |
655
|
|
|
public function __construct() {} |
656
|
|
|
|
657
|
|
|
/** |
658
|
|
|
* @return string |
659
|
|
|
*/ |
660
|
|
|
public function getName() |
661
|
|
|
{ |
662
|
|
|
return 'image'; |
663
|
|
|
} |
664
|
|
|
} |
665
|
|
|
|
666
|
|
|
/** |
667
|
|
|
* Class RssUrlHandler |
668
|
|
|
*/ |
669
|
|
|
class RssUrlHandler extends XmlTagHandler |
670
|
|
|
{ |
671
|
|
|
/** |
672
|
|
|
* RssUrlHandler constructor. |
673
|
|
|
*/ |
674
|
|
|
public function __construct() {} |
675
|
|
|
|
676
|
|
|
/** |
677
|
|
|
* @return string |
678
|
|
|
*/ |
679
|
|
|
public function getName() |
680
|
|
|
{ |
681
|
|
|
return 'url'; |
682
|
|
|
} |
683
|
|
|
|
684
|
|
|
/** |
685
|
|
|
* @param $parser |
686
|
|
|
* @param $data |
687
|
|
|
*/ |
688
|
|
|
public function handleCharacterData($parser, &$data) |
689
|
|
|
{ |
690
|
|
|
if ($parser->getParentTag() === 'image') { |
691
|
|
|
$parser->setImageData('url', $data); |
692
|
|
|
} |
693
|
|
|
} |
694
|
|
|
} |
695
|
|
|
|
696
|
|
|
/** |
697
|
|
|
* Class RssWidthHandler |
698
|
|
|
*/ |
699
|
|
|
class RssWidthHandler extends XmlTagHandler |
700
|
|
|
{ |
701
|
|
|
/** |
702
|
|
|
* RssWidthHandler constructor. |
703
|
|
|
*/ |
704
|
|
|
public function __construct() {} |
705
|
|
|
|
706
|
|
|
/** |
707
|
|
|
* @return string |
708
|
|
|
*/ |
709
|
|
|
public function getName() |
710
|
|
|
{ |
711
|
|
|
return 'width'; |
712
|
|
|
} |
713
|
|
|
|
714
|
|
|
/** |
715
|
|
|
* @param $parser |
716
|
|
|
* @param $data |
717
|
|
|
*/ |
718
|
|
|
public function handleCharacterData($parser, &$data) |
719
|
|
|
{ |
720
|
|
|
if ($parser->getParentTag() === 'image') { |
721
|
|
|
$parser->setImageData('width', $data); |
722
|
|
|
} |
723
|
|
|
} |
724
|
|
|
} |
725
|
|
|
|
726
|
|
|
/** |
727
|
|
|
* Class RssHeightHandler |
728
|
|
|
*/ |
729
|
|
|
class RssHeightHandler extends XmlTagHandler |
730
|
|
|
{ |
731
|
|
|
/** |
732
|
|
|
* RssHeightHandler constructor. |
733
|
|
|
*/ |
734
|
|
|
public function __construct() {} |
735
|
|
|
|
736
|
|
|
/** |
737
|
|
|
* @return string |
738
|
|
|
*/ |
739
|
|
|
public function getName() |
740
|
|
|
{ |
741
|
|
|
return 'height'; |
742
|
|
|
} |
743
|
|
|
|
744
|
|
|
/** |
745
|
|
|
* @param $parser |
746
|
|
|
* @param $data |
747
|
|
|
*/ |
748
|
|
|
public function handleCharacterData($parser, &$data) |
749
|
|
|
{ |
750
|
|
|
if ($parser->getParentTag() === 'image') { |
751
|
|
|
$parser->setImageData('height', $data); |
752
|
|
|
} |
753
|
|
|
} |
754
|
|
|
} |
755
|
|
|
|
756
|
|
|
/** |
757
|
|
|
* Class RssItemHandler |
758
|
|
|
*/ |
759
|
|
|
class RssItemHandler extends XmlTagHandler |
760
|
|
|
{ |
761
|
|
|
/** |
762
|
|
|
* RssItemHandler constructor. |
763
|
|
|
*/ |
764
|
|
|
public function __construct() {} |
765
|
|
|
|
766
|
|
|
/** |
767
|
|
|
* @return string |
768
|
|
|
*/ |
769
|
|
|
public function getName() |
770
|
|
|
{ |
771
|
|
|
return 'item'; |
772
|
|
|
} |
773
|
|
|
|
774
|
|
|
/** |
775
|
|
|
* @param $parser |
776
|
|
|
* @param $attributes |
777
|
|
|
*/ |
778
|
|
|
public function handleBeginElement($parser, &$attributes) |
779
|
|
|
{ |
780
|
|
|
$parser->resetTempArr(); |
781
|
|
|
} |
782
|
|
|
|
783
|
|
|
/** |
784
|
|
|
* @param $parser |
785
|
|
|
*/ |
786
|
|
|
public function handleEndElement($parser) |
787
|
|
|
{ |
788
|
|
|
$items = $parser->getTempArr(); |
789
|
|
|
$parser->setItems($items); |
790
|
|
|
} |
791
|
|
|
} |
792
|
|
|
|
793
|
|
|
/** |
794
|
|
|
* Class RssCategoryHandler |
795
|
|
|
*/ |
796
|
|
|
class RssCategoryHandler extends XmlTagHandler |
797
|
|
|
{ |
798
|
|
|
/** |
799
|
|
|
* RssCategoryHandler constructor. |
800
|
|
|
*/ |
801
|
|
|
public function __construct() {} |
802
|
|
|
|
803
|
|
|
/** |
804
|
|
|
* @return string |
805
|
|
|
*/ |
806
|
|
|
public function getName() |
807
|
|
|
{ |
808
|
|
|
return 'category'; |
809
|
|
|
} |
810
|
|
|
|
811
|
|
|
/** |
812
|
|
|
* @param $parser |
813
|
|
|
* @param $data |
814
|
|
|
*/ |
815
|
|
|
public function handleCharacterData($parser, &$data) |
816
|
|
|
{ |
817
|
|
|
switch ($parser->getParentTag()) { |
818
|
|
|
case 'channel': |
819
|
|
|
$parser->setChannelData('category', $data); |
820
|
|
|
break; |
821
|
|
|
case 'item': |
822
|
|
|
$parser->setTempArr('category', $data, ', '); |
823
|
|
|
break; |
824
|
|
|
default: |
825
|
|
|
break; |
826
|
|
|
} |
827
|
|
|
} |
828
|
|
|
} |
829
|
|
|
|
830
|
|
|
/** |
831
|
|
|
* Class RssCommentsHandler |
832
|
|
|
*/ |
833
|
|
|
class RssCommentsHandler extends XmlTagHandler |
834
|
|
|
{ |
835
|
|
|
/** |
836
|
|
|
* RssCommentsHandler constructor. |
837
|
|
|
*/ |
838
|
|
|
public function __construct() {} |
839
|
|
|
|
840
|
|
|
/** |
841
|
|
|
* @return string |
842
|
|
|
*/ |
843
|
|
|
public function getName() |
844
|
|
|
{ |
845
|
|
|
return 'comments'; |
846
|
|
|
} |
847
|
|
|
|
848
|
|
|
/** |
849
|
|
|
* @param $parser |
850
|
|
|
* @param $data |
851
|
|
|
*/ |
852
|
|
|
public function handleCharacterData($parser, &$data) |
853
|
|
|
{ |
854
|
|
|
if ($parser->getParentTag() === 'item') { |
855
|
|
|
$parser->setTempArr('comments', $data); |
856
|
|
|
} |
857
|
|
|
} |
858
|
|
|
} |
859
|
|
|
|
860
|
|
|
/** |
861
|
|
|
* Class RssPubDateHandler |
862
|
|
|
*/ |
863
|
|
|
class RssPubDateHandler extends XmlTagHandler |
864
|
|
|
{ |
865
|
|
|
/** |
866
|
|
|
* RssPubDateHandler constructor. |
867
|
|
|
*/ |
868
|
|
|
public function __construct() {} |
869
|
|
|
|
870
|
|
|
/** |
871
|
|
|
* @return string |
872
|
|
|
*/ |
873
|
|
|
public function getName() |
874
|
|
|
{ |
875
|
|
|
return 'pubDate'; |
876
|
|
|
} |
877
|
|
|
|
878
|
|
|
/** |
879
|
|
|
* @param $parser |
880
|
|
|
* @param $data |
881
|
|
|
*/ |
882
|
|
|
public function handleCharacterData($parser, &$data) |
883
|
|
|
{ |
884
|
|
|
switch ($parser->getParentTag()) { |
885
|
|
|
case 'channel': |
886
|
|
|
$parser->setChannelData('pubdate', $data); |
887
|
|
|
break; |
888
|
|
|
case 'item': |
889
|
|
|
$parser->setTempArr('pubdate', $data); |
890
|
|
|
break; |
891
|
|
|
default: |
892
|
|
|
break; |
893
|
|
|
} |
894
|
|
|
} |
895
|
|
|
} |
896
|
|
|
|
897
|
|
|
/** |
898
|
|
|
* Class RssGuidHandler |
899
|
|
|
*/ |
900
|
|
|
class RssGuidHandler extends XmlTagHandler |
901
|
|
|
{ |
902
|
|
|
/** |
903
|
|
|
* RssGuidHandler constructor. |
904
|
|
|
*/ |
905
|
|
|
public function __construct() {} |
906
|
|
|
|
907
|
|
|
/** |
908
|
|
|
* @return string |
909
|
|
|
*/ |
910
|
|
|
public function getName() |
911
|
|
|
{ |
912
|
|
|
return 'guid'; |
913
|
|
|
} |
914
|
|
|
|
915
|
|
|
/** |
916
|
|
|
* @param $parser |
917
|
|
|
* @param $data |
918
|
|
|
*/ |
919
|
|
|
public function handleCharacterData($parser, &$data) |
920
|
|
|
{ |
921
|
|
|
if ($parser->getParentTag() === 'item') { |
922
|
|
|
$parser->setTempArr('guid', $data); |
923
|
|
|
} |
924
|
|
|
} |
925
|
|
|
} |
926
|
|
|
|
927
|
|
|
/** |
928
|
|
|
* Class RssAuthorHandler |
929
|
|
|
*/ |
930
|
|
|
class RssAuthorHandler extends XmlTagHandler |
931
|
|
|
{ |
932
|
|
|
public function RssGuidHandler() {} |
933
|
|
|
|
934
|
|
|
/** |
935
|
|
|
* @return string |
936
|
|
|
*/ |
937
|
|
|
public function getName() |
938
|
|
|
{ |
939
|
|
|
return 'author'; |
940
|
|
|
} |
941
|
|
|
|
942
|
|
|
/** |
943
|
|
|
* @param $parser |
944
|
|
|
* @param $data |
945
|
|
|
*/ |
946
|
|
|
public function handleCharacterData($parser, &$data) |
947
|
|
|
{ |
948
|
|
|
if ($parser->getParentTag() === 'item') { |
949
|
|
|
$parser->setTempArr('author', $data); |
950
|
|
|
} |
951
|
|
|
} |
952
|
|
|
} |
953
|
|
|
|
954
|
|
|
/** |
955
|
|
|
* Class RssSourceHandler |
956
|
|
|
*/ |
957
|
|
|
class RssSourceHandler extends XmlTagHandler |
958
|
|
|
{ |
959
|
|
|
/** |
960
|
|
|
* RssSourceHandler constructor. |
961
|
|
|
*/ |
962
|
|
|
public function __construct() {} |
963
|
|
|
|
964
|
|
|
/** |
965
|
|
|
* @return string |
966
|
|
|
*/ |
967
|
|
|
public function getName() |
968
|
|
|
{ |
969
|
|
|
return 'source'; |
970
|
|
|
} |
971
|
|
|
|
972
|
|
|
/** |
973
|
|
|
* @param $parser |
974
|
|
|
* @param $attributes |
975
|
|
|
*/ |
976
|
|
|
public function handleBeginElement($parser, &$attributes) |
977
|
|
|
{ |
978
|
|
|
if ($parser->getParentTag() === 'item') { |
979
|
|
|
$parser->setTempArr('source_url', $attributes['url']); |
980
|
|
|
} |
981
|
|
|
} |
982
|
|
|
|
983
|
|
|
/** |
984
|
|
|
* @param $parser |
985
|
|
|
* @param $data |
986
|
|
|
*/ |
987
|
|
|
public function handleCharacterData($parser, &$data) |
988
|
|
|
{ |
989
|
|
|
if ($parser->getParentTag() === 'item') { |
990
|
|
|
$parser->setTempArr('source', $data); |
991
|
|
|
} |
992
|
|
|
} |
993
|
|
|
} |
994
|
|
|
|