2021-03-17 19:30:47 +03:00
|
|
|
<?php
|
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
class PresidenciaPTBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'Presidência da República Portuguesa';
|
|
|
|
const URI = 'https://www.presidencia.pt';
|
|
|
|
const DESCRIPTION = 'Presidência da República Portuguesa';
|
|
|
|
const MAINTAINER = 'somini';
|
|
|
|
const PARAMETERS = [
|
|
|
|
'Section' => [
|
|
|
|
'/atualidade/noticias' => [
|
|
|
|
'name' => 'Notícias',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'defaultValue' => 'checked',
|
|
|
|
],
|
|
|
|
'/atualidade/mensagens' => [
|
|
|
|
'name' => 'Mensagens',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'defaultValue' => 'checked',
|
|
|
|
],
|
|
|
|
'/atualidade/atividade-legislativa' => [
|
|
|
|
'name' => 'Atividade Legislativa',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'defaultValue' => 'checked',
|
|
|
|
],
|
|
|
|
'/atualidade/notas-informativas' => [
|
|
|
|
'name' => 'Notas Informativas',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'defaultValue' => 'checked',
|
|
|
|
]
|
|
|
|
]
|
|
|
|
];
|
2021-03-17 19:30:47 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
const PT_MONTH_NAMES = [
|
|
|
|
'janeiro',
|
|
|
|
'fevereiro',
|
|
|
|
'março',
|
|
|
|
'abril',
|
|
|
|
'maio',
|
|
|
|
'junho',
|
|
|
|
'julho',
|
|
|
|
'agosto',
|
|
|
|
'setembro',
|
|
|
|
'outubro',
|
|
|
|
'novembro',
|
|
|
|
'dezembro'];
|
2021-05-09 22:22:10 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function getIcon()
|
|
|
|
{
|
|
|
|
return 'https://www.presidencia.pt/Theme/favicon/apple-touch-icon.png';
|
|
|
|
}
|
2021-03-17 19:30:47 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2024-01-25 15:03:00 +03:00
|
|
|
$contexts = $this->getParameters();
|
|
|
|
|
|
|
|
foreach (array_keys($contexts['Section']) as $k) {
|
2022-07-01 16:10:30 +03:00
|
|
|
if ($this->getInput($k)) {
|
|
|
|
$html = getSimpleHTMLDOMCached($this->getURI() . $k);
|
2021-03-17 19:30:47 +03:00
|
|
|
|
2022-07-01 16:10:30 +03:00
|
|
|
foreach ($html->find('#atualidade-list article.card-block') as $element) {
|
|
|
|
$item = [];
|
2021-03-17 19:30:47 +03:00
|
|
|
|
2022-07-01 16:10:30 +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
|
|
|
|
2022-07-01 16:10:30 +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) {
|
Fix coding style missed by phpbcf (#2901)
$ composer require --dev friendsofphp/php-cs-fixer
$ echo >.php-cs-fixer.dist.php "<?php
$finder = PhpCsFixer\Finder::create()
->in(__DIR__);
$rules = [
'@PSR12' => true,
// '@PSR12:risky' => true,
'@PHP74Migration' => true,
// '@PHP74Migration:risky' => true,
// buggy, duplicates existing comment sometimes
'no_break_comment' => false,
'array_syntax' => true,
'lowercase_static_reference' => true,
'visibility_required' => false,
// Too much noise
'binary_operator_spaces' => false,
'heredoc_indentation' => false,
'trailing_comma_in_multiline' => false,
];
$config = new PhpCsFixer\Config();
return $config
->setRules($rules)
// ->setRiskyAllowed(true)
->setFinder($finder);
"
$ vendor/bin/php-cs-fixer --version
PHP CS Fixer 3.8.0 BerSzcz against war! by Fabien Potencier and Dariusz Ruminski.
PHP runtime: 8.1.7
$ vendor/bin/php-cs-fixer fix
$ rm .php-cs-fixer.cache
$ vendor/bin/php-cs-fixer fix
2022-07-08 14:00:52 +03:00
|
|
|
return sprintf('-%02d-', $num);
|
2024-06-18 21:22:46 +03:00
|
|
|
}, range(1, count(self::PT_MONTH_NAMES))),
|
2022-07-01 16:10:30 +03:00
|
|
|
$edt
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-17 19:30:47 +03:00
|
|
|
}
|