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