Hello all,
I’m writing a plugin for OJS 2 that adds a JQuery/Javascript tag to the <HEAD>
area of the pages, wrapping the logotype image, if available, with an <A>
tag with the link that is defined in the locale files. To customize the link, enable the Custom Translator Plugin and modify the plugin’s URL translation key.
My URL For Logo Plugin installed fine, but system went down.
Once I removed the folder from OJS, system got back online.
I used the TinyMCE generic plugin as a base and removed what I thought was unnecessary, but I’m not sure if anything is missing.
I’m sure there’s a typo, coding error somewhere, but, it’s beyond me…
<?php
/**
* @file plugins/generic/urlforlogo/UrlForLogoPlugin.inc.php
*
* Copyright (c) 2013-2016 Simon Fraser University Library
* Copyright (c) 2003-2016 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class UrlForLogoPlugin
* @ingroup plugins_generic_urlforlogo
*
* @brief urlforlogo WYSIWYG plugin for textareas - to allow cross-browser HTML editing
*/
import('lib.pkp.classes.plugins.GenericPlugin');
class UrlForLogoPlugin extends GenericPlugin {
/**
* Register the plugin, if enabled; note that this plugin
* runs under both Journal and Site contexts.
* @param $category string
* @param $path string
* @return boolean
*/
function register($category, $path) {
if (parent::register($category, $path)) {
if ($this->getEnabled()) {
HookRegistry::register('TemplateManager::display',array(&$this, 'callback'));
}
return true;
}
return false;
}
/**
* Get the name of the settings file to be installed on new journal
* creation.
* @return string
*/
function getContextSpecificPluginSettingsFile() {
return $this->getPluginPath() . '/settings.xml';
}
/**
* Get the name of the settings file to be installed site-wide when
* OJS is installed.
* @return string
*/
function getInstallSitePluginSettingsFile() {
return $this->getPluginPath() . '/settings.xml';
}
/**
* Hook callback function for TemplateManager::display
* @param $hookName string
* @param $args array
* @return boolean
*/
function callback($hookName, $args) {
$baseUrl = $templateManager->get_template_vars('baseUrl');
$additionalHeadData = $templateManager->get_template_vars('additionalHeadData');
$logoUrl = ._return('plugins.generic.urlforlogo.url');
$allLocales = AppLocale::getAllLocales();
$localeList = array();
foreach ($allLocales as $key => $locale) {
$localeList[] = String::substr($key, 0, 2);
}
$urlforlogoScript = '
<script language="javascript" type="text/javascript">
$("#header").children("h1").children("img.first").wrap($("<a>",{
href:"'.$logoUrl.'"
}));
</script>';
$templateManager->assign('additionalHeadData', $additionalHeadData."\n".$urlforlogoScript);
return false;
}
/**
* Get the display name of this plugin
* @return string
*/
function getDisplayName() {
return __('plugins.generic.urlforlogo.name');
}
/**
* Get the description of this plugin
* @return string
*/
function getDescription() {
return __('plugins.generic.urlforlogo.description');
}
/**
* Get a list of available management verbs for this plugin
* @return array
*/
function getManagementVerbs() {
$verbs = array();
parent::getManagementVerbs();
return $verbs;
}
}
?>