[
'name' => 'region',
'type' => 'list',
'exampleValue' => 'Nürnberg',
'title' => 'Select a region',
'values' => [
'Ansbach' => 'ansbach',
'Bamberg' => 'bamberg',
'Bayreuth' => 'bayreuth',
'Erlangen' => 'erlangen',
'Forchheim' => 'forchheim',
'Fürth' => 'fuerth',
'Gunzenhausen' => 'gunzenhausen',
'Herzogenaurach' => 'herzogenaurach',
'Höchstadt' => 'hoechstadt',
'Neumarkt' => 'neumarkt',
'Neustadt/Aisch-Bad Windsheim' => 'neustadt-aisch-bad-windsheim',
'Nürnberg' => 'nuernberg',
'Nürnberger Land' => 'nuernberger-land',
'Regensburg' => 'regensburg',
'Roth' => 'roth',
'Schwabach' => 'schwabach',
'Weißenburg' => 'weissenburg'
]
],
'policeReports' => [
'name' => 'Police Reports',
'type' => 'checkbox',
'exampleValue' => 'checked',
'title' => 'Include Police Reports',
],
'hideNNPlus' => [
'name' => 'Hide NN+ articles',
'type' => 'checkbox',
'exampleValue' => 'unchecked',
'title' => 'Hide all paywall articles on NN'
],
'hideDPA' => [
'name' => 'Hide dpa articles',
'type' => 'checkbox',
'exampleValue' => 'unchecked',
'title' => 'Hide external articles from dpa'
]
]];
private function getValidImage($picture)
{
$img = $picture->find('img', 0);
if ($img) {
$imgUrl = $img->src;
if (!preg_match('#/logo-.*\.png#', $imgUrl)) {
return '
';
}
}
return '';
}
private function getUseFullContent($rawContent)
{
$content = '';
foreach ($rawContent->children as $element) {
if (
($element->tag === 'p' || $element->tag === 'h3') &&
$element->class !== 'article__teaser'
) {
$content .= $element;
} elseif ($element->tag === 'main') {
$content .= self::getUseFullContent($element->find('article', 0));
} elseif ($element->tag === 'header') {
$content .= self::getUseFullContent($element);
} elseif (
$element->tag === 'div' &&
!str_contains($element->class, 'article__infobox') &&
!str_contains($element->class, 'authorinfo')
) {
$content .= self::getUseFullContent($element);
} elseif (
$element->tag === 'section' &&
(str_contains($element->class, 'article__richtext') ||
str_contains($element->class, 'article__context'))
) {
$content .= self::getUseFullContent($element);
} elseif ($element->tag === 'picture') {
$content .= self::getValidImage($element);
}
}
return $content;
}
private function getTeaser($content)
{
$teaser = $content->find('p[class=article__teaser]', 0);
if ($teaser === null) {
return '';
}
$teaser = $teaser->plaintext;
$teaser = preg_replace('/[ ]{2,}/', ' ', $teaser);
$teaser = '