Skip to content

Commit

Permalink
Merge pull request #13 from ulsdevteam/3.4_Updates
Browse files Browse the repository at this point in the history
3.4 updates
  • Loading branch information
trp89 authored Dec 19, 2024
2 parents 2a7a4f3 + 24abf23 commit fe70cd6
Show file tree
Hide file tree
Showing 25 changed files with 298 additions and 578 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
*
* @brief Class for Inline HTML Galley block plugin
*/
namespace APP\plugins\generic\inlineHtmlGalley;

import('lib.pkp.classes.plugins.BlockPlugin');
use PKP\plugins\BlockPlugin;
use PKP\config\Config;
use PKP\plugins\PluginRegistry;

class InlineHtmlGalleyBlockPlugin extends BlockPlugin {

Expand Down
29 changes: 21 additions & 8 deletions InlineHtmlGalleyPlugin.inc.php → InlineHtmlGalleyPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,24 @@
*
* @brief Class for InlineHtmlGalley plugin
*/
namespace APP\plugins\generic\inlineHtmlGalley;

import('plugins.generic.htmlArticleGalley.HtmlArticleGalleyPlugin');
use PKP\plugins\PluginRegistry;
use PKP\linkAction\LinkAction;
use PKP\linkAction\request\AjaxModal;
use PKP\core\JSONMessage;
use PKP\plugins\Hook;
use PKP\core\Core;
use Exception;
use DOMDocument;
use DOMXPath;
use APP\plugins\generic\htmlArticleGalley\HtmlArticleGalleyPlugin;
use APP\plugins\generic\inlineHtmlGalley\InlineHtmlGalleyBlockPlugin;
use APP\plugins\generic\inlineHtmlGalley\InlineHtmlGalleySidebarBlockPlugin;
use APP\plugins\generic\inlineHtmlGalley\InlineHtmlGalleySettingsForm;
use APP\template\TemplateManager;

include "InlineHtmlGalleySidebarBlockPlugin.php";

class InlineHtmlGalleyPlugin extends HtmlArticleGalleyPlugin {
/**
Expand All @@ -25,13 +41,11 @@ function register($category, $path, $mainContextId = null) {
if (!$success) return false;
if ($success && $this->getEnabled()) {
// Load this plugin as a block plugin as well
$this->import('InlineHtmlGalleyBlockPlugin');
PluginRegistry::register(
'blocks',
new InlineHtmlGalleyBlockPlugin($this->getName(), $this->getPluginPath()),
$this->getPluginPath()
);
$this->import('InlineHtmlGalleySidebarBlockPlugin');
PluginRegistry::register(
'blocks',
new InlineHtmlGalleyAuthorsSidebarBlockPlugin($this->getName(), $this->getPluginPath()),
Expand Down Expand Up @@ -82,8 +96,8 @@ function register($category, $path, $mainContextId = null) {
new InlineHtmlGalleyGalleysSidebarBlockPlugin($this->getName(), $this->getPluginPath()),
$this->getPluginPath()
);
HookRegistry::register('ArticleHandler::view', array($this, 'articleViewCallback'), HOOK_SEQUENCE_LATE);
HookRegistry::register('TemplateResource::getFilename', array($this, '_overridePluginTemplates'), HOOK_SEQUENCE_CORE);
Hook::add('ArticleHandler::view', array($this, 'articleViewCallback'), HOOK_SEQUENCE_LATE);
Hook::add('TemplateResource::getFilename', array($this, '_overridePluginTemplates'), HOOK_SEQUENCE_CORE);
}

return true;
Expand Down Expand Up @@ -114,6 +128,7 @@ function articleViewCallback($hookName, $args) {
$request =& $args[0];
$issue =& $args[1];
$article =& $args[2];
$publication = $args[3];
$galleys = $article->getGalleys();
if (!$galleys) return false;

Expand All @@ -123,14 +138,14 @@ function articleViewCallback($hookName, $args) {
$templateMgr->assign(array(
'issue' => $issue,
'article' => $article,
'publication' => $publication,
'galley' => $galley,
'orcidIcon' => $this->getOrcidIcon()
));
$inlineHtmlGalley = $this->_getHTMLContents($request, $galley);
$inlineHtmlGalleyBody = $this->_extractBodyContents($inlineHtmlGalley, $request->getContext()->getId());
$templateMgr->assign('inlineHtmlGalley', $inlineHtmlGalleyBody);
$templateMgr->display($this->getTemplateResource('displayInline.tpl'));

return true;
}
}
Expand Down Expand Up @@ -194,7 +209,6 @@ function getOrcidIcon() {
* @copydoc Plugin::manage()
*/
function manage($args, $request) {
$this->import('InlineHtmlGalleySettingsForm');
if ($request->getUserVar('verb') == 'settings') {
$settingsForm = new InlineHtmlGalleySettingsForm($this, $request->getContext()->getId());
if ($request->getUserVar('save')) {
Expand All @@ -216,7 +230,6 @@ function manage($args, $request) {
*/
function getActions($request, $verb) {
$router = $request->getRouter();
import('lib.pkp.classes.linkAction.request.AjaxModal');
return array_merge(
$this->getEnabled()?array(
new LinkAction(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
*
* @brief Form to provide settings for the InlineHtmlGalley plugin
*/
namespace APP\plugins\generic\inlineHtmlGalley;

import('lib.pkp.classes.form.Form');
use PKP\form\Form;
use PKP\form\validation\FormValidatorPost;
use PKP\form\validation\FormValidatorCSRF;
use APP\template\TemplateManager;

class InlineHtmlGalleySettingsForm extends Form {

Expand All @@ -30,7 +34,7 @@ class InlineHtmlGalleySettingsForm extends Form {
function __construct($plugin, $contextId) {
$this->plugin = $plugin;
$this->contextId = $contextId;

parent::__construct(method_exists($plugin, 'getTemplateResource') ? $plugin->getTemplateResource('settingsForm.tpl') : $plugin->getTemplatePath() . 'settingsForm.tpl');

$this->addCheck(new FormValidatorPost($this));
Expand All @@ -54,17 +58,17 @@ function readInputData() {
/**
* @copydoc Form::fetch()
*/
function fetch($request) {
function fetch($request, $template = null, $display = false) {
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('pluginName', $this->plugin->getName());

return parent::fetch($request);
return parent::fetch($request, $template, $display);
}

/**
* @copydoc Form::execute()
*/
function execute() {
function execute(...$functionArgs) {
$this->plugin->updateSetting($this->contextId, 'xpath', $this->getData('xpath'));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,36 +11,37 @@
*
* @brief Class for Inline HTML Galley sidebar block plugin
*/
namespace APP\plugins\generic\inlineHtmlGalley;

import('plugins.generic.inlineHtmlGalley.InlineHtmlGalleyBlockPlugin');
use APP\plugins\generic\inlineHtmlGalley\InlineHtmlGalleyBlockPlugin;

abstract class InlineHtmlGalleySidebarBlockPlugin extends InlineHtmlGalleyBlockPlugin {

abstract function blockName();

/**
* Get the display name of this plugin.
* @return String
*/
function getDisplayName() {
return __('plugins.generic.inlineHtmlGalley.block.' . $this->blockName() . '.displayName');
}
* Get the display name of this plugin.
* @return String
*/
function getDisplayName() {
return __('plugins.generic.inlineHtmlGalley.block.' . $this->blockName() . '.displayName');
}

/**
* Get a description of the plugin.
* @return String
*/
function getDescription() {
return __('plugins.generic.inlineHtmlGalley.block.' . $this->blockName() . '.description');
/**
* Get a description of the plugin.
* @return String
*/
function getDescription() {
return __('plugins.generic.inlineHtmlGalley.block.' . $this->blockName() . '.description');
}

/**
* Get the name of the block template file.
* @return String
*/
function getBlockTemplateFilename() {
return 'block' . ucfirst($this->blockName()) . '.tpl';
}
/**
* Get the name of the block template file.
* @return String
*/
function getBlockTemplateFilename() {
return 'block' . ucfirst($this->blockName()) . '.tpl';
}

}

Expand All @@ -62,9 +63,9 @@ function blockName() {
}

/**
* @copydoc BlockPlugin::getContents()
*/
function getContents($templateMgr, $request = null) {
* @copydoc BlockPlugin::getContents()
*/
function getContents($templateMgr, $request = null) {
if ($templateMgr && $request) {
$pubIdPlugins = $templateMgr->getTemplateVars('pubIdPlugins');
if ($pubIdPlugins) {
Expand Down
23 changes: 0 additions & 23 deletions index.php

This file was deleted.

File renamed without changes.
File renamed without changes.
94 changes: 21 additions & 73 deletions templates/blockAuthors.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,83 +8,31 @@
*
* @uses $boolAuthorInfo bool to check whether at least one author has additional info
*}
{* authors list *}
{if $article->getAuthors()}

{if count($publication->getData('authors'))}
<div class="pkp_block block_inline_html_authors">
<span class="title">
{translate key="submission.authors"}
{translate key="submission.authors"}
</span>
<div class="content">
<div class="authors_info">
<ul class="entry_authors_list">
{strip}
{foreach from=$article->getAuthors() item=author key=authorNumber}
<li class="entry_author_block{if $authorNumber > 4} limit-for-mobiles{elseif $authorNumber === 4} fifth-author{/if}">
{if $author->getOrcid()}
<a class="orcid-image-url" href="{$author->getOrcid()}">{$orcidIcon}</a>
{/if}
<span class="name_wrapper">
{$author->getFullName()|escape}
</span>
{if $authorNumber+1 !== $article->getAuthors()|@count}
<span class="author-delimiter">, </span>
{/if}
</li>
{/foreach}
{if $article->getAuthors()|@count > 4}
<span class="collapse-authors" id="show-all-authors"><ion-icon name="add-circle"></ion-icon></span>
<span class="collapse-authors hide" id="hide-authors"><ion-icon name="remove-circle"></ion-icon></ion-icon></span>
{/if}
{/strip}
</ul>
</div>
<div class="additional-authors-info">
{if $boolAuthorInfo}
<a class="more-authors-info-button" id="collapseButton" data-toggle="collapse" href="#authorInfoCollapse" role="button" aria-expanded="false" aria-controls="authorInfoCollapse">
<ion-icon name="add" class="ion_icon" id="more-authors-data-symbol"></ion-icon>
<ion-icon name="remove" class="ion_icon hide" id="less-authors-data-symbol"></ion-icon>
<span class="ion-icon-text">{translate key="plugins.themes.classic.more-info"}</span>
</a>
{/if}
<div class="collapse" id="authorInfoCollapse">
{foreach from=$article->getAuthors() item=author key=number}
<div class="additional-author-block">
{if $author->getLocalizedAffiliation() || $author->getLocalizedBiography()}
<span class="additional-author-name">{$author->getFullName()|escape}</span>
{/if}
{if $author->getLocalizedAffiliation()}
<br/>
<span class="additional-author-affiliation">{$author->getLocalizedAffiliation()|escape}</span>
{/if}
{if $author->getLocalizedBiography()}
<br/>
<a class="more_button" data-toggle="modal" data-target="#modalAuthorBio-{$number}">
{translate key="plugins.themes.classic.biography"}
</a>
{* author's biography *}
<div class="modal fade" id="modalAuthorBio-{$number}" tabindex="-1" role="dialog" aria-labelledby="modalAuthorBioTitle" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalAuthorBioTitle">{translate key="submission.authorBiography"}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
{$author->getLocalizedBiography()|strip_unsafe_html}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" data-dismiss="modal">{translate key="plugins.themes.classic.close"}</button>
</div>
</div>
</div>
</div>
{/if}
<div class="authors">
{foreach from=$publication->getData('authors') item=author}
<div class="author">
<strong>{$author->getFullName()|escape}</strong>
{if $author->getLocalizedAffiliation()}
<div class="article-author-affilitation">
{$author->getLocalizedAffiliation()|escape}
</div>
{/foreach}
{/if}
{if $author->getOrcid()}
<div class="orcid">
{$orcidIcon}
<a href="{$author->getOrcid()|escape}" target="_blank">
{$author->getOrcid()|escape}
</a>
</div>
{/if}
</div>
</div>
{/foreach}
</div>
</div>
{/if}
{/if}
37 changes: 23 additions & 14 deletions templates/blockCoverImage.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,26 @@
* Inline HTML Galley Cover Image block
*
*}
{* Article/Issue cover image *}
{if $article->getLocalizedCoverImage() || $issue->getLocalizedCoverImage()}
<div class="pkp_block block_inline_html_cover_image">
<div class="article_cover_wrapper">
{if $article->getLocalizedCoverImage()}
<img class="img-fluid img-responsive" src="{$article->getLocalizedCoverImageUrl()|escape}"{if $article->getLocalizedCoverImageAltText()} alt="{$article->getLocalizedCoverImageAltText()|escape}"{/if}>
{else}
<a href="{url page="issue" op="view" path=$issue->getBestIssueId()}">
<img class="img-fluid img-responsive" src="{$issue->getLocalizedCoverImageUrl()|escape}"{if $issue->getLocalizedCoverImageAltText()} alt="{$issue->getLocalizedCoverImageAltText()|escape}"{/if}>
</a>
{/if}
</div>
</div>
{/if}

{if $publication->getLocalizedData('coverImage') || ($issue && $issue->getLocalizedCoverImage())}
<div class="pkp_block block_inline_html_cover_image">
<div class="cover-image">
{if $publication->getLocalizedData('coverImage')}
{assign var="coverImage" value=$publication->getLocalizedData('coverImage')}
<img
class="img-responsive"
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-responsive"
src="{$issue->getLocalizedCoverImageUrl()|escape}"
alt="{$issue->getLocalizedCoverImageAltText()|escape|default:''}"
>
</a>
{/if}
</div>
</div>
{/if}
Loading

0 comments on commit fe70cd6

Please # to comment.