Skip to content

Commit

Permalink
Ajusta gravação de título para contemplar multi-idiomas
Browse files Browse the repository at this point in the history
  • Loading branch information
liviacarolgouvea committed Dec 25, 2023
1 parent 6224152 commit 3d27bf9
Showing 1 changed file with 31 additions and 9 deletions.
40 changes: 31 additions & 9 deletions src/Parser/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,17 +96,39 @@ private function incrementMetadata(Crawler $crawler, string $currentLang)
]);
}
}
$nodes = $crawler->filter('meta[name="citation_title"]');
if ($nodes->count()) {
$this->setTitle($nodes->attr('content'), $currentLang);
$titlesExtra = $crawler->filter('h2[class="article-title"]')->each(function ($node, $i) {return $node->text();});

if (!$this->getTitle($currentLang)) {
$nodes = $crawler->filter('meta[name="citation_title"]');
if ($nodes->count()) {
$this->setTitle($nodes->attr('content'), $currentLang);
} else {
$this->logger->error('Without Title', [
'method' => 'ScieloClient::getArticleMetadata',
'directory' => $this->getBasedir()
]);
if($currentLang == "pt_BR"){
$langs = ["en_US", "es_ES"];
}
if($currentLang == "en_US"){
if(count($titlesExtra) > 1){
$langs = ["pt_BR", "es_ES"];
}else{
$langs = ["pt_BR"];
}
}
if($currentLang == "es_ES"){
if(count($titlesExtra) > 1){
$langs = ["en_US", "pt_BR"];
}else{
$langs = ["pt_BR"];
}
}
if($titlesExtra){
foreach($titlesExtra as $key => $value){
$this->setTitle($value, $langs[$key]);
next($langs);
}
}
} else {
$this->logger->error('Without Title', [
'method' => 'ScieloClient::getArticleMetadata',
'directory' => $this->getBasedir()
]);
}
if (!$this->getPublished()) {
$nodes = $crawler->filter('meta[name="citation_publication_date"]');
Expand Down

0 comments on commit 3d27bf9

Please sign in to comment.