addOption('baseColour', 'colour', array( 'label' => 'plugins.themes.healthSciences.option.colour.label', 'description' => 'plugins.themes.healthSciences.option.colour.description', 'default' => '#10BECA', )); // Update colour based on theme option $additionalLessVariables = []; if ($this->getOption('baseColour') !== '#10BECA') { $additionalLessVariables[] = '@primary:' . $this->getOption('baseColour') . ';'; if (!$this->isColourDark($this->getOption('baseColour'))) { $additionalLessVariables[] = '@primary-light: desaturate(lighten(@primary, 41%), 15%);'; $additionalLessVariables[] = '@primary-text: darken(@primary, 15%);'; } } // Load dependencies from CDN if (Config::getVar('general', 'enable_cdn')) { $this->addStyle( 'fonts', 'https://fonts.googleapis.com/css?family=Droid+Serif:200,200i,400,400i|Fira+Sans:300,300i,400,400i,700,700i', array('baseUrl' => '') ); $this->addStyle( 'bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css', array('baseUrl' => '') ); $this->addStyle( 'fontawesome', 'https://use.fontawesome.com/releases/v5.2.0/css/all.css', array('baseUrl' => '') ); $this->addScript( 'jquery', 'https://code.jquery.com/jquery-3.3.1.min.js', array('baseUrl' => '') ); $this->addScript( 'popper', 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js', array('baseUrl' => '') ); $this->addScript( 'bootstrap', 'https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js', array('baseUrl' => '') ); // Load local copies of dependencies if CDNs are not allowed } else { $this->addStyle('bootstrap', 'libs/bootstrap.min.css'); $this->addScript('jquery', 'libs/jquery-3.3.1.min.js'); $this->addScript('popper', 'libs/popper.min.js'); $this->addScript('bootstrap', 'libs/bootstrap.min.js'); } // Load theme stylesheet and script $this->addStyle('stylesheet', 'styles/index.less'); $this->modifyStyle('stylesheet', array('addLessVariables' => join($additionalLessVariables))); $this->addScript('main', 'js/main.js'); // Add JQuery UI and tag-it libraries for registration page (reviewer's interests) $this->addScript("jquery-ui", "libs/jquery-ui.min.js"); $this->addScript("tag-it", "libs/tag-it.min.js"); // Add navigation menu areas for this theme $this->addMenuArea(array('primary', 'user')); // Get extra data for templates HookRegistry::register ('TemplateManager::display', array($this, 'loadTemplateData')); // Check if CSS embedded to the HTML galley HookRegistry::register('TemplateManager::display', array($this, 'hasEmbeddedCSS')); } /** * Get the display name of this theme * @return string */ public function getDisplayName() { return __('plugins.themes.healthSciences.name'); } /** * Get the description of this plugin * @return string */ public function getDescription() { return __('plugins.themes.healthSciences.description'); } /** * Load custom data for templates * * @param string $hookName * @param array $args [ * @option TemplateManager * @option string Template file requested * @option string * @option string * @option string output HTML * ] */ public function loadTemplateData($hookName, $args) { $templateMgr = $args[0]; $request = Application::getRequest(); $context = $request->getContext(); if (!defined('SESSION_DISABLE_INIT')) { // Get possible locales if ($context) { $locales = $context->getSupportedLocaleNames(); } else { $locales = $request->getSite()->getSupportedLocaleNames(); } // Load login form $loginUrl = $request->url(null, 'login', 'signIn'); if (Config::getVar('security', 'force_login_ssl')) { $loginUrl = PKPString::regexp_replace('/^http:/', 'https:', $loginUrl); } $orcidImage = $this->getPluginPath() . '/templates/images/orcid.png'; $templateMgr->assign(array( 'languageToggleLocales' => $locales, 'loginUrl' => $loginUrl, 'brandImage' => 'templates/images/ojs_brand_white.png', 'orcidImage' => $orcidImage, )); } } public function hasEmbeddedCSS($hookName, $args) { $templateMgr = $args[0]; $template = $args[1]; $request = $this->getRequest(); // Retun false if not a galley page if ($template != 'plugins/plugins/generic/htmlArticleGalley/generic/htmlArticleGalley:display.tpl') return false; $articleArrays = $templateMgr->get_template_vars('article'); $boolEmbeddedCss = false; foreach ($articleArrays->getGalleys() as $galley) { if ($galley->getFileType() === 'text/html') { $submissionFile = $galley->getFile(); $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); import('lib.pkp.classes.submission.SubmissionFile'); // Constants $embeddableFiles = array_merge( $submissionFileDao->getLatestRevisions($submissionFile->getSubmissionId(), SUBMISSION_FILE_PROOF), $submissionFileDao->getLatestRevisionsByAssocId(ASSOC_TYPE_SUBMISSION_FILE, $submissionFile->getFileId(), $submissionFile->getSubmissionId(), SUBMISSION_FILE_DEPENDENT) ); foreach ($embeddableFiles as $embeddableFile) { if ($embeddableFile->getFileType() == 'text/css') { $boolEmbeddedCss = true; } } } } $templateMgr->assign(array( 'boolEmbeddedCss' => $boolEmbeddedCss, 'themePath' => $request->getBaseUrl() . "/" . $this->getPluginPath(), )); } }