Skip to content

Commit

Permalink
Merge pull request #175 from NateWr/i4870_versioning
Browse files Browse the repository at this point in the history
pkp/pkp-lib#4870 Adapt for versioning and publications
  • Loading branch information
NateWr authored Feb 19, 2020
2 parents 528e4aa + dc3b3d6 commit dcc40b0
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 38 deletions.
2 changes: 1 addition & 1 deletion HealthSciencesThemePlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ public function getDescription() {
*/
public function loadTemplateData($hookName, $args) {
$templateMgr = $args[0];
$request = Application::getRequest();
$request = Application::get()->getRequest();
$context = $request->getContext();

if (!defined('SESSION_DISABLE_INIT')) {
Expand Down
91 changes: 71 additions & 20 deletions templates/frontend/objects/article_details.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@
<div class="article-details">
<div class="page-header row">
<div class="col-lg article-meta-mobile">
{* Notification that this is an old version *}
{if $currentPublication->getId() !== $publication->getId()}
<div class="alert alert-primary" role="alert">
{capture assign="latestVersionUrl"}{url page="article" op="view" path=$article->getBestId()}{/capture}
{translate key="submission.outdatedVersion"
datePublished=$publication->getData('datePublished')|date_format:$dateFormatShort
urlRecentVersion=$latestVersionUrl|escape
}
</div>
{/if}

{* Title and issue details *}
<div class="article-details-issue-section small-screen">
<a href="{url page="issue" op="view" path=$issue->getBestIssueId()}">{$issue->getIssueSeries()|escape}</a>{if $section}, <span>{$section->getLocalizedTitle()|escape}</span>{/if}
Expand All @@ -42,7 +53,7 @@
</div>

<h1 class="article-details-fulltitle">
{$article->getLocalizedFullTitle()|escape}
{$publication->getLocalizedFullTitle()|escape}
</h1>

{if $section}
Expand All @@ -63,16 +74,23 @@
{/if}
{/foreach}

{* Date published *}
{if $article->getDatePublished()}
{* Date published & updated *}
{if $publication->getData('datePublished')}
<div class="article-details-published">
{translate key="plugins.themes.healthSciences.currentIssuePublished" date=$article->getDatePublished()|date_format:$dateFormatLong}
{translate key="submissions.published"}
{* If this is the original version *}
{if $firstPublication->getID() === $publication->getId()}
{$firstPublication->getData('datePublished')|date_format:$dateFormatShort}
{* If this is an updated version *}
{else}
{translate key="submission.updatedOn" datePublished=$firstPublication->getData('datePublished')|date_format:$dateFormatShort dateUpdated=$publication->getData('datePublished')|date_format:$dateFormatShort}
{/if}
</div>
{/if}

{if $article->getAuthors()}
{if $publication->getData('authors')}
<ul class="authors-string">
{foreach from=$article->getAuthors() item=authorString key=authorStringKey}
{foreach from=$publication->getData('authors') item=authorString key=authorStringKey}
{strip}
<li>
{if $authorString->getLocalizedAffiliation() or $authorString->getLocalizedBiography()}
Expand All @@ -93,10 +111,10 @@
</ul>

{* Authors *}
{assign var="authorCount" value=$article->getAuthors()|@count}
{assign var="authorCount" value=$publication->getData('authors')|@count}
{assign var="authorBioIndex" value=0}
<div class="article-details-authors">
{foreach from=$article->getAuthors() item=author key=authorKey}
{foreach from=$publication->getData('authors') item=author key=authorKey}
<div class="article-details-author hideAuthor" id="author-{$authorKey+1}">
<div class="article-details-author-name small-screen">
{$author->getFullName()|escape}
Expand Down Expand Up @@ -157,13 +175,22 @@
<div class="article-details-sidebar" id="articleDetails">

{* Article/Issue cover image *}
{if $article->getLocalizedCoverImage() || $issue->getLocalizedCoverImage()}
{if $publication->getLocalizedData('coverImage') || ($issue && $issue->getLocalizedCoverImage())}
<div class="article-details-block article-details-cover">
{if $article->getLocalizedCoverImage()}
<img class="img-fluid" src="{$article->getLocalizedCoverImageUrl()|escape}"{if $article->getLocalizedCoverImageAltText()} alt="{$article->getLocalizedCoverImageAltText()|escape}"{/if}>
{if $publication->getLocalizedData('coverImage')}
{assign var="coverImage" value=$publication->getLocalizedData('coverImage')}
<img
class="img-fluid"
src="{$publication->getLocalizedCoverImageUrl($article->getData('contextId'))|escape}"
alt="{$coverImage.altText|escape|default:''}"
>
{else}
<a href="{url page="issue" op="view" path=$issue->getBestIssueId()}">
<img class="img-fluid" src="{$issue->getLocalizedCoverImageUrl()|escape}"{if $issue->getLocalizedCoverImageAltText()} alt="{$issue->getLocalizedCoverImageAltText()|escape}"{/if}>
<img
class="img-fluid"
src="{$issue->getLocalizedCoverImageUrl()|escape}"
alt="{$issue->getLocalizedCoverImageAltText()|escape|default:''}"
>
</a>
{/if}
</div>
Expand All @@ -176,6 +203,30 @@
{/foreach}
{/capture}

{* Display other versions *}
{if $publication->getData('datePublished')}
{if count($article->getPublishedPublications()) > 1}
<div class="article-details-block">
<h2 class="article-details-heading">
{translate key="submission.versions"}
</h2>
<ul>
{foreach from=array_reverse($article->getPublishedPublications()) item=iPublication}
{capture assign="name"}{translate key="submission.versionIdentity" datePublished=$iPublication->getData('datePublished')|date_format:$dateFormatShort version=$iPublication->getData('version')}{/capture}
<li>
{if $iPublication->getId() === $publication->getId()}
{$name}
{elseif $iPublication->getId() === $currentPublication->getId()}
<a href="{url page="article" op="view" path=$article->getBestId()}">{$name}</a>
{else}
<a href="{url page="article" op="view" path=$article->getBestId()|to_array:"version":$iPublication->getId()}">{$name}</a>
{/if}
</li>
{/foreach}
</ul>
</div>
{/if}
{/if}

{* Article Galleys (sidebar -- only visible on small devices) *}
{if $primaryGalleys}
Expand Down Expand Up @@ -287,10 +338,10 @@
<div class="article-details-main" id="articleMain">

{* Abstract *}
{if $article->getLocalizedAbstract()}
{if $publication->getLocalizedData('abstract')}
<div class="article-details-block article-details-abstract">
<h2 class="article-details-heading">{translate key="article.abstract"}</h2>
{$article->getLocalizedAbstract()|strip_unsafe_html}
{$publication->getLocalizedData('abstract')|strip_unsafe_html}
</div>
{/if}

Expand Down Expand Up @@ -320,18 +371,18 @@
{/if}

{* References *}
{if $parsedCitations->getCount() || $article->getCitations()}
{if $parsedCitations || $publication->getData('citationsRaw')}
<div class="article-details-block article-details-references">
<h2 class="article-details-heading">
{translate key="submission.citations"}
</h2>
<div class="article-details-references-value">
{if $parsedCitations->getCount()}
{iterate from=parsedCitations item=parsedCitation}
{if $parsedCitations}
{foreach from=$parsedCitations item=parsedCitation}
<p>{$parsedCitation->getCitationWithLinks()|strip_unsafe_html}</p>
{/iterate}
{elseif $article->getCitations()}
{$article->getCitations()|nl2br}
{/foreach}
{else}
{$publication->getData('citationsRaw')|nl2br}
{/if}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions templates/frontend/objects/article_summary.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* @uses $hideGalleys bool Hide the article galleys for this article?
* @uses $primaryGenreIds array List of file genre ids for primary file types
*}
{assign var=articlePath value=$article->getBestArticleId()}
{assign var=articlePath value=$article->getBestId()}

{if (!$section.hideAuthor && $article->getHideAuthor() == $smarty.const.AUTHOR_TOC_DEFAULT) || $article->getHideAuthor() == $smarty.const.AUTHOR_TOC_SHOW}
{assign var="showAuthor" value=true}
Expand Down Expand Up @@ -87,7 +87,7 @@
{/if}
{/if}
{assign var="hasArticleAccess" value=$hasAccess}
{if ($article->getAccessStatus() == $smarty.const.ARTICLE_ACCESS_OPEN)}
{if $currentContext->getSetting('publishingMode') == $smarty.const.PUBLISHING_MODE_OPEN || $article->getCurrentPublication()->getData('accessStatus') == $smarty.const.ARTICLE_ACCESS_OPEN}
{assign var="hasArticleAccess" value=1}
{/if}
{include file="frontend/objects/galley_link.tpl" parent=$article hasAccess=$hasArticleAccess}
Expand Down
2 changes: 1 addition & 1 deletion templates/frontend/objects/galley_link.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
{assign var="parentId" value=$parent->getBestIssueId()}
{else}
{assign var="page" value="article"}
{assign var="parentId" value=$parent->getBestArticleId()}
{assign var="parentId" value=$parent->getBestId()}
{/if}

{* Get user access flag *}
Expand Down
4 changes: 2 additions & 2 deletions templates/frontend/objects/issue_toc.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
* @uses $issueSeries string Vol/No/Year string for the issue
* @uses $issueGalleys array Galleys for the entire issue
* @uses $hasAccess bool Can this user access galleys for this context?
* @uses $publishedArticles array Lists of articles published in this issue
* @uses $publishedSubmissions array Lists of articles published in this issue
* sorted by section.
* @uses $primaryGenreIds array List of file genre ids for primary file types
* @uses $sectionHeading string Tag to use (h2, h3, etc) for section headings
*}
<div class="issue-toc">

{foreach name=sections from=$publishedArticles item=section}
{foreach name=sections from=$publishedSubmissions item=section}
<div class="issue-toc-section">
{if $section.articles}
{if $section.title}
Expand Down
2 changes: 1 addition & 1 deletion templates/frontend/pages/issueInterstitial.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
{assign var="parentId" value=$parent->getBestIssueId()}
{url op="view" path=$parentId}
{else}
{assign var="parentId" value=$parent->getBestArticleId()}
{assign var="parentId" value=$parent->getBestId()}
{url page="article" op="view" path=$parentId}
{/if}
{/capture}
Expand Down
2 changes: 1 addition & 1 deletion templates/frontend/pages/search.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{* Results pagination *}
{else}
{iterate from=results item=result}
{include file="frontend/objects/article_summary.tpl" article=$result.publishedArticle journal=$result.journal showDatePublished=true hideGalleys=true}
{include file="frontend/objects/article_summary.tpl" article=$result.publishedSubmission journal=$result.journal showDatePublished=true hideGalleys=true}
{/iterate}
<div class="pagination">
{page_info iterator=$results}
Expand Down
8 changes: 4 additions & 4 deletions templates/frontend/pages/searchAuthorDetails.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="page-content" id="authorDetails">
<h3 class="author-details-author text-lg-center">{$lastName|escape}, {$firstName|escape}{if $middleName} {$middleName|escape}{/if}{if $affiliation}, {$affiliation|escape}{/if}{if $country}, {$country|escape}{/if}</h3>
<ul class="author-details-articles">
{foreach from=$publishedArticles item=article}
{foreach from=$submissions item=article}
{assign var=issueId value=$article->getIssueId()}
{assign var=issue value=$issues[$issueId]}
{assign var=issueUnavailable value=$issuesUnavailable.$issueId}
Expand All @@ -39,12 +39,12 @@
<span>{$section->getLocalizedTitle()|escape}</span>
</div>
<div class="author-details-block author-details-article">
<a href="{url journal=$journal->getPath() page="article" op="view" path=$article->getBestArticleId()}">{$article->getLocalizedTitle()|strip_unsafe_html}</a>
<a href="{url journal=$journal->getPath() page="article" op="view" path=$article->getBestId()}">{$article->getLocalizedTitle()|strip_unsafe_html}</a>
</div>
{if (!$issueUnavailable || $article->getAccessStatus() == $smarty.const.ARTICLE_ACCESS_OPEN)}
{if (!$issueUnavailable || $publication->getData('accessStatus') == $smarty.const.ARTICLE_ACCESS_OPEN}}
<div class="author-details-block author-details-galleys">
{foreach from=$article->getGalleys() item=galley name=galleyList}
<a href="{url journal=$journal->getPath() page="article" op="view" path=$article->getBestArticleId()|to_array:$galley->getBestGalleyId()}"
<a href="{url journal=$journal->getPath() page="article" op="view" path=$article->getBestId()|to_array:$galley->getBestGalleyId()}"
class="btn btn-primary">{$galley->getGalleyLabel()|escape}</a>
{/foreach}
</div>
Expand Down
18 changes: 13 additions & 5 deletions templates/plugins/generic/htmlArticleGalley/templates/display.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,27 @@
{* Header wrapper *}
<header class="header_view">

<a href="{url page="article" op="view" path=$article->getBestArticleId()}" class="return">
<a href="{url page="article" op="view" path=$article->getBestId()}" class="return">
<span class="pkp_screen_reader">
{translate key="article.return"}
</span>
</a>

<a href="{url page="article" op="view" path=$article->getBestArticleId()}" class="title">
{$article->getLocalizedTitle()|escape}
{if !$isLatestPublication}
<div class="title" role="alert">
{translate key="submission.outdatedVersion"
datePublished=$galleyPublication->getData('datePublished')|date_format:$dateFormatLong
urlRecentVersion=$parentUrl
}
</div>
{else}
<a href="{url page="article" op="view" path=$article->getBestId()}" class="title">
{$galleyPublication->getLocalizedTitle()|escape}
</a>
{/if}
</header>

<div id="htmlContainer" class="galley_view" style="overflow:visible;-webkit-overflow-scrolling:touch">
<iframe id="htmlGalleyFrame" name="htmlFrame" src="{url page="article" op="download" path=$article->getBestArticleId()|to_array:$galley->getBestGalleyId() inline=true}" allowfullscreen webkitallowfullscreen></iframe>
<iframe id="htmlGalleyFrame" name="htmlFrame" src="{url page="article" op="download" path=$article->getBestId()|to_array:$galley->getBestGalleyId() inline=true}" allowfullscreen webkitallowfullscreen></iframe>
</div>
{call_hook name="Templates::Common::Footer::PageFooter"}
</body>
Expand Down
12 changes: 11 additions & 1 deletion templates/plugins/generic/pdfJsViewer/templates/display.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,19 @@
{translate key="article.return"}
{/if}
</span>
{$title}
{if $isLatestPublication}
{$title|escape}
{/if}
</a>
</div>
{if !$isLatestPublication}
<div class="alert alert-primary" role="alert">
{translate key="submission.outdatedVersion"
datePublished=$galleyPublication->getData('datePublished')|date_format:$dateFormatLong
urlRecentVersion=$parentUrl
}
</div>
{/if}
<div class="pdf-download-button">
<a href="{$pdfUrl}" class="btn" download>
<span class="label">
Expand Down

0 comments on commit dcc40b0

Please sign in to comment.