Skip to content

Commit

Permalink
pkp#9914 editorial history public page
Browse files Browse the repository at this point in the history
  • Loading branch information
bozana committed May 6, 2024
1 parent 871a5ec commit 0214bdb
Show file tree
Hide file tree
Showing 5 changed files with 140 additions and 0 deletions.
3 changes: 3 additions & 0 deletions locale/en/common.po
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ msgstr "Peer Reviewers"
msgid "common.editorialMasthead.peerReviewers.description"
msgstr "The editors express their appreciation of the reviewers for {$year} listed below."

msgid "common.editorialHistory"
msgstr "Editorial History"

msgid "common.name"
msgstr "Name"

Expand Down
85 changes: 85 additions & 0 deletions pages/about/AboutContextHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
use APP\handler\Handler;
use APP\template\TemplateManager;
use DateTime;
use PKP\facades\Locale;
use PKP\plugins\Hook;
use PKP\security\authorization\ContextRequiredPolicy;
use PKP\security\Role;
use PKP\userGroup\relationships\enums\UserUserGroupMastheadStatus;
use PKP\userGroup\relationships\enums\UserUserGroupStatus;
use PKP\userGroup\relationships\UserUserGroup;

class AboutContextHandler extends Handler
Expand Down Expand Up @@ -138,6 +140,89 @@ public function editorialMasthead($args, $request)
$templateMgr->display('frontend/pages/editorialMasthead.tpl');
}

/**
* Display editorial history page.
*
* @param array $args
* @param \PKP\core\PKPRequest $request
*
* @hook AboutContextHandler::editorialHistory [[$mastheadRoles, $mastheadUsers]]
*/
public function editorialHistory($args, $request)
{
$context = $request->getContext();

$savedMastheadUserGroupIdsOrder = (array) $context->getData('mastheadUserGroupIds');

$collector = Repo::userGroup()->getCollector();
$allMastheadUserGroups = $collector
->filterByContextIds([$context->getId()])
->filterByMasthead(true)
->orderBy($collector::ORDERBY_ROLE_ID)
->getMany()
->toArray();

// sort the masthead roles in their saved order for display
$mastheadRoles = array_replace(array_flip($savedMastheadUserGroupIdsOrder), $allMastheadUserGroups);

$mastheadUsers = [];
foreach ($mastheadRoles as $mastheadUserGroup) {
if ($mastheadUserGroup->getRoleId() == Role::ROLE_ID_REVIEWER) {
continue;
}
// Get all users that were active and are not active any more in the given role
// and that have accepted to be displayed on the masthead for that role.
// No need to filter by context ID, because the user groups are already filtered so.
$usersCollector = Repo::user()->getCollector();
$users = $usersCollector
->filterByUserGroupIds([$mastheadUserGroup->getId()])
->filterByUserUserGroupStatus(UserUserGroupStatus::STATUS_ENDED)
->filterByUserUserGroupMastheadStatus(UserUserGroupMastheadStatus::STATUS_ON)
->orderBy($usersCollector::ORDERBY_FAMILYNAME, $usersCollector::ORDER_DIR_ASC, [Locale::getLocale(), Application::get()->getRequest()->getSite()->getPrimaryLocale()])
->getMany();

foreach ($users as $user) {
$userUserGroups = UserUserGroup::withUserId($user->getId())
->withUserGroupId($mastheadUserGroup->getId())
->withEnded()
->withMasthead()
->get();
$services = [];
foreach ($userUserGroups as $userUserGroup) {
$startDatetime = new DateTime($userUserGroup->dateStart);
$endDatetime = new DateTime($userUserGroup->dateEnd);
$services[] = [
'dateStart' => $startDatetime->format('Y'),
'dateEnd' => $endDatetime->format('Y'),
];
}
if (!empty($services)) {
$mastheadUsers[$mastheadUserGroup->getId()][$user->getId()] = [
'user' => $user,
'services' => $services
];
}

}
}

Hook::call('AboutContextHandler::editorialHistory', [$mastheadRoles, $mastheadUsers]);

// To come after https://github.com/pkp/pkp-lib/issues/9771
// $orcidIcon = OrcidManager::getIcon();
$orcidIcon = '';

$templateMgr = TemplateManager::getManager($request);
$this->setupTemplate($request);
$templateMgr->assign([
'mastheadRoles' => $mastheadRoles,
'mastheadUsers' => $mastheadUsers,
'orcidIcon' => $orcidIcon
]);
$templateMgr->display('frontend/pages/editorialHistory.tpl');
}


/**
* Display editorialTeam page.
*
Expand Down
1 change: 1 addition & 0 deletions pages/about/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
switch ($op) {
case 'index':
case 'editorialMasthead':
case 'editorialHistory':
case 'editorialTeam':
case 'submissions':
case 'contact':
Expand Down
45 changes: 45 additions & 0 deletions templates/frontend/pages/editorialHistory.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{**
* templates/frontend/pages/editorialHistory.tpl
*
* Copyright (c) 2024 Simon Fraser University
* Copyright (c) 2024 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @brief Display journal's editorial history page.
*
*}
{include file="frontend/components/header.tpl" pageTitle="common.editorialHistory"}

<div class="page page_masthead">
{include file="frontend/components/breadcrumbs.tpl" currentTitleKey="common.editorialHistory"}

<h1>{translate key="common.editorialHistory"}</h1>
{foreach from=$mastheadRoles item="mastheadRole"}
{if array_key_exists($mastheadRole->getId(), $mastheadUsers)}
<h2>{$mastheadRole->getLocalizedName()|escape}</h2>
<ul>
{foreach from=$mastheadUsers[$mastheadRole->getId()] item="mastheadUser"}
{foreach from=$mastheadUser['services'] item="service"}
<li>
{$mastheadUser['user']->getFullName()|escape},
{$mastheadUser['user']->getLocalizedData('affiliation')|escape},
{$service['dateStart']} - {$service['dateEnd']}
{if $mastheadUser['user']->getData('orcid')}
<span class="orcid">
{if $mastheadUser['user']->getData('orcidAccessToken')}
{$orcidIcon}
{/if}
<a href="{$mastheadUser['user']->getData('orcid')|escape}" target="_blank">
{$mastheadUser['user']->getData('orcid')|escape}
</a>
</span>
{/if}
</li>
{/foreach}
{/foreach}
</ul>
{/if}
{/foreach}
</div><!-- .page -->

{include file="frontend/components/footer.tpl"}
6 changes: 6 additions & 0 deletions templates/frontend/pages/editorialMasthead.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
{/if}
{/foreach}

<p>
<a href="{url page="about" op="editorialHistory" router=\PKP\core\PKPApplication::ROUTE_PAGE}">
{translate key="common.editorialHistory"}
</a>
</p>

{if !empty($reviewers)}
<h2>{translate key="common.editorialMasthead.peerReviewers"}</h2>
<p>{translate key="common.editorialMasthead.peerReviewers.description" year=$previousYear}</p>
Expand Down

0 comments on commit 0214bdb

Please sign in to comment.