-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathInlineHtmlGalleyBlockPlugin.php
132 lines (115 loc) · 3.13 KB
/
InlineHtmlGalleyBlockPlugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
/**
* @file plugins/generic/inlineHtmlGalley/InlineHtmlGalleyBlockPlugin.inc.php
*
* Copyright (c) University of Pittsburgh
* Distributed under the GNU GPL v2 or later. For full terms see the file docs/COPYING.
*
* @class InlineHtmlGalleyBlockPlugin
* @ingroup plugins_generic_inlineHtmlGalley
*
* @brief Class for Inline HTML Galley block plugin
*/
namespace APP\plugins\generic\inlineHtmlGalley;
use PKP\plugins\BlockPlugin;
use PKP\config\Config;
use PKP\plugins\PluginRegistry;
class InlineHtmlGalleyBlockPlugin extends BlockPlugin {
/** @var $parentPluginName string name of InlineHtmlGalley plugin */
var $parentPluginName;
/** @var $pluginPath string path to InlineHtmlGalley plugins */
var $pluginPath;
/**
* Constructor
* @param $parentPluginName string
* @param $pluginPath string
*/
function __construct($parentPluginName, $pluginPath) {
parent::__construct();
$this->parentPluginName = $parentPluginName;
$this->pluginPath = $pluginPath;
}
/**
* Override currentVersion to prevent upgrade and delete management.
* @return boolean
*/
function getCurrentVersion() {
return false;
}
/**
* @copydoc LazyLoadPlugin::getEnabled()
*/
function getEnabled($contextId = null) {
if (!Config::getVar('general', 'installed')) return true;
return parent::getEnabled($contextId);
}
/**
* Get the display name of this plugin.
* @return String
*/
function getDisplayName() {
return __('plugins.generic.inlineHtmlGalley.block.download.displayName');
}
/**
* Get a description of the plugin.
* @return String
*/
function getDescription() {
return __('plugins.generic.inlineHtmlGalley.block.download.description');
}
/**
* Hide this plugin from the management interface (it's subsidiary)
* @return boolean
*/
function getHideManagement() {
return true;
}
/**
* Get the supported contexts (e.g. BLOCK_CONTEXT_...) for this block.
* @return array
*/
function getSupportedContexts() {
return array(BLOCK_CONTEXT_SIDEBAR);
}
/**
* Get the parent plugin
* @return object
*/
function &getParentPlugin() {
$plugin = PluginRegistry::getPlugin('generic', $this->parentPluginName);
return $plugin;
}
/**
* Override the builtin to get the correct plugin path.
* @return string
*/
function getPluginPath() {
return $this->pluginPath;
}
/**
* Get the name of the block template file.
* @return String
*/
function getBlockTemplateFilename() {
return 'blockDownload.tpl';
}
/**
* @copydoc BlockPlugin::getContents()
*/
function getContents($templateMgr, $request = null) {
if ($templateMgr && $request) {
$router = $request->getRouter();
if ($router->getRequestedPage($request) === 'article' && $router->getRequestedOp($request) === 'view') {
$submission = $templateMgr->getTemplateVars('article');
$galley = $templateMgr->getTemplateVars('galley');
if ($submission && $galley && $galley->getFileType() == 'text/html') {
$templateMgr->assign('submissionId', $submission->getBestArticleId());
$templateMgr->assign('galleyId', $galley->getBestGalleyId());
return parent::getContents($templateMgr);
}
}
}
return false;
}
}
?>