2021-03-17 19:30:47 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class PresidenciaPTBridge extends BridgeAbstract
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2021-03-17 19:30:47 +03:00
|
|
|
const NAME = 'Presidência da República Portuguesa';
|
|
|
|
const URI = 'https://www.presidencia.pt';
|
2021-05-09 22:22:10 +03:00
|
|
|
const DESCRIPTION = 'Presidência da República Portuguesa';
|
2021-03-17 19:30:47 +03:00
|
|
|
const MAINTAINER = 'somini';
|
|
|
|
const PARAMETERS = [
|
|
|
|
'Section' => [
|
|
|
|
'/atualidade/noticias' => [
|
|
|
|
'name' => 'Notícias',
|
2021-05-09 22:22:10 +03:00
|
|
|
'type' => 'checkbox',
|
|
|
|
'defaultValue' => 'checked',
|
2022-07-01 16:10:30 +03:00
|
|
|
],
|
2021-05-09 22:22:10 +03:00
|
|
|
'/atualidade/mensagens' => [
|
|
|
|
'name' => 'Mensagens',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'defaultValue' => 'checked',
|
2022-07-01 16:10:30 +03:00
|
|
|
],
|
2021-05-09 22:22:10 +03:00
|
|
|
'/atualidade/atividade-legislativa' => [
|
|
|
|
'name' => 'Atividade Legislativa',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'defaultValue' => 'checked',
|
2022-07-01 16:10:30 +03:00
|
|
|
],
|
2021-05-09 22:22:10 +03:00
|
|
|
'/atualidade/notas-informativas' => [
|
|
|
|
'name' => 'Notas Informativas',
|
|
|
|
'type' => 'checkbox',
|
2021-03-17 19:30:47 +03:00
|
|
|
'defaultValue' => 'checked',
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
|
|
|
]
|
2021-03-17 19:30:47 +03:00
|
|
|
];
|
|
|
|
|
2021-05-09 22:22:10 +03:00
|
|
|
const PT_MONTH_NAMES = [
|
2021-03-17 19:30:47 +03:00
|
|
|
'janeiro',
|
2021-05-09 22:22:10 +03:00
|
|
|
'fevereiro',
|
2021-03-17 19:30:47 +03:00
|
|
|
'março',
|
2022-07-01 16:10:30 +03:00
|
|
|
'abril',
|
|
|
|
'maio',
|
|
|
|
'junho',
|
|
|
|
'julho',
|
2021-05-09 22:22:10 +03:00
|
|
|
'agosto',
|
|
|
|
'setembro',
|
|
|
|
'outubro',
|
2022-07-01 16:10:30 +03:00
|
|
|
'novembro',
|
2021-05-09 22:22:10 +03:00
|
|
|
'dezembro'];
|
|
|
|
|
2021-03-17 19:30:47 +03:00
|
|
|
public function getIcon()
|
2021-05-09 22:22:10 +03:00
|
|
|
{
|
|
|
|
return 'https://www.presidencia.pt/Theme/favicon/apple-touch-icon.png';
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2021-03-17 19:30:47 +03:00
|
|
|
|
2021-05-09 22:22:10 +03:00
|
|
|
public function collectData()
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2021-05-09 22:22:10 +03:00
|
|
|
foreach (array_keys($this->getParameters()['Section']) as $k) {
|
|
|
|
Debug::log('Key: ' . var_export($k, true));
|
|
|
|
if ($this->getInput($k)) {
|
|
|
|
$html = getSimpleHTMLDOMCached($this->getURI() . $k);
|
2021-03-17 19:30:47 +03:00
|
|
|
|
2021-05-09 22:22:10 +03:00
|
|
|
foreach ($html->find('#atualidade-list article.card-block') as $element) {
|
|
|
|
$item = [];
|
2021-03-17 19:30:47 +03:00
|
|
|
|
2021-05-09 22:22:10 +03:00
|
|
|
$link = $element->find('a', 0);
|
2023-06-17 07:13:09 +03:00
|
|
|
$etitle = $element->find('.article-title', 0);
|
2023-06-26 18:52:32 +03:00
|
|
|
$edts = $element->find('.date', 0);
|
|
|
|
$edt = $edts->innertext;
|
2021-03-17 19:30:47 +03:00
|
|
|
|
2021-05-09 22:22:10 +03:00
|
|
|
$item['title'] = strip_tags($etitle->innertext);
|
|
|
|
$item['uri'] = self::URI . $link->href;
|
|
|
|
$item['description'] = $element;
|
|
|
|
$item['timestamp'] = str_ireplace(
|
|
|
|
array_map(function ($name) {
|
|
|
|
return ' de ' . $name . ' de ';
|
|
|
|
}, self::PT_MONTH_NAMES),
|
|
|
|
array_map(function ($num) {
|
|
|
|
return sprintf('-%02d-', $num);
|
|
|
|
}, range(1, sizeof(self::PT_MONTH_NAMES))),
|
2022-07-01 16:10:30 +03:00
|
|
|
$edt
|
|
|
|
);
|
|
|
|
|
2021-05-09 22:22:10 +03:00
|
|
|
$this->items[] = $item;
|
2021-03-17 19:30:47 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-17 19:30:47 +03:00
|
|
|
}
|