source: trunk/Modules/News/Import/Vismo.php

Last change on this file was 938, checked in by chronos, 2 years ago
  • Fixed: Not working news import due to PHP SSL bug.
  • Added: News import from zdechov.net site.
File size: 1.3 KB
Line 
1<?php
2
3class NewsSourceVismo extends NewsSource
4{
5
6 function Import(): string
7 {
8 $Output = parent::Import();
9 $Content = file_get_contents_curl($this->URL);
10
11 $BlockStart = '<h2 class="cvi text-to-speech">Přehled dokumentů</h2>';
12 $BlockEnd = '</ul>';
13 $Content = GetTextBetween($Content, $BlockStart, $BlockEnd);
14 if ($Content == '')
15 {
16 $Output .= 'Main block not isolated.</br>';
17 return $Output;
18 }
19
20 $ItemStart = '<li>';
21 $ItemEnd = "</li>";
22 while (strpos($Content, $ItemStart) !== false)
23 {
24 $Item = GetTextBetween($Content, $ItemStart, $ItemEnd);
25 $NewsItem = new NewsItem();
26
27 $NewsItem->Link = GetUrlBase($this->URL).html_entity_decode(GetTextBetween($Item, '<a href="', '">'));
28 $NewsItem->Title = html_entity_decode(GetTextBetween($Item, '', '</a>'));
29 $Date = GetTextBetween($Item, '<span>(', ')</span>');
30 $NewsItem->Date = HumanDateToTime($Date);
31 $NewsItem->Category = $this->Category;
32 if (strpos($Item, '<div>') !== false)
33 {
34 $NewsItem->Content = html_entity_decode(GetTextBetween($Item, '<div>', '</div>'));
35 }
36
37 $NewsItem->Author = 'Automat';
38 $NewsItem->Database = $this->Database;
39 $this->NewsItems[] = $NewsItem;
40 }
41 return $Output;
42 }
43}
Note: See TracBrowser for help on using the repository browser.