Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.4 updates #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
70 changes: 0 additions & 70 deletions InlineHtmlGalleySettingsForm.inc.php

This file was deleted.

74 changes: 74 additions & 0 deletions InlineHtmlGalleySettingsForm.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php

/**
* @file plugins/generic/inlineHtmlGalley/InlineHtmlGalleySettingsForm.inc.php
*
* Copyright (c) University of Pittsburgh
* Distributed under the GNU GPL v2 or later. For full terms see the file docs/COPYING.
*
* @class InlineHtmlGalleySettingsForm
* @ingroup plugins_generic_inlineHtmlGalley
*
* @brief Form to provide settings for the InlineHtmlGalley plugin
*/
namespace APP\plugins\generic\inlineHtmlGalley;

use PKP\form\Form;
use PKP\form\validation\FormValidatorPost;
use PKP\form\validation\FormValidatorCSRF;
use APP\template\TemplateManager;

class InlineHtmlGalleySettingsForm extends Form {

/** @var $plugin InlineHtmlGalleyPlugin */
var $plugin;

/** @var $contextId int */
var $contextId;

/**
* Constructor
* @param $plugin InlineHtmlGalleyPlugin
* @param $contextId int
*/
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));
$this->addCheck(new FormValidatorCSRF($this));
}

/**
* @copydoc Form::initData()
*/
function initData() {
$this->setData('xpath', $this->plugin->getSetting($this->contextId, 'xpath'));
}

/**
* @copydoc Form::readInputData()
*/
function readInputData() {
$this->readUserVars(array('xpath'));
}

/**
* @copydoc Form::fetch()
*/
function fetch($request, $template = null, $display = false) {
$templateMgr = TemplateManager::getManager($request);
$templateMgr->assign('pluginName', $this->plugin->getName());

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

/**
* @copydoc Form::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,14 +11,15 @@
*
* @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();
abstract function blockName();

/**
/**
* Get the display name of this plugin.
* @return String
*/
Expand All @@ -45,79 +46,79 @@ function getBlockTemplateFilename() {
}

class InlineHtmlGalleyAuthorsSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "authors";
}
function blockName() {
return "authors";
}
}

class InlineHtmlGalleyKeywordsSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "keywords";
}
function blockName() {
return "keywords";
}
}

class InlineHtmlGalleyDoiSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "doi";
}
function blockName() {
return "doi";
}

/**
/**
* @copydoc BlockPlugin::getContents()
*/
function getContents($templateMgr, $request = null) {
if ($templateMgr && $request) {
$pubIdPlugins = $templateMgr->getTemplateVars('pubIdPlugins');
if ($pubIdPlugins) {
foreach ($pubIdPlugins as $pubIdPlugin) {
if ($pubIdPlugin->getPubIdType() == 'doi') {
return parent::getContents($templateMgr, $request);
}
}
}
}

return false;
}
if ($templateMgr && $request) {
$pubIdPlugins = $templateMgr->getTemplateVars('pubIdPlugins');
if ($pubIdPlugins) {
foreach ($pubIdPlugins as $pubIdPlugin) {
if ($pubIdPlugin->getPubIdType() == 'doi') {
return parent::getContents($templateMgr, $request);
}
}
}
}

return false;
}
}

class InlineHtmlGalleyCoverImageSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "coverImage";
}
function blockName() {
return "coverImage";
}
}

class InlineHtmlGalleyDetailsSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "details";
}
function blockName() {
return "details";
}
}

class InlineHtmlGalleyPublishedDateSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "publishedDate";
}
function blockName() {
return "publishedDate";
}
}

class InlineHtmlGalleyHowToCiteSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "howToCite";
}
function blockName() {
return "howToCite";
}
}

class InlineHtmlGalleyLicenseSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "license";
}
function blockName() {
return "license";
}
}

class InlineHtmlGalleyReferencesSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "references";
}
function blockName() {
return "references";
}
}

class InlineHtmlGalleyGalleysSidebarBlockPlugin extends InlineHtmlGalleySidebarBlockPlugin {
function blockName() {
return "galleys";
}
function blockName() {
return "galleys";
}
}
Loading