Skip to content

Commit

Permalink
latest issues slider #25
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy-1 committed Feb 13, 2018
1 parent 48ce272 commit e8662e2
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 47 deletions.
41 changes: 41 additions & 0 deletions OldGreggThemePlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

define('OLDGREGG_CSL_STYLE_DEFAULT', 'vancouver');
define('OLDGREGG_LATEST_ARTICLES_DEFAULT', 20);
define('OLDGREGG_ISSUE_COVER_RELATIVE_URL', 'images/issue_default.jpg');
define('OLDGREGG_LATEST_ISSUES_DEFAULT', 3);

class OldGreggThemePlugin extends ThemePlugin
{
Expand All @@ -42,6 +44,10 @@ public function init()
)
));

$this->addOption('displayIssuesSlider', 'text', array(
'label' => 'plugins.gregg.if-display.issue-slider',
'description' => 'plugins.gregg.if-display.issue-slider.description',
));

$this->addStyle('bootstrap', 'bootstrap/css/bootstrap.min.css');
$this->addStyle('header', 'css/header.css');
Expand Down Expand Up @@ -93,6 +99,7 @@ public function init()
HookRegistry::register('TemplateManager::display', array($this, 'jatsParser'), HOOK_SEQUENCE_NORMAL);
HookRegistry::register('TemplateManager::display', array($this, 'browseLatest'), HOOK_SEQUENCE_CORE);
HookRegistry::register('TemplateManager::display', array($this, 'citationStyle'), HOOK_SEQUENCE_LATE);
HookRegistry::register('TemplateManager::display', array($this, 'latestIssuesSlider'), HOOK_SEQUENCE_NORMAL);
}


Expand Down Expand Up @@ -240,6 +247,40 @@ public function citationStyle($hookName, $args) {
$smarty->assign('cslStyle', $cslStyle);
}

public function latestIssuesSlider($hookName, $args) {
$smarty = $args[0];
$template = $args[1];

if ($template != 'frontend/pages/indexJournal.tpl') return false;

$latestIssuesInput = $this->getOption("displayIssuesSlider");
if (is_null($latestIssuesInput)) {
$latestIssuesInput = OLDGREGG_LATEST_ISSUES_DEFAULT;
} elseif (intval($latestIssuesInput) === 0) {
return false;
} else {
$latestIssuesInput = intval($latestIssuesInput);
}

$request = $this->getRequest();
$journal = $request->getJournal();
$journalId = $journal->getId();

$issueDao = DAORegistry::getDAO('IssueDAO');
$rangeIssues = new DBResultRange($latestIssuesInput, 1);
$latestIssuesObjects = $issueDao->getPublishedIssues($journalId, $rangeIssues);

$latestIssues = array();
while ($latestIssue = $latestIssuesObjects->next()) {
$latestIssues[] = $latestIssue;
}

$defaultCoverImageUrl = "/" . $this->getPluginPath() . "/" . OLDGREGG_ISSUE_COVER_RELATIVE_URL;

$smarty->assign('latestIssues', $latestIssues);
$smarty->assign('defaultCoverImageUrl', $defaultCoverImageUrl);
}

}

?>
26 changes: 26 additions & 0 deletions css/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,30 @@ a.recent-article-title:hover {
/* all index page */
.index-page-content {
margin-top: 50px;
}

/* recent issues block */
.recent-issues-slider {
margin-bottom: 30px;
}

.recent-issues-slider h3 {
padding: .75rem 1.25rem;
background-color: rgba(0,0,0,.03);
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
text-align: center;
font-size: 17px;
font-weight: normal;
margin-left: -15px;
margin-right: -15px;
text-transform: capitalize;
}

#carouselIndicators {
margin-bottom: 30px;
}

#carouselIndicators .carousel-inner {
border-radius: 5px;
}
Binary file added images/issue_default.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions locale/en_US/locale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,10 @@
<message key="plugins.gregg.citation-style.type">Citation Style</message>
<message key="plugins.gregg.citation-style.description">Citation Style for references from JATS XML</message>
<message key="plugins.gregg.citation-style.vancouver">Vancouver</message>

<!-- Journal Index page -->
<message key="plugins.gregg.issues.slider.title">latest issues</message>
<message key="plugins.gregg.if-display.issue-slider">Number of Latest Issues</message>
<message key="plugins.gregg.if-display.issue-slider.description">The number of latest issues to display in the slider on the journal index page; enter "0" to disable this feature </message>

</locale>
5 changes: 5 additions & 0 deletions locale/uk_UA/locale.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@
<message key="plugins.gregg.citation-style.type">Стиль цитувань</message>
<message key="plugins.gregg.citation-style.description">Стиль, в якому буде відображуватись перелік використаної літератури, взятий із JATS XML</message>
<message key="plugins.gregg.citation-style.vancouver">Ванкуверський стиль цитувань</message>

<!-- Journal Index page -->
<message key="plugins.gregg.issues.slider.title">нещодавні випуски</message>
<message key="plugins.gregg.if-display.issue-slider">Кількість нещодавніх випусків</message>
<message key="plugins.gregg.if-display.issue-slider.description">Кількість випусків журналу, яка буде відображатись на головній сторінці журналу у слайдері; вкажіть "0", якщо хочете вимкнути цю опцію</message>
</locale>
55 changes: 55 additions & 0 deletions templates/frontend/objects/issue_slider.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
{**
* templates/frontend/objects/issue_slider.tpl
*
* Copyright (c) 2018 Vitaliy Bezsheiko
* Distributed under the GNU GPL v3.
*}

<div class="recent-issues-slider col-md-12">
<h3>{translate key="plugins.gregg.issues.slider.title"}</h3>
</div>
<div id="carouselIndicators" class="carousel slide" data-ride="carousel">
{capture name="forCarouselIndicators"}
{foreach from=$latestIssues item=issue key=k}
<li data-target="#carouselIndicators" data-slide-to="{$k}" {if $k == 0}class="active"{/if}></li>
{/foreach}
{/capture}
{capture name="forCarouselImages"}
{foreach from=$latestIssues item=issue key=k}
<div class="carousel-item {if $k == 0}active{/if}">
{if $issue->getLocalizedCoverImageUrl()}
<img src="{$issue->getLocalizedCoverImageUrl()}" class="img-fluid">
{else}
<img src="{$defaultCoverImageUrl}" class="img-fluid">
{/if}
<div class="carousel-caption">
{if $issue->getLocalizedTitle()}
<h5>{$issue->getLocalizedTitle()}</h5>
{else}
<h5>{$displayPageHeaderTitle}</h5>
{/if}
<p>{$issue->getVolume()}
|
{$issue->getNumber()}</p>
</div>
</div>
{/foreach}
{/capture}
<ol class="carousel-indicators">
{$smarty.capture.forCarouselIndicators}
</ol>
<div class="carousel-inner">
{$smarty.capture.forCarouselImages}
</div>
<a class="carousel-control-prev" href="#carouselIndicators" role="button"
data-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselIndicators" role="button"
data-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
{* end of carousel div*}
98 changes: 51 additions & 47 deletions templates/frontend/pages/indexJournal.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,66 @@
{include file="frontend/components/header.tpl" pageTitleTranslated=$currentJournal->getLocalizedName()}

<div class="page_index_journal">
<div class="index-page-content">
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="recent-articles-section-title col-md-12">
<h3>{translate key="plugins.gregg.latest"}</h3>
</div>
{foreach from=$publishedArticles item=article key=k}
<div class="recent-wrapper col-md-6">
<div class="card">
<a href="{url page="article" op="view" path=$article->getBestArticleId()}">
<img class="card-img-top" src="{$article->getLocalizedCoverImageUrl()|escape}">
</a>
<div class="card-body">
<h4 class="card-title">
<a class="recent-article-title" href="{url page="article" op="view" path=$article->getBestArticleId()}">
{$article->getLocalizedTitle()|strip|escape:"html"}
</a>
</h4>
<p class="card-text">
<div class="index-page-content">
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="recent-articles-section-title col-md-12">
<h3>{translate key="plugins.gregg.latest"}</h3>
</div>
{foreach from=$publishedArticles item=article key=k}
<div class="recent-wrapper col-md-6">
<div class="card">
<a href="{url page="article" op="view" path=$article->getBestArticleId()}">
<img class="card-img-top" src="{$article->getLocalizedCoverImageUrl()|escape}">
</a>
<div class="card-body">
<h4 class="card-title">
<a class="recent-article-title"
href="{url page="article" op="view" path=$article->getBestArticleId()}">
{$article->getLocalizedTitle()|strip|escape:"html"}
</a>
</h4>
<p class="card-text">
{foreach from=$article->getAuthors() key=k item=author}
<span>{$author->getLastName()|strip|escape:"html"}
{if $k<($article->getAuthors()|@count - 1)}
{$author->getFirstName()|regex_replace:"/(?<=\w)\w+/":".,"}
{else}
{$author->getFirstName()|regex_replace:"/(?<=\w)\w+/":"."}
{/if}</span>
<span>{$author->getLastName()|strip|escape:"html"}
{if $k<($article->getAuthors()|@count - 1)}
{$author->getFirstName()|regex_replace:"/(?<=\w)\w+/":".,"}
{else}
{$author->getFirstName()|regex_replace:"/(?<=\w)\w+/":"."}
{/if}</span>
{/foreach}
</p>
</div>
<div class="card-footer">
<small class="text-muted">
{$article->getSectionTitle()}
|
{$article->getDatePublished()|date_format:"%Y-%m-%d"}
</small>
</div>
</div>
</div>

{/foreach}
</div>
</p>
</div>
<div class="card-footer">
<small class="text-muted">
{$article->getSectionTitle()}
|
{$article->getDatePublished()|date_format:"%Y-%m-%d"}
</small>
</div>
</div>
</div>
{/foreach}
</div>
{call_hook name="Templates::Index::journal"}
</div>
<div class="col-md-4">
</div>
<div class="col-md-4">
{if empty($isFullWidth)}
{call_hook|assign:"sidebarCode" name="Templates::Common::Sidebar"}
{if $sidebarCode}
<div class="pkp_structure_sidebar" role="complementary" aria-label="{translate|escape key="common.navigation.sidebar"}">
{if $latestIssues}
{include file="frontend/objects/issue_slider.tpl"}
{/if}
<div class="pkp_structure_sidebar" role="complementary"
aria-label="{translate|escape key="common.navigation.sidebar"}">
{$sidebarCode}
</div>
</div>
{/if}
{/if}
</div>
</div>
</div>
</div>
</div>
</div>
</div><!-- .page -->

{include file="frontend/components/footer.tpl"}

0 comments on commit e8662e2

Please sign in to comment.