Skip to content

Commit

Permalink
pkp/pkp-lib#9253 Add site-level announcements
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr authored and asmecher committed Nov 8, 2023
1 parent 543d77c commit 63cb9c9
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 33 deletions.
1 change: 1 addition & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
<upgrade minversion="3.4.0.0" maxversion="3.4.9.9">
<migration class="PKP\migration\upgrade\v3_5_0\I9197_MigrateAccessKeys"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9262_Highlights"/>
<migration class="PKP\migration\upgrade\v3_5_0\I9253_SiteAnnouncements"/>
</upgrade>

<!-- update plugin configuration - should be done as the final upgrade task -->
Expand Down
3 changes: 1 addition & 2 deletions pages/index/IndexHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public function index($args, $request)
'highlights' => $this->getHighlights($server),
]);

$this->_setupAnnouncements($journal ?? $request->getSite(), $templateMgr);
if ($server) {
// OPS: sections
$sections = Repo::section()->getCollector()->filterByContextIds([$server->getId()])->getMany();
Expand Down Expand Up @@ -96,8 +97,6 @@ public function index($args, $request)
'authorUserGroups' => Repo::userGroup()->getCollector()->filterByRoleIds([\PKP\security\Role::ROLE_ID_AUTHOR])->filterByContextIds([$server->getId()])->getMany()->remember(),
]);

$this->_setupAnnouncements($server, $templateMgr);

$templateMgr->display('frontend/pages/indexServer.tpl');
event(new UsageEvent(Application::ASSOC_TYPE_SERVER, $server));
return;
Expand Down
3 changes: 2 additions & 1 deletion plugins/themes/default/styles/components.less
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@
}

// Announcements
.cmp_announcements {
// Double class rule overrides .pkp_structure_main ul
.cmp_announcements.cmp_announcements {
&:extend(.pkp_unstyled_list);
margin-left: -@base;
margin-right: -@base;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@
.cmp_button_text(@fa-var-chevron-right);
}
}

@media (min-width: @screen-tablet) {
.obj_announcement_summary_has_image {
display: grid;
grid-template-columns: 33% auto;
gap: @triple;
}
}
1 change: 1 addition & 0 deletions plugins/themes/default/styles/pages/indexServer.less
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
}

> .obj_announcement_summary {
display: block;
position: relative;
padding: @triple @base;
}
Expand Down
31 changes: 1 addition & 30 deletions templates/frontend/pages/indexServer.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -55,36 +55,7 @@
</section>
{/if}

{* Announcements *}
{if $numAnnouncementsHomepage && $announcements|@count}
<section class="cmp_announcements highlight_first">
<a id="homepageAnnouncements"></a>
<h2>
{translate key="announcement.announcements"}
</h2>
{foreach name=announcements from=$announcements item=announcement}
{if $smarty.foreach.announcements.iteration > $numAnnouncementsHomepage}
{break}
{/if}
{if $smarty.foreach.announcements.iteration == 1}
{include file="frontend/objects/announcement_summary.tpl" heading="h3"}
<div class="more">
{else}
<article class="obj_announcement_summary">
<h4>
<a href="{url router=PKPApplication::ROUTE_PAGE page="announcement" op="view" path=$announcement->getId()}">
{$announcement->getLocalizedTitle()|escape}
</a>
</h4>
<div class="date">
{$announcement->getDatePosted()|date_format:$dateFormatShort}
</div>
</article>
{/if}
{/foreach}
</div><!-- .more -->
</section>
{/if}
{include file="frontend/objects/announcements_list.tpl" numAnnouncements=$numAnnouncementsHomepage}

{* Additional Homepage Content *}
{if $additionalHomeContent}
Expand Down
2 changes: 2 additions & 0 deletions templates/frontend/pages/indexSite.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
</div>
{/if}

{include file="frontend/objects/announcements_list.tpl" numAnnouncements=$numAnnouncementsHomepage}

<div class="servers">
<h2>
{translate key="context.contexts"}
Expand Down

0 comments on commit 63cb9c9

Please sign in to comment.