Skip to content

Commit

Permalink
#126 Fix fatal error on adding js to article page
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaliy-1 committed Jan 6, 2021
1 parent 1780c34 commit 98f53bf
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions OldGreggThemePlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,6 @@ public function init()
$this->addScript('fontawesome', 'resources/js/fontawesome-all.min.js');
$this->addScript('main', 'resources/js/main.js');

$request = $this->getRequest();
if ($request->getRequestedPage() == "article" && (is_array($request->getRequestedArgs()) && count($request->getRequestedArgs()) == 1)) {
$this->addScript("article", "resources/js/article.js");
}


$this->addStyle(
'my-custom-font1',
'//fonts.googleapis.com/css?family=Lora',
Expand All @@ -97,6 +91,7 @@ public function init()
HookRegistry::register('TemplateManager::display', array($this, 'journalDescription'), HOOK_SEQUENCE_NORMAL);
HookRegistry::register('TemplateManager::display', array($this, 'categoriesJournalIndex'), HOOK_SEQUENCE_NORMAL);
HookRegistry::register('TemplateManager::display', array($this, 'articleSection'));
HookRegistry::register('TemplateManager::display', array($this, 'articleJs'));
}


Expand Down Expand Up @@ -151,7 +146,7 @@ public function browseLatest($hookName, $args)
function sitewideData($hookName, $args) {
$smarty = $args[0];

$orcidImagePath = $this->request->getBaseUrl() . DIRECTORY_SEPARATOR . $this->getTemplatePath() . DIRECTORY_SEPARATOR . "images" . DIRECTORY_SEPARATOR . "orcid.png";
$orcidImagePath = $this->getRequest()->getBaseUrl() . DIRECTORY_SEPARATOR . $this->getTemplatePath() . DIRECTORY_SEPARATOR . "images" . DIRECTORY_SEPARATOR . "orcid.png";
$smarty->assign('orcidImagePath', $orcidImagePath);
}

Expand Down Expand Up @@ -373,6 +368,21 @@ public function articleSection($hookName, $args) {
'section' => $section
]);
}

/**
* @param $hookName
* @param $args
* Adds javascript file to the article landing page & (temporary) galley page
*/
public function articleJs($hookName, $args) {
$templateMgr = $args[0];
$template = $args[1];

if ($template != 'frontend/pages/article.tpl' && $template != 'plugins-plugins-generic-jatsParser-generic-jatsParser:articleGalleyView.tpl') return;

$request = $this->getRequest();
$templateMgr->addJavascript('article', $request->getBaseUrl() . '/' . $this->getPluginPath() . '/resources/js/article.js');
}
}

?>

0 comments on commit 98f53bf

Please sign in to comment.