Skip to content

Commit

Permalink
Merge branch 'translatorInLandingPage-734' into 'main'
Browse files Browse the repository at this point in the history
Destaca tradutor na landing page da submissão

See merge request softwares-pkp/temas/scielo!11
  • Loading branch information
JhonathanLepidus committed Jan 10, 2025
2 parents be217f7 + d052e8a commit 043c025
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 26 deletions.
31 changes: 31 additions & 0 deletions ScieloThemePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
use PKP\plugins\ThemePlugin;
use PKP\session\SessionManager;
use PKP\plugins\Hook;
use APP\template\TemplateManager;
use APP\facades\Repo;

class ScieloThemePlugin extends ThemePlugin
{
Expand Down Expand Up @@ -179,6 +181,7 @@ public function init()

Hook::add('LoadHandler', [$this, 'replaceIndexHandler']);
Hook::add('Templates::Common::Sidebar', [$this, 'setSidebarToNotShowAtHome']);
Hook::add('PreprintHandler::view', [$this, 'addDataOnSubmissionView']);
}

public function register($category, $path, $mainContextId = null)
Expand Down Expand Up @@ -216,6 +219,34 @@ public function setSidebarToNotShowAtHome($hookName, $args)
}
}

public function addDataOnSubmissionView($hookName, $args)
{
$request = $args[0];
$templateMgr = TemplateManager::getManager($request);
$translatorsUserGroup = $this->getTranslatorsUserGroup($request->getContext()->getId());

if ($translatorsUserGroup) {
$templateMgr->assign(['translatorsUserGroupId' => $translatorsUserGroup->getId()]);
}
}

private function getTranslatorsUserGroup(int $contextId)
{
$contextUserGroups = Repo::userGroup()->getCollector()
->filterByContextIds([$contextId])
->getMany();

foreach ($contextUserGroups as $userGroup) {
$userGroupAbbrev = strtolower($userGroup->getData('abbrev', 'en'));

if ($userGroupAbbrev === 'tr') {
return $userGroup;
}
}

return null;
}

public function getContextSpecificPluginSettingsFile()
{
return $this->getPluginPath() . '/settings.xml';
Expand Down
5 changes: 4 additions & 1 deletion locale/en/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ msgid "plugins.themes.scielo.indexToArchive"
msgstr "All preprints"

msgid "plugins.themes.scielo.msgCountingDownloads"
msgstr " (as of yesterday)"
msgstr " (as of yesterday)"

msgid "plugins.themes.scielo.translation"
msgstr "Translation"
5 changes: 4 additions & 1 deletion locale/es/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,7 @@ msgid "plugins.themes.scielo.indexToArchive"
msgstr "Todos los preprints"

msgid "plugins.themes.scielo.msgCountingDownloads"
msgstr " (hasta ayer)"
msgstr " (hasta ayer)"

msgid "plugins.themes.scielo.translation"
msgstr "Traducción"
5 changes: 4 additions & 1 deletion locale/pt_BR/locale.po
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,7 @@ msgid "plugins.themes.scielo.indexToArchive"
msgstr "Todos os preprints"

msgid "plugins.themes.scielo.msgCountingDownloads"
msgstr " (até ontem)"
msgstr " (até ontem)"

msgid "plugins.themes.scielo.translation"
msgstr "Tradução"
10 changes: 10 additions & 0 deletions styles/objects/article_details.less
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,16 @@
.name {
font-weight: bold;
display: block;

.translationBadge {
font-size: 12px;
font-weight: @normal;
color: #fff;
background-color: #007ab2;
padding: 0.2em 0.8em;
border-radius: 12px;
margin-left: 5px;
}
}

.orcid {
Expand Down
43 changes: 22 additions & 21 deletions templates/frontend/objects/preprint_details.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@
<li>
<span class="name">
{$author->getFullName()|escape}

{if $author->getData('userGroupId') == $translatorsUserGroupId}
<span class="translationBadge">
{translate key="plugins.themes.scielo.translation"}
</span>
{/if}
</span>
{if $author->getLocalizedData('affiliation')}
<span class="affiliation">
Expand All @@ -146,27 +152,22 @@
</section>
{/if}

{* DOI (requires plugin) *}
{foreach from=$pubIdPlugins item=pubIdPlugin}
{if $pubIdPlugin->getPubIdType() != 'doi'}
{continue}
{/if}
{assign var=pubId value=$publication->getStoredPubId($pubIdPlugin->getPubIdType())}
{if $pubId}
{assign var="doiUrl" value=$pubIdPlugin->getResolvingURL($currentJournal->getId(), $pubId)|escape}
<section class="item doi">
<h2 class="label">
{capture assign=translatedDOI}{translate key="plugins.pubIds.doi.readerDisplayName"}{/capture}
{translate key="semicolon" label=$translatedDOI}
</h2>
<span class="value">
<a href="{$doiUrl}">
{$doiUrl}
</a>
</span>
</section>
{/if}
{/foreach}
{* DOI *}
{assign var=doiObject value=$publication->getData('doiObject')}
{if $doiObject}
{assign var="doiUrl" value=$doiObject->getData('resolvingUrl')|escape}
<section class="item doi">
<h2 class="label">
{capture assign=translatedDOI}{translate key="doi.readerDisplayName"}{/capture}
{translate key="semicolon" label=$translatedDOI}
</h2>
<span class="value">
<a href="{$doiUrl}">
{$doiUrl}
</a>
</span>
</section>
{/if}

{* Keywords *}
{if !empty($publication->getLocalizedData('keywords'))}
Expand Down
4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
<version>
<application>scieloTheme</application>
<type>plugins.themes</type>
<release>2.0.0</release>
<date>2024-02-08</date>
<release>2.1.0.0</release>
<date>2025-01-10</date>
<lazy-load>1</lazy-load>
<class>ScieloThemePlugin</class>
</version>

0 comments on commit 043c025

Please sign in to comment.