/** * Add the tinyMCE script for editing sidebar blocks with a WYSIWYG editor */ function addTinyMCE() { $journalId = $this->journalId; $plugin =& $this->plugin; $templateMgr =& TemplateManager::getManager(); // Enable TinyMCE with specific params $additionalHeadData = $templateMgr->get_template_vars('additionalHeadData'); import('classes.file.JournalFileManager'); $publicFileManager = new PublicFileManager(); $tinyMCE_script = ' <script language="javascript" type="text/javascript" src="' . Request::getBaseUrl() . '/' . TINYMCE_JS_PATH . '/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "textareas", plugins : "style,paste", theme : "advanced", theme_advanced_buttons1 : "formatselect,fontselect,fontsizeselect", theme_advanced_buttons2 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright, justifyfull,bullist,numlist,undo,redo,link,unlink", theme_advanced_buttons3 : "cut,copy,paste,pastetext,pasteword,|,cleanup,help,code,", theme_advanced_toolbar_location : "bottom", theme_advanced_toolbar_align : "left", content_css : "' . Request::getBaseUrl() . '/styles/common.css", relative_urls : false, document_base_url : "' . Request::getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journalId) . '/", extended_valid_elements : "span[*], div[*]" }); </script>'; $templateMgr->assign('additionalHeadData', $additionalHeadData . "\n" . $tinyMCE_script); }
/** * Public view book for review details. */ function viewBookForReview($args = array(), &$request) { $this->setupTemplate(true); $journal =& $request->getJournal(); $journalId = $journal->getId(); $bfrPlugin =& PluginRegistry::getPlugin('generic', BOOKS_FOR_REVIEW_PLUGIN_NAME); $bookId = !isset($args) || empty($args) ? null : (int) $args[0]; $bfrDao =& DAORegistry::getDAO('BookForReviewDAO'); // Ensure book for review is valid and for this journal if ($bfrDao->getBookForReviewJournalId($bookId) == $journalId) { $book =& $bfrDao->getBookForReview($bookId); $bfrPlugin->import('classes.BookForReview'); // Ensure book is still available if ($book->getStatus() == BFR_STATUS_AVAILABLE) { $isAuthor = Validation::isAuthor(); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = $request->getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/'; $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('coverPagePath', $coverPagePath); $templateMgr->assign('locale', AppLocale::getLocale()); $templateMgr->assign_by_ref('bookForReview', $book); $templateMgr->assign('isAuthor', $isAuthor); $templateMgr->display($bfrPlugin->getTemplatePath() . 'bookForReview.tpl'); } } $request->redirect(null, 'booksForReview'); }
/** * Get the file path to this plugin's stylesheet. * @return String stylesheet path */ function getStylesheetPath() { $journal =& Request::getJournal(); if ($this->getSetting($journal->getId(), 'customThemePerJournal')) { import('classes.file.PublicFileManager'); $fileManager = new PublicFileManager(); return $fileManager->getJournalFilesPath($journal->getId()); } else { return $this->getPluginPath(); } }
/** * Get the filename of the CSS stylesheet for this plugin. */ function getStyleSheetFile() { $journal =& Request::getJournal(); $journalId = $journal ? $journal->getId() : 0; $styleSheet = $this->getSetting($journalId, 'externalFeedStyleSheet'); if (empty($styleSheet)) { return $this->getDefaultStyleSheetFile(); } else { import('classes.file.PublicFileManager'); $fileManager = new PublicFileManager(); return $fileManager->getJournalFilesPath($journalId) . '/' . $styleSheet['uploadName']; } }
/** * Get pages social meta tags * @return social tags string */ function getPageSocialMetaTags() { $journal = Request::getJournal(); $title = $journal->getLocalizedTitle(); $type = 'webpage'; $url = Request::url(); $description = str_replace('"', '', $journal->getLocalizedDescription()); $description = strip_tags($description); $description = $this->truncate($description, 140); if ($journal->getLocalizedPageHeaderLogo()) { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = Request::getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journal->getId()) . '/'; $pageHeaderLogo = $journal->getLocalizedPageHeaderLogo(); $journalImage = $coverPagePath . $pageHeaderLogo['uploadName']; } elseif ($journal->getLocalizedPageHeaderTitle()) { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = Request::getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journal->getId()) . '/'; $pageHeaderTitle = $journal->getLocalizedPageHeaderTitle(); $journalImage = $coverPagePath . $pageHeaderTitle['uploadName']; } else { $journalImage = NULL; } $tagsStr = "\n\n<!-- Open Graph -->\n"; $tagsStr .= '<meta property="og:title" content="' . $title . '" />' . "\n"; $tagsStr .= '<meta property="og:type" content="' . $type . '" />' . "\n"; $tagsStr .= '<meta property="og:url" content="' . $url . '" />' . "\n"; $tagsStr .= '<meta property="og:description" content="' . $description . '" />' . "\n"; if ($journalImage) { $tagsStr .= '<meta property="og:image" content="' . $journalImage . '" />' . "\n"; } $tagsStr .= "\n\n<!-- Twitter Cards -->\n"; $tagsStr .= '<meta name="twitter:card" content="summary" />' . "\n"; $tagsStr .= '<meta name="twitter:title" content="' . str_replace('"', '', $title) . '" />' . "\n"; $tagsStr .= '<meta name="twitter:description" content="' . $description . '" />' . "\n"; if ($journalImage) { $tagsStr .= '<meta name="twitter:image" content="' . $journalImage . '" />' . "\n"; } return $tagsStr; }
/** * Display the form */ function display() { $templateMgr =& TemplateManager::getManager(); $additionalHeadData = $templateMgr->get_template_vars('additionalHeadData'); $additionalHeadData .= '<script type="text/javascript" src="' . Request::getBaseUrl() . '/plugins/themes/custom/picker.js"></script>' . "\n"; $templateMgr->addStyleSheet(Request::getBaseUrl() . '/plugins/themes/custom/picker.css'); $templateMgr->assign('additionalHeadData', $additionalHeadData); $stylesheetFilePluginLocation = $this->plugin->getPluginPath() . '/' . $this->plugin->getStylesheetFilename(); if (!$this->_canUsePluginPath() || $this->plugin->getSetting($this->journalId, 'customThemePerJournal')) { if (!$this->_canUsePluginPath()) { $templateMgr->assign('disablePluginPath', true); $templateMgr->assign('stylesheetFilePluginLocation', $stylesheetFilePluginLocation); } import('classes.file.PublicFileManager'); $fileManager = new PublicFileManager(); $stylesheetFileLocation = $fileManager->getJournalFilesPath($this->journalId) . '/' . $this->plugin->getStylesheetFilename(); } else { $stylesheetFileLocation = $stylesheetFilePluginLocation; } $templateMgr->assign('canSave', $this->_is_writable($stylesheetFileLocation)); $templateMgr->assign('stylesheetFileLocation', $stylesheetFileLocation); return parent::display(); }
/** * Get a full URL to the localized cover image * * @return string */ function getLocalizedCoverImageUrl() { $coverImage = $this->getLocalizedCoverImage(); if (!$coverImage) { return ''; } $request = Application::getRequest(); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); return $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($this->getContextId()) . '/' . $coverImage; }
/** * Delete a journal. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function deleteContext($args, $request) { // Identify the journal Id. $journalId = $request->getUserVar('rowId'); $journalDao = DAORegistry::getDAO('JournalDAO'); $journal = $journalDao->getById($journalId); if ($journal) { $journalDao->deleteById($journalId); // Delete journal file tree // FIXME move this somewhere better. import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager($journalId); $journalPath = Config::getVar('files', 'files_dir') . '/journals/' . $journalId; $fileManager->rmtree($journalPath); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->rmtree($publicFileManager->getJournalFilesPath($journalId)); return DAO::getDataChangedEvent($journalId); } return new JSONMessage(false); }
/** * Save changes to article. * @param $request PKPRequest * @return int the article ID */ function execute(&$request) { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $authorDao =& DAORegistry::getDAO('AuthorDAO'); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $citationDao =& DAORegistry::getDAO('CitationDAO'); /* @var $citationDao CitationDAO */ $article =& $this->article; // Retrieve the previous citation list for comparison. $previousRawCitationList = $article->getCitations(); // Update article $article->setTitle($this->getData('title'), null); // Localized $section =& $sectionDao->getSection($article->getSectionId()); $article->setAbstract($this->getData('abstract'), null); // Localized import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if ($publicFileManager->uploadedFileExists(COVER_PAGE_IMAGE_NAME)) { $journal = Request::getJournal(); $originalFileName = $publicFileManager->getUploadedFileName(COVER_PAGE_IMAGE_NAME); $type = $publicFileManager->getUploadedFileType(COVER_PAGE_IMAGE_NAME); $newFileName = 'cover_article_' . $this->article->getId() . '_' . $this->getFormLocale() . $publicFileManager->getImageExtension($type); $publicFileManager->uploadJournalFile($journal->getId(), COVER_PAGE_IMAGE_NAME, $newFileName); $article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale()); $article->setFileName($newFileName, $this->getFormLocale()); // Store the image dimensions. list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newFileName); $article->setWidth($width, $this->getFormLocale()); $article->setHeight($height, $this->getFormLocale()); } $article->setCoverPageAltText($this->getData('coverPageAltText'), null); // Localized $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $showCoverPage)) { $showCoverPage[$locale] = 0; } } $article->setShowCoverPage($showCoverPage, null); // Localized $hideCoverPageToc = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageToc')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $hideCoverPageToc)) { $hideCoverPageToc[$locale] = 0; } } $article->setHideCoverPageToc($hideCoverPageToc, null); // Localized $hideCoverPageAbstract = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageAbstract')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $hideCoverPageAbstract)) { $hideCoverPageAbstract[$locale] = 0; } } $article->setHideCoverPageAbstract($hideCoverPageAbstract, null); // Localized $article->setDiscipline($this->getData('discipline'), null); // Localized $article->setSubjectClass($this->getData('subjectClass'), null); // Localized $article->setSubject($this->getData('subject'), null); // Localized $article->setCoverageGeo($this->getData('coverageGeo'), null); // Localized $article->setCoverageChron($this->getData('coverageChron'), null); // Localized $article->setCoverageSample($this->getData('coverageSample'), null); // Localized $article->setType($this->getData('type'), null); // Localized $article->setLanguage($this->getData('language')); // Localized $article->setSponsor($this->getData('sponsor'), null); // Localized $article->setCitations($this->getData('citations')); if ($this->isEditor) { $article->setHideAuthor($this->getData('hideAuthor') ? $this->getData('hideAuthor') : 0); } // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $article); // Update authors $authors = $this->getData('authors'); for ($i = 0, $count = count($authors); $i < $count; $i++) { if ($authors[$i]['authorId'] > 0) { // Update an existing author $author =& $authorDao->getAuthor($authors[$i]['authorId'], $article->getId()); $isExistingAuthor = true; } else { // Create a new author if (checkPhpVersion('5.0.0')) { // *5488* PHP4 Requires explicit instantiation-by-reference $author = new Author(); } else { $author =& new Author(); } $isExistingAuthor = false; } if ($author != null) { $author->setSubmissionId($article->getId()); $author->setFirstName($authors[$i]['firstName']); $author->setMiddleName($authors[$i]['middleName']); $author->setLastName($authors[$i]['lastName']); $author->setAffiliation($authors[$i]['affiliation'], null); // Localized $author->setCountry($authors[$i]['country']); $author->setEmail($authors[$i]['email']); $author->setData('orcid', $authors[$i]['orcid']); $author->setUrl($authors[$i]['url']); if (array_key_exists('competingInterests', $authors[$i])) { $author->setCompetingInterests($authors[$i]['competingInterests'], null); // Localized } $author->setBiography($authors[$i]['biography'], null); // Localized $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0); $author->setSequence($authors[$i]['seq']); HookRegistry::call('Submission::Form::MetadataForm::Execute', array(&$author, &$authors[$i])); if ($isExistingAuthor) { $authorDao->updateAuthor($author); } else { $authorDao->insertAuthor($author); } unset($author); } } // Remove deleted authors $deletedAuthors = preg_split('/:/', $this->getData('deletedAuthors'), -1, PREG_SPLIT_NO_EMPTY); for ($i = 0, $count = count($deletedAuthors); $i < $count; $i++) { $authorDao->deleteAuthorById($deletedAuthors[$i], $article->getId()); } if ($this->isEditor) { $article->setCopyrightHolder($this->getData('copyrightHolder'), null); $article->setCopyrightYear($this->getData('copyrightYear')); $article->setLicenseURL($this->getData('licenseURL')); } parent::execute(); // Save the article $articleDao->updateArticle($article); // Update search index import('classes.search.ArticleSearchIndex'); $articleSearchIndex = new ArticleSearchIndex(); $articleSearchIndex->articleMetadataChanged($article); $articleSearchIndex->articleChangesFinished(); // Update references list if it changed. $rawCitationList = $article->getCitations(); if ($previousRawCitationList != $rawCitationList) { $citationDao->importCitations($request, ASSOC_TYPE_ARTICLE, $article->getId(), $rawCitationList); } return $article->getId(); }
/** * View Article. (Either article landing page or galley view.) * @param $args array * @param $request Request */ function view($args, $request) { $articleId = array_shift($args); $galleyId = array_shift($args); $fileId = array_shift($args); $journal = $request->getJournal(); $issue = $this->issue; $article = $this->article; $templateMgr = TemplateManager::getManager($request); $templateMgr->assign(array('issue' => $issue, 'article' => $article, 'fileId' => $fileId)); $this->setupTemplate($request); if (!$this->userCanViewGalley($request, $articleId, $galleyId)) { fatalError('Cannot view galley.'); } // Fetch and assign the section to the template $sectionDao = DAORegistry::getDAO('SectionDAO'); $section = $sectionDao->getById($article->getSectionId(), $journal->getId(), true); $templateMgr->assign('section', $section); // Fetch and assign the galley to the template $galleyDao = DAORegistry::getDAO('ArticleGalleyDAO'); if ($journal->getSetting('enablePublicGalleyId')) { $galley = $galleyDao->getByBestGalleyId($galleyId, $article->getId()); } else { $galley = $galleyDao->getById($galleyId, $article->getId()); } if ($galley && $galley->getRemoteURL()) { $request->redirectUrl($galley->getRemoteURL()); } $templateMgr->assign('galley', $galley); // Copyright and license info if ($journal->getSetting('includeCopyrightStatement') && $journal->getLocalizedSetting('copyrightNotice')) { $templateMgr->assign(array('copyright' => $journal->getLocalizedSetting('copyrightNotice'), 'copyrightHolder' => $journal->getLocalizedSetting('copyrightHolder'), 'copyrightYear' => $journal->getSetting('copyrightYear'))); } if ($journal->getSetting('includeLicense') && $article->getLicenseURL()) { $templateMgr->assign(array('licenseUrl' => $article->getLicenseURL(), 'ccLicenseBadge' => Application::getCCLicenseBadge($article->getLicenseURL()))); } // Keywords $submissionKeywordDao = DAORegistry::getDAO('SubmissionKeywordDAO'); $templateMgr->assign('keywords', $submissionKeywordDao->getKeywords($article->getId(), array(AppLocale::getLocale()))); // Consider public identifiers $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true); $templateMgr->assign('pubIdPlugins', $pubIdPlugins); if (!$galley) { // No galley: Prepare the article landing page. // Get the subscription status if displaying the abstract; // if access is open, we can display links to the full text. import('classes.issue.IssueAction'); // The issue may not exist, if this is an editorial user // and scheduling hasn't been completed yet for the article. $issueAction = new IssueAction(); $subscriptionRequired = false; if ($issue) { $subscriptionRequired = $issueAction->subscriptionRequired($issue); } $subscribedUser = $issueAction->subscribedUser($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null); $subscribedDomain = $issueAction->subscribedDomain($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null); $templateMgr->assign('showGalleyLinks', !$subscriptionRequired || $journal->getSetting('showGalleyLinks')); $templateMgr->assign('hasAccess', !$subscriptionRequired || isset($article) && $article->getAccessStatus() == ARTICLE_ACCESS_OPEN || $subscribedUser || $subscribedDomain); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($request); if ($paymentManager->onlyPdfEnabled()) { $templateMgr->assign('restrictOnlyPdf', true); } if ($paymentManager->purchaseArticleEnabled()) { $templateMgr->assign('purchaseArticleEnabled', true); } // Article cover page. if (isset($article) && $article->getLocalizedFileName() && $article->getLocalizedShowCoverPage() && !$article->getLocalizedHideCoverPageAbstract()) { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $templateMgr->assign(array('coverPagePath' => $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId()) . '/', 'coverPageFileName' => $article->getLocalizedFileName(), 'width' => $article->getLocalizedWidth(), 'height' => $article->getLocalizedHeight(), 'coverPageAltText' => $article->getLocalizedCoverPageAltText())); } if (!HookRegistry::call('ArticleHandler::view', array(&$request, &$issue, &$article))) { return $templateMgr->display('frontend/pages/article.tpl'); } } else { // Galley: Prepare the galley file download. if (!HookRegistry::call('ArticleHandler::view::galley', array(&$request, &$issue, &$galley, &$article))) { $request->redirect(null, null, 'download', array($articleId, $galleyId)); } } }
/** * Public view object for review details. * @param $args array * @param $request PKPRequest */ function viewObjectForReview($args, &$request) { // Ensure the args (object ID) exists $objectId = array_shift($args); if (!$objectId) { $request->redirect(null, 'objectsForReview'); } $journal =& $request->getJournal(); $journalId = $journal->getId(); // Ensure the object exists $ofrDao =& DAORegistry::getDAO('ObjectForReviewDAO'); $objectForReview =& $ofrDao->getById($objectId, $journalId); if (!isset($objectForReview)) { $request->redirect(null, 'objectsForReview'); } // If object is available if ($objectForReview->getAvailable()) { // Get all metadata for the objects for review $reviewObjectTypeDao =& DAORegistry::getDAO('ReviewObjectTypeDAO'); $allTypes =& $reviewObjectTypeDao->getTypeIdsAlphabetizedByContext($journalId); $reviewObjectMetadataDao =& DAORegistry::getDAO('ReviewObjectMetadataDAO'); $allReviewObjectsMetadata = array(); foreach ($allTypes as $type) { $typeId = $type['typeId']; $typeMetadata = $reviewObjectMetadataDao->getArrayByReviewObjectTypeId($typeId); $allReviewObjectsMetadata[$typeId] = $typeMetadata; } // If the user is an author get her/his assignments $isAuthor = Validation::isAuthor(); if ($isAuthor) { $user =& $request->getUser(); $ofrAssignmentDao =& DAORegistry::getDAO('ObjectForReviewAssignmentDAO'); $authorAssignments = $ofrAssignmentDao->getObjectIds($user->getId()); } $this->setupTemplate($request, true); $templateMgr =& TemplateManager::getManager($request); $templateMgr->assign('objectForReview', $objectForReview); $templateMgr->assign('allReviewObjectsMetadata', $allReviewObjectsMetadata); $templateMgr->assign('isAuthor', $isAuthor); $templateMgr->assign('authorAssignments', $authorAssignments); // Cover page path import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = $request->getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/'; $templateMgr->assign('coverPagePath', $coverPagePath); $ofrPlugin =& $this->_getObjectsForReviewPlugin(); $ofrPlugin->import('classes.ReviewObjectMetadata'); $templateMgr->assign('multipleOptionsTypes', ReviewObjectMetadata::getMultipleOptionsTypes()); $templateMgr->assign('locale', AppLocale::getLocale()); $templateMgr->assign('ofrListing', false); $templateMgr->assign('ofrTemplatePath', $ofrPlugin->getTemplatePath()); $templateMgr->display($ofrPlugin->getTemplatePath() . 'objectForReview.tpl'); } else { $request->redirect(null, 'objectsForReview'); } }
/** * Display book for review cover page in article abstract. */ function displayArticleCoverPageAbstract($hookName, $params) { if ($this->getEnabled()) { $smarty =& $params[1]; $output =& $params[2]; $journal =& Request::getJournal(); if ($journal) { $journalId = $journal->getId(); } else { return false; } $article =& $smarty->get_template_vars('article'); if ($article) { $articleId = $article->getId(); } else { return false; } $bfrDao =& DAORegistry::getDAO('BookForReviewDAO'); $book =& $bfrDao->getSubmittedBookForReviewByArticle($journalId, $articleId); if ($book) { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $baseCoverPagePath = Request::getBaseUrl() . '/'; $baseCoverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/'; $smarty->assign('baseCoverPagePath', $baseCoverPagePath); $smarty->assign('locale', AppLocale::getLocale()); $smarty->assign('book', $book); $output .= $smarty->fetch($this->getTemplatePath() . 'coverPageAbstract.tpl'); } else { return false; } } return false; }
/** * View Article. * @param $args array * @param $request Request */ function view($args, &$request) { $router =& $request->getRouter(); $articleId = isset($args[0]) ? $args[0] : 0; $galleyId = isset($args[1]) ? $args[1] : 0; $this->validate($request, $articleId, $galleyId); $journal =& $this->journal; $issue =& $this->issue; $article =& $this->article; $this->setupTemplate(); $rtDao =& DAORegistry::getDAO('RTDAO'); $journalRt = $rtDao->getJournalRTByJournal($journal); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $section =& $sectionDao->getSection($article->getSectionId(), $journal->getJournalid(), true); $version = null; if ($journalRt->getVersion() != null && $journalRt->getDefineTerms()) { // Determine the "Define Terms" context ID. $version = $rtDao->getVersion($journalRt->getVersion(), $journalRt->getJournalId(), true); if ($version) { foreach ($version->getContexts() as $context) { if ($context->getDefineTerms()) { $defineTermsContextId = $context->getContextId(); break; } } } } $commentDao =& DAORegistry::getDAO('CommentDAO'); $enableComments = $journal->getSetting('enableComments'); if ($article->getEnableComments() && ($enableComments == COMMENTS_AUTHENTICATED || $enableComments == COMMENTS_UNAUTHENTICATED || $enableComments == COMMENTS_ANONYMOUS)) { $comments =& $commentDao->getRootCommentsByArticleId($article->getId()); } $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO'); if ($journal->getSetting('enablePublicGalleyId')) { $galley =& $galleyDao->getGalleyByBestGalleyId($galleyId, $article->getId()); } else { $galley =& $galleyDao->getGalley($galleyId, $article->getId()); } if ($galley && !$galley->isHtmlGalley() && !$galley->isPdfGalley()) { if ($galley->isInlineable()) { $this->viewFile(array($galley->getArticleId(), $galley->getId()), $request); } else { $this->download(array($galley->getArticleId(), $galley->getId()), $request); } } $templateMgr =& TemplateManager::getManager(); if (!$galley) { // Get the subscription status if displaying the abstract; // if access is open, we can display links to the full text. import('issue.IssueAction'); // The issue may not exist, if this is an editorial user // and scheduling hasn't been completed yet for the article. if ($issue) { $templateMgr->assign('subscriptionRequired', IssueAction::subscriptionRequired($issue)); } $templateMgr->assign('subscribedUser', IssueAction::subscribedUser($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null)); $templateMgr->assign('subscribedDomain', IssueAction::subscribedDomain($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null)); $templateMgr->assign('showGalleyLinks', $journal->getSetting('showGalleyLinks')); import('payment.ojs.OJSPaymentManager'); $paymentManager =& OJSPaymentManager::getManager(); if ($paymentManager->onlyPdfEnabled()) { $templateMgr->assign('restrictOnlyPdf', true); } if ($paymentManager->purchaseArticleEnabled()) { $templateMgr->assign('purchaseArticleEnabled', true); } // Article cover page. $locale = Locale::getLocale(); if (isset($article) && $article->getLocalizedFileName() && $article->getLocalizedShowCoverPage() && !$article->getLocalizedHideCoverPageAbstract($locale)) { import('file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = $request->getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journal->getId()) . '/'; $templateMgr->assign('coverPagePath', $coverPagePath); $templateMgr->assign('coverPageFileName', $article->getLocalizedFileName()); $templateMgr->assign('width', $article->getLocalizedWidth()); $templateMgr->assign('height', $article->getLocalized()); $templateMgr->assign('coverPageAltText', $article->getLocalizedCoverPageAltText()); } // Increment the published article's abstract views count if (!$request->isBot()) { $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticleDao->incrementViewsByArticleId($article->getId()); } } else { if (!$request->isBot()) { // Increment the galley's views count $galleyDao->incrementViews($galley->getId()); } // Use the article's CSS file, if set. if ($galley->isHTMLGalley() && ($styleFile =& $galley->getStyleFile())) { $templateMgr->addStyleSheet($router->url($request, null, 'article', 'viewFile', array($article->getId(), $galley->getBestGalleyId($journal), $styleFile->getFileId()))); } } // Add font sizer js and css if not already in header $additionalHeadData = $templateMgr->get_template_vars('additionalHeadData'); if (strpos(strtolower($additionalHeadData), 'sizer.js') === false) { $additionalHeadData .= $templateMgr->fetch('common/sizer.tpl'); $templateMgr->assign('additionalHeadData', $additionalHeadData); } $templateMgr->assign_by_ref('issue', $issue); $templateMgr->assign_by_ref('article', $article); $templateMgr->assign_by_ref('galley', $galley); $templateMgr->assign_by_ref('section', $section); $templateMgr->assign_by_ref('journalRt', $journalRt); $templateMgr->assign_by_ref('version', $version); $templateMgr->assign_by_ref('journal', $journal); $templateMgr->assign('articleId', $articleId); $templateMgr->assign('postingAllowed', $article->getEnableComments() && ($enableComments == COMMENTS_UNAUTHENTICATED || ($enableComments == COMMENTS_AUTHENTICATED || $enableComments == COMMENTS_ANONYMOUS) && Validation::isLoggedIn())); $templateMgr->assign('enableComments', $enableComments); $templateMgr->assign('postingLoginRequired', $enableComments != COMMENTS_ANONYMOUS && !Validation::isLoggedIn()); $templateMgr->assign('galleyId', $galleyId); $templateMgr->assign('defineTermsContextId', isset($defineTermsContextId) ? $defineTermsContextId : null); $templateMgr->assign('comments', isset($comments) ? $comments : null); $templateMgr->assign('sharingEnabled', $journalRt->getSharingEnabled()); if ($journalRt->getSharingEnabled()) { $templateMgr->assign('sharingRequestURL', $request->getRequestURL()); $templateMgr->assign('sharingArticleTitle', $article->getArticleTitle()); $templateMgr->assign_by_ref('sharingUserName', $journalRt->getSharingUserName()); $templateMgr->assign_by_ref('sharingButtonStyle', $journalRt->getSharingButtonStyle()); $templateMgr->assign_by_ref('sharingDropDownMenu', $journalRt->getSharingDropDownMenu()); $templateMgr->assign_by_ref('sharingBrand', $journalRt->getSharingBrand()); $templateMgr->assign_by_ref('sharingDropDown', $journalRt->getSharingDropDown()); $templateMgr->assign_by_ref('sharingLanguage', $journalRt->getSharingLanguage()); $templateMgr->assign_by_ref('sharingLogo', $journalRt->getSharingLogo()); $templateMgr->assign_by_ref('sharingLogoBackground', $journalRt->getSharingLogoBackground()); $templateMgr->assign_by_ref('sharingLogoColor', $journalRt->getSharingLogoColor()); list($btnUrl, $btnWidth, $btnHeight) = SharingRT::sharingButtonImage($journalRt); $templateMgr->assign('sharingButtonUrl', $btnUrl); $templateMgr->assign('sharingButtonWidth', $btnWidth); $templateMgr->assign('sharingButtonHeight', $btnHeight); } $templateMgr->assign('articleSearchByOptions', array('' => 'search.allFields', ARTICLE_SEARCH_AUTHOR => 'search.author', ARTICLE_SEARCH_TITLE => 'article.title', ARTICLE_SEARCH_ABSTRACT => 'search.abstract', ARTICLE_SEARCH_INDEX_TERMS => 'search.indexTerms', ARTICLE_SEARCH_GALLEY_FILE => 'search.fullText')); $templateMgr->display('article/article.tpl'); }
function addTinyMCE() { $journalId = $this->journalId; $plugin =& $this->plugin; $templateMgr =& TemplateManager::getManager(); // Enable TinyMCE with specific params $additionalHeadData = $templateMgr->get_template_vars('additionalHeadData'); import('classes.file.JournalFileManager'); $publicFileManager = new PublicFileManager(); $tinyMCE_script = ' <script language="javascript" type="text/javascript" src="' . Request::getBaseUrl() . '/' . TINYMCE_JS_PATH . '/tiny_mce.js"></script> <script language="javascript" type="text/javascript"> tinyMCE.init({ mode : "textareas", plugins : "safari,spellchecker,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,pagebreak,", theme_advanced_buttons1_add : "fontsizeselect", theme_advanced_buttons2_add : "separator,preview,separator,forecolor,backcolor", theme_advanced_buttons2_add_before: "search,replace,separator", theme_advanced_buttons3_add_before : "tablecontrols,separator", theme_advanced_buttons3_add : "media,separator", theme_advanced_buttons4 : "cut,copy,paste,pastetext,pasteword,separator,styleprops,|,spellchecker,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,print,separator", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", relative_urls : false, document_base_url : "' . Request::getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journalId) . '/", theme : "advanced", theme_advanced_layout_manager : "SimpleLayout", extended_valid_elements : "span[*], div[*]", spellchecker_languages : "+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv" }); </script>'; $templateMgr->assign('additionalHeadData', $additionalHeadData . "\n" . $tinyMCE_script); }
/** * Given an issue, set up the template with all the required variables for * issues/view.tpl to function properly (i.e. current issue and view issue). * @param $issue object The issue to display * @param $showToc boolean iff false and a custom cover page exists, * the cover page will be displayed. Otherwise table of contents * will be displayed. */ function _setupIssueTemplate($request, $issue, $showToc = false) { $journal =& $request->getJournal(); $journalId = $journal->getId(); $templateMgr =& TemplateManager::getManager(); if (IssueHandler::_isVisibleIssue($issue, $journalId)) { $issueHeadingTitle = $issue->getIssueIdentification(false, true); $issueCrumbTitle = $issue->getIssueIdentification(false, true); $locale = AppLocale::getLocale(); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = $request->getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/'; $templateMgr->assign('coverPagePath', $coverPagePath); $templateMgr->assign('locale', $locale); $coverLocale = $issue->getFileName($locale) ? $locale : $journal->getPrimaryLocale(); if (!$showToc && $issue->getFileName($coverLocale) && $issue->getShowCoverPage($coverLocale) && !$issue->getHideCoverPageCover($coverLocale)) { $templateMgr->assign('fileName', $issue->getFileName($coverLocale)); $templateMgr->assign('width', $issue->getWidth($coverLocale)); $templateMgr->assign('height', $issue->getHeight($coverLocale)); $templateMgr->assign('coverPageAltText', $issue->getCoverPageAltText($coverLocale)); $templateMgr->assign('originalFileName', $issue->getOriginalFileName($coverLocale)); $showToc = false; } else { // Issue galleys $issueGalleyDao =& DAORegistry::getDAO('IssueGalleyDAO'); $issueGalleys =& $issueGalleyDao->getGalleysByIssue($issue->getId()); $templateMgr->assign_by_ref('issueGalleys', $issueGalleys); // Published articles $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticles =& $publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true); $publicFileManager = new PublicFileManager(); $templateMgr->assign_by_ref('publishedArticles', $publishedArticles); $showToc = true; } $templateMgr->assign('showToc', $showToc); $templateMgr->assign_by_ref('issue', $issue); // Subscription Access import('classes.issue.IssueAction'); $subscriptionRequired = IssueAction::subscriptionRequired($issue); $subscribedUser = IssueAction::subscribedUser($journal); $subscribedDomain = IssueAction::subscribedDomain($journal); $subscriptionExpiryPartial = $journal->getSetting('subscriptionExpiryPartial'); if ($showToc && $subscriptionRequired && !$subscribedUser && !$subscribedDomain && $subscriptionExpiryPartial) { $templateMgr->assign('subscriptionExpiryPartial', true); // Partial subscription expiry for issue $partial = IssueAction::subscribedUser($journal, $issue->getId()); if (!$partial) { IssueAction::subscribedDomain($journal, $issue->getId()); } $templateMgr->assign('issueExpiryPartial', $partial); // Partial subscription expiry for articles $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticlesTemp =& $publishedArticleDao->getPublishedArticles($issue->getId()); $articleExpiryPartial = array(); foreach ($publishedArticlesTemp as $publishedArticle) { $partial = IssueAction::subscribedUser($journal, $issue->getId(), $publishedArticle->getId()); if (!$partial) { IssueAction::subscribedDomain($journal, $issue->getId(), $publishedArticle->getId()); } $articleExpiryPartial[$publishedArticle->getId()] = $partial; } $templateMgr->assign_by_ref('articleExpiryPartial', $articleExpiryPartial); } $templateMgr->assign('subscriptionRequired', $subscriptionRequired); $templateMgr->assign('subscribedUser', $subscribedUser); $templateMgr->assign('subscribedDomain', $subscribedDomain); $templateMgr->assign('showGalleyLinks', $journal->getSetting('showGalleyLinks')); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($request); if ($paymentManager->onlyPdfEnabled()) { $templateMgr->assign('restrictOnlyPdf', true); } if ($paymentManager->purchaseArticleEnabled()) { $templateMgr->assign('purchaseArticleEnabled', true); } } else { $issueCrumbTitle = __('archive.issueUnavailable'); $issueHeadingTitle = __('archive.issueUnavailable'); } if ($issue && ($styleFileName = $issue->getStyleFileName())) { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $templateMgr->addStyleSheet($request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journalId) . '/' . $styleFileName); } $templateMgr->assign('pageCrumbTitleTranslated', $issueCrumbTitle); $templateMgr->assign('issueHeadingTitle', $issueHeadingTitle); }
function _handleOjsUrl($matchArray) { $request = Application::getRequest(); $url = $matchArray[2]; $anchor = null; if (($i = strpos($url, '#')) !== false) { $anchor = substr($url, $i + 1); $url = substr($url, 0, $i); } $urlParts = explode('/', $url); if (isset($urlParts[0])) { switch (strtolower_codesafe($urlParts[0])) { case 'journal': $url = $request->url(isset($urlParts[1]) ? $urlParts[1] : $request->getRequestedJournalPath(), null, null, null, null, $anchor); break; case 'article': if (isset($urlParts[1])) { $url = $request->url(null, 'article', 'view', $urlParts[1], null, $anchor); } break; case 'issue': if (isset($urlParts[1])) { $url = $request->url(null, 'issue', 'view', $urlParts[1], null, $anchor); } else { $url = $request->url(null, 'issue', 'current', null, null, $anchor); } break; case 'sitepublic': array_shift($urlParts); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $url = $request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath() . '/' . implode('/', $urlParts) . ($anchor ? '#' . $anchor : ''); break; case 'public': array_shift($urlParts); $journal = $request->getJournal(); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $url = $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId()) . '/' . implode('/', $urlParts) . ($anchor ? '#' . $anchor : ''); break; } } return $matchArray[1] . $url . $matchArray[3]; }
/** * Constructor. * Initialize template engine and assign basic template variables. * @param $request PKPRequest */ function TemplateManager($request) { parent::PKPTemplateManager($request); if (!defined('SESSION_DISABLE_INIT')) { /** * Kludge to make sure no code that tries to connect to * the database is executed (e.g., when loading * installer pages). */ $context = $request->getContext(); $site = $request->getSite(); $publicFileManager = new PublicFileManager(); $siteFilesDir = $request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath(); $this->assign('sitePublicFilesDir', $siteFilesDir); $this->assign('publicFilesDir', $siteFilesDir); // May be overridden by journal $siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet($request->getBaseUrl() . '/' . $siteStyleFilename, STYLE_SEQUENCE_LAST); } $this->assign('siteCategoriesEnabled', $site->getSetting('categoriesEnabled')); if (isset($context)) { $this->assign('currentJournal', $context); $this->assign('siteTitle', $context->getLocalizedName()); $this->assign('publicFilesDir', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId())); $this->assign('primaryLocale', $context->getPrimaryLocale()); $this->assign('alternateLocales', $context->getSetting('alternateLocales')); // Assign page header $this->assign('displayPageHeaderTitle', $context->getLocalizedPageHeaderTitle()); $this->assign('displayPageHeaderLogo', $context->getLocalizedPageHeaderLogo()); $this->assign('displayPageHeaderTitleAltText', $context->getLocalizedSetting('pageHeaderTitleImageAltText')); $this->assign('displayPageHeaderLogoAltText', $context->getLocalizedSetting('pageHeaderLogoImageAltText')); $this->assign('displayFavicon', $context->getLocalizedFavicon()); $this->assign('faviconDir', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId())); $this->assign('alternatePageHeader', $context->getLocalizedSetting('journalPageHeader')); $this->assign('metaSearchDescription', $context->getLocalizedSetting('searchDescription')); $this->assign('metaSearchKeywords', $context->getLocalizedSetting('searchKeywords')); $this->assign('metaCustomHeaders', $context->getLocalizedSetting('customHeaders')); $this->assign('numPageLinks', $context->getSetting('numPageLinks')); $this->assign('itemsPerPage', $context->getSetting('itemsPerPage')); $this->assign('enableAnnouncements', $context->getSetting('enableAnnouncements')); // Assign stylesheets and footer $contextStyleSheet = $context->getSetting('journalStyleSheet'); if ($contextStyleSheet) { $this->addStyleSheet($request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()) . '/' . $contextStyleSheet['uploadName'], STYLE_SEQUENCE_LAST); } import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($request); $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured()); // Include footer links if they have been defined. $footerCategoryDao = DAORegistry::getDAO('FooterCategoryDAO'); $footerCategories = $footerCategoryDao->getNotEmptyByContextId($context->getId()); $this->assign('footerCategories', $footerCategories->toArray()); $footerLinkDao = DAORegistry::getDAO('FooterLinkDAO'); $this->assign('maxLinks', $footerLinkDao->getLargestCategoryTotalbyContextId($context->getId())); $this->assign('pageFooter', $context->getLocalizedSetting('journalPageFooter')); } else { // Add the site-wide logo, if set for this locale or the primary locale $displayPageHeaderTitle = $site->getLocalizedPageHeaderTitle(); $this->assign('displayPageHeaderTitle', $displayPageHeaderTitle); if (isset($displayPageHeaderTitle['altText'])) { $this->assign('displayPageHeaderTitleAltText', $displayPageHeaderTitle['altText']); } $this->assign('siteTitle', $site->getLocalizedTitle()); $this->assign('primaryLocale', $site->getPrimaryLocale()); } } }
/** * Display object metadata on the article abstract pages. * @param $hookName string (Templates::Article::MoreInfo) * @param $args array * @return boolean false to continue processing subsequent hooks */ function displayAbstract($hookName, $params) { $smarty =& $params[1]; $output =& $params[2]; // Get the journal and the article $journal =& Request::getJournal(); $journalId = $journal->getId(); $article = $smarty->get_template_vars('article'); $pubObject = $smarty->get_template_vars('pubObject'); // Only consider the abstract page if ($article && is_a($pubObject, 'Article')) { // Get the assignemnts for this article $objectsForReview = array(); $ofrDao =& DAORegistry::getDAO('ObjectForReviewDAO'); $ofrAssignmentDao =& DAORegistry::getDAO('ObjectForReviewAssignmentDAO'); $objectForReviewAssignments =& $ofrAssignmentDao->getAllBySubmissionId($article->getId()); foreach ($objectForReviewAssignments as $objectForReviewAssignment) { $objectForReview = $ofrDao->getById($objectForReviewAssignment->getObjectId(), $journalId); $objectsForReview[] = $objectForReview; } if (!empty($objectsForReview)) { // Get metadata for the review type $reviewObjectTypeDao =& DAORegistry::getDAO('ReviewObjectTypeDAO'); $allTypes =& $reviewObjectTypeDao->getTypeIdsAlphabetizedByContext($journalId); $reviewObjectMetadataDao =& DAORegistry::getDAO('ReviewObjectMetadataDAO'); $allReviewObjectsMetadata = array(); foreach ($allTypes as $type) { $typeId = $type['typeId']; $typeMetadata = $reviewObjectMetadataDao->getArrayByReviewObjectTypeId($typeId); $allReviewObjectsMetadata[$typeId] = $typeMetadata; } $publicFileManager = new PublicFileManager(); $coverPagePath = Request::getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/'; $smarty->assign('coverPagePath', $coverPagePath); $smarty->assign('objectsForReview', $objectsForReview); $smarty->assign('allReviewObjectsMetadata', $allReviewObjectsMetadata); $smarty->assign('multipleOptionsTypes', ReviewObjectMetadata::getMultipleOptionsTypes()); $smarty->assign('ofrListing', true); $smarty->assign('ofrTemplatePath', $this->getTemplatePath()); $output .= $smarty->fetch($this->getTemplatePath() . 'articleObjectsForReview.tpl'); } } return false; }
/** * Get data for an issue * @param $request PKPRequest * @param $journalId The journal ID * @param $issueId Object * @param $withArticles boolean Whether to include the issue's articles in the response */ function _getIssueInfo(&$request, $journalId, $issue, $withArticles = false) { if (!isset($issue)) { $this->showError(); } Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON)); //Handle getting the image URL $publicFileManager = new PublicFileManager(); $coverPagePath = $request->getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journalId) . '/'; $imageFileName = $issue->getIssueFileName(); $imageUrl = $coverPagePath . $imageFileName; $response = array('url' => $request->url(null, 'issue', 'view', $issue->getId()), 'issueId' => $issue->getId(), 'title' => $issue->getLocalizedTitle(), 'description' => $issue->getLocalizedDescription(), 'identification' => $issue->getIssueIdentification(), 'volume' => $issue->getVolume(), 'number' => $issue->getNumber(), 'year' => $issue->getYear(), 'datePublished' => $issue->getDatePublished(), 'imageUrl' => $imageUrl, 'imageDescription' => $issue->getIssueCoverPageDescription()); if ($withArticles) { $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticles =& $publishedArticleDao->getPublishedArticles($issue->getId()); $articles = array(); foreach ($publishedArticles as $publishedArticle) { $articles[] = $this->_getArticleInfo($request, $publishedArticle->getId()); } $response['articles'] = $articles; } return $response; }
function restorePublicFolder() { $publicFileManager = new PublicFileManager(); $oldPublicFolder = $this->publicFolderPath; $newPublicFolder = $publicFileManager->getJournalFilesPath($this->journal->getId()); $dir = new DirectoryIterator($oldPublicFolder); foreach ($dir as $fileinfo) { if (!$fileinfo->isDot()) { if ($fileinfo->isDir()) { $publicFileManager->copyDir($fileinfo->getPathname(), $newPublicFolder . "/" . $fileinfo->getFileName()); } else { if ($fileinfo->isFile()) { $publicFileManager->copyFile($fileinfo->getPathname(), $newPublicFolder . "/" . $fileinfo->getFileName()); } } } } }
/** * Display the issue archive listings */ function archive() { $this->validate(); $this->setupTemplate(); $journal =& Request::getJournal(); $issueDao =& DAORegistry::getDAO('IssueDAO'); $rangeInfo = Handler::getRangeInfo('issues'); $publishedIssuesIterator = $issueDao->getPublishedIssues($journal->getId(), $rangeInfo); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = Request::getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journal->getId()) . '/'; $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('coverPagePath', $coverPagePath); $templateMgr->assign('locale', AppLocale::getLocale()); $templateMgr->assign_by_ref('issues', $publishedIssuesIterator); $templateMgr->assign('helpTopicId', 'user.currentAndArchives'); $templateMgr->display('issue/archive.tpl'); }
/** * Save changes to article. * @return int the article ID */ function execute() { $articleDao =& DAORegistry::getDAO('ArticleDAO'); $authorDao =& DAORegistry::getDAO('AuthorDAO'); $sectionDao =& DAORegistry::getDAO('SectionDAO'); // Update article $article =& $this->article; $article->setTitle($this->getData('title'), null); // Localized $section =& $sectionDao->getSection($article->getSectionId()); $article->setAbstract($this->getData('abstract'), null); // Localized import('file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if ($publicFileManager->uploadedFileExists('coverPage')) { $journal = Request::getJournal(); $originalFileName = $publicFileManager->getUploadedFileName('coverPage'); $newFileName = 'cover_article_' . $this->getData('articleId') . '_' . $this->getFormLocale() . '.' . $publicFileManager->getExtension($originalFileName); $publicFileManager->uploadJournalFile($journal->getId(), 'coverPage', $newFileName); $article->setOriginalFileName($publicFileManager->truncateFileName($originalFileName, 127), $this->getFormLocale()); $article->setFileName($newFileName, $this->getFormLocale()); // Store the image dimensions. list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newFileName); $article->setWidth($width, $this->getFormLocale()); $article->setHeight($height, $this->getFormLocale()); } $article->setCoverPageAltText($this->getData('coverPageAltText'), null); // Localized $showCoverPage = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('showCoverPage')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $showCoverPage)) { $showCoverPage[$locale] = 0; } } $article->setShowCoverPage($showCoverPage, null); // Localized $hideCoverPageToc = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageToc')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $hideCoverPageToc)) { $hideCoverPageToc[$locale] = 0; } } $article->setHideCoverPageToc($hideCoverPageToc, null); // Localized $hideCoverPageAbstract = array_map(create_function('$arrayElement', 'return (int)$arrayElement;'), (array) $this->getData('hideCoverPageAbstract')); foreach (array_keys($this->getData('coverPageAltText')) as $locale) { if (!array_key_exists($locale, $hideCoverPageAbstract)) { $hideCoverPageAbstract[$locale] = 0; } } $article->setHideCoverPageAbstract($hideCoverPageAbstract, null); // Localized $article->setDiscipline($this->getData('discipline'), null); // Localized $article->setSubjectClass($this->getData('subjectClass'), null); // Localized $article->setSubject($this->getData('subject'), null); // Localized $article->setCoverageGeo($this->getData('coverageGeo'), null); // Localized $article->setCoverageChron($this->getData('coverageChron'), null); // Localized $article->setCoverageSample($this->getData('coverageSample'), null); // Localized $article->setType($this->getData('type'), null); // Localized $article->setLanguage($this->getData('language')); // Localized $article->setSponsor($this->getData('sponsor'), null); // Localized $article->setCitations($this->getData('citations')); if ($this->isEditor) { $article->setHideAuthor($this->getData('hideAuthor') ? $this->getData('hideAuthor') : 0); } // Update authors $authors = $this->getData('authors'); for ($i = 0, $count = count($authors); $i < $count; $i++) { if ($authors[$i]['authorId'] > 0) { // Update an existing author $author =& $article->getAuthor($authors[$i]['authorId']); $isExistingAuthor = true; } else { // Create a new author $author = new Author(); $isExistingAuthor = false; } if ($author != null) { $author->setFirstName($authors[$i]['firstName']); $author->setMiddleName($authors[$i]['middleName']); $author->setLastName($authors[$i]['lastName']); $author->setAffiliation($authors[$i]['affiliation']); $author->setCountry($authors[$i]['country']); $author->setEmail($authors[$i]['email']); $author->setUrl($authors[$i]['url']); if (array_key_exists('competingInterests', $authors[$i])) { $author->setCompetingInterests($authors[$i]['competingInterests'], null); // Localized } $author->setBiography($authors[$i]['biography'], null); // Localized $author->setPrimaryContact($this->getData('primaryContact') == $i ? 1 : 0); $author->setSequence($authors[$i]['seq']); if ($isExistingAuthor == false) { $article->addAuthor($author); } } } // Remove deleted authors $deletedAuthors = explode(':', $this->getData('deletedAuthors')); for ($i = 0, $count = count($deletedAuthors); $i < $count; $i++) { $article->removeAuthor($deletedAuthors[$i]); } parent::execute(); // Save the article $articleDao->updateArticle($article); // Update search index import('search.ArticleSearchIndex'); ArticleSearchIndex::indexArticleMetadata($article); return $article->getId(); }
function handleArticleCoverNode(&$journal, &$coverNode, &$article, &$errors, $isCommandLine) { $errors = array(); $hasErrors = false; $journalSupportedLocales = array_keys($journal->getSupportedLocaleNames()); // => journal locales must be set up before $journalPrimaryLocale = $journal->getPrimaryLocale(); $locale = $coverNode->getAttribute('locale'); if ($locale == '') { $locale = $journalPrimaryLocale; } elseif (!in_array($locale, $journalSupportedLocales)) { $errors[] = array('plugins.importexport.native.import.error.coverLocaleUnsupported', array('issueTitle' => $issue->getIssueIdentification(), 'locale' => $locale)); return false; } $article->setShowCoverPage(1, $locale); if ($node = $coverNode->getChildByName('altText')) { $article->setCoverPageAltText($node->getValue(), $locale); } if ($node = $coverNode->getChildByName('image')) { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $newName = 'cover_article_' . $article->getId() . "_{$locale}" . '.'; if ($href = $node->getChildByName('href')) { $url = $href->getAttribute('src'); if ($isCommandLine || NativeImportDom::isAllowedMethod($url)) { if ($isCommandLine && NativeImportDom::isRelativePath($url)) { // The command-line tool does a chdir; we need to prepend the original pathname to relative paths so we're not looking in the wrong place. $url = PWD . '/' . $url; } $originalName = basename($url); $newName .= $publicFileManager->getExtension($originalName); if (!$publicFileManager->copyJournalFile($journal->getId(), $url, $newName)) { $errors[] = array('plugins.importexport.native.import.error.couldNotCopy', array('url' => $url)); $hasErrors = true; } $article->setFileName($newName, $locale); $article->setOriginalFileName($publicFileManager->truncateFileName($originalName, 127), $locale); } } if ($embed = $node->getChildByName('embed')) { if (($type = $embed->getAttribute('encoding')) !== 'base64') { $errors[] = array('plugins.importexport.native.import.error.unknownEncoding', array('type' => $type)); $hasErrors = true; } else { $originalName = $embed->getAttribute('filename'); $newName .= $publicFileManager->getExtension($originalName); $article->setFileName($newName, $locale); $article->setOriginalFileName($publicFileManager->truncateFileName($originalName, 127), $locale); if ($publicFileManager->writeJournalFile($journal->getId(), $newName, base64_decode($embed->getValue())) === false) { $errors[] = array('plugins.importexport.native.import.error.couldNotWriteFile', array('originalName' => $originalName)); $hasErrors = true; } } } // Store the image dimensions. list($width, $height) = getimagesize($publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $newName); $article->setWidth($width, $locale); $article->setHeight($height, $locale); } if ($hasErrors) { return false; } return true; }
/** * View Article. * @param $args array * @param $request Request */ function view($args, $request) { $articleId = isset($args[0]) ? $args[0] : 0; $galleyId = isset($args[1]) ? $args[1] : 0; $fileId = isset($args[2]) ? $args[2] : 0; if ($this->userCanViewGalley($request, $articleId, $galleyId)) { $journal = $this->journal; $issue = $this->issue; $article = $this->article; $this->setupTemplate($request); $sectionDao = DAORegistry::getDAO('SectionDAO'); $section = $sectionDao->getById($article->getSectionId(), $journal->getId(), true); $galleyDao = DAORegistry::getDAO('ArticleGalleyDAO'); if ($journal->getSetting('enablePublicGalleyId')) { $galley = $galleyDao->getByBestGalleyId($galleyId, $article->getId()); } if (!isset($galley)) { $galley = $galleyDao->getById($galleyId, $article->getId()); } if (isset($galley)) { if ($galley->getRemoteURL()) { $request->redirectUrl($galley->getRemoteURL()); } } $templateMgr = TemplateManager::getManager($request); $templateMgr->addJavaScript('js/relatedItems.js'); if (!$galley) { // Get the subscription status if displaying the abstract; // if access is open, we can display links to the full text. import('classes.issue.IssueAction'); // The issue may not exist, if this is an editorial user // and scheduling hasn't been completed yet for the article. $issueAction = new IssueAction(); if ($issue) { $templateMgr->assign('subscriptionRequired', $issueAction->subscriptionRequired($issue)); } $templateMgr->assign('subscribedUser', $issueAction->subscribedUser($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null)); $templateMgr->assign('subscribedDomain', $issueAction->subscribedDomain($journal, isset($issue) ? $issue->getId() : null, isset($article) ? $article->getId() : null)); $templateMgr->assign('showGalleyLinks', $journal->getSetting('showGalleyLinks')); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($request); if ($paymentManager->onlyPdfEnabled()) { $templateMgr->assign('restrictOnlyPdf', true); } if ($paymentManager->purchaseArticleEnabled()) { $templateMgr->assign('purchaseArticleEnabled', true); } // Article cover page. if (isset($article) && $article->getLocalizedFileName() && $article->getLocalizedShowCoverPage() && !$article->getLocalizedHideCoverPageAbstract()) { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $coverPagePath = $request->getBaseUrl() . '/'; $coverPagePath .= $publicFileManager->getJournalFilesPath($journal->getId()) . '/'; $templateMgr->assign('coverPagePath', $coverPagePath); $templateMgr->assign('coverPageFileName', $article->getLocalizedFileName()); $templateMgr->assign('width', $article->getLocalizedWidth()); $templateMgr->assign('height', $article->getLocalizedHeight()); $templateMgr->assign('coverPageAltText', $article->getLocalizedCoverPageAltText()); } // References list. // FIXME: We only display the edited raw citations right now. We also want // to allow for generated citations to be displayed here (including a way for // the reader to choose any of the installed citation styles for output), see #5938. $citationDao = DAORegistry::getDAO('CitationDAO'); /* @var $citationDao CitationDAO */ $citationFactory = $citationDao->getObjectsByAssocId(ASSOC_TYPE_ARTICLE, $article->getId()); $templateMgr->assign('citationFactory', $citationFactory); } $templateMgr->assign('issue', $issue); $templateMgr->assign('article', $article); $templateMgr->assign('galley', $galley); $templateMgr->assign('section', $section); $templateMgr->assign('journal', $journal); $templateMgr->assign('articleId', $articleId); $templateMgr->assign('galleyId', $galleyId); $templateMgr->assign('fileId', $fileId); $templateMgr->assign('defineTermsContextId', isset($defineTermsContextId) ? $defineTermsContextId : null); $templateMgr->assign('ccLicenseBadge', Application::getCCLicenseBadge($article->getLicenseURL())); $templateMgr->assign('articleSearchByOptions', array('query' => 'search.allFields', 'authors' => 'search.author', 'title' => 'article.title', 'abstract' => 'search.abstract', 'indexTerms' => 'search.indexTerms', 'galleyFullText' => 'search.fullText')); // consider public identifiers $pubIdPlugins = PluginRegistry::loadCategory('pubIds', true); $templateMgr->assign('pubIdPlugins', $pubIdPlugins); // load Article galley plugins PluginRegistry::loadCategory('viewableFiles', true); $templateMgr->display('article/article.tpl'); } }
/** * Constructor. * Initialize template engine and assign basic template variables. * @param $request PKPRequest */ function TemplateManager($request) { parent::PKPTemplateManager($request); if (!defined('SESSION_DISABLE_INIT')) { /** * Kludge to make sure no code that tries to connect to * the database is executed (e.g., when loading * installer pages). */ $context = $request->getContext(); $site = $request->getSite(); $publicFileManager = new PublicFileManager(); $siteFilesDir = $request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath(); $this->assign('sitePublicFilesDir', $siteFilesDir); $this->assign('publicFilesDir', $siteFilesDir); // May be overridden by journal $siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet($request->getBaseUrl() . '/' . $siteStyleFilename, STYLE_SEQUENCE_LAST); } $this->assign('siteCategoriesEnabled', $site->getSetting('categoriesEnabled')); if (isset($context)) { $this->assign('currentJournal', $context); $this->assign('siteTitle', $context->getLocalizedName()); $this->assign('publicFilesDir', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId())); $this->assign('primaryLocale', $context->getPrimaryLocale()); $this->assign('alternateLocales', $context->getSetting('alternateLocales')); // Assign page header $this->assign('displayPageHeaderTitle', $context->getLocalizedPageHeaderTitle()); $this->assign('displayPageHeaderLogo', $context->getLocalizedPageHeaderLogo()); $this->assign('displayPageHeaderLogoAltText', $context->getLocalizedSetting('pageHeaderLogoImageAltText')); $this->assign('displayFavicon', $context->getLocalizedFavicon()); $this->assign('faviconDir', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId())); $this->assign('metaSearchDescription', $context->getLocalizedSetting('searchDescription')); $this->assign('metaSearchKeywords', $context->getLocalizedSetting('searchKeywords')); $this->assign('metaCustomHeaders', $context->getLocalizedSetting('customHeaders')); $this->assign('numPageLinks', $context->getSetting('numPageLinks')); $this->assign('itemsPerPage', $context->getSetting('itemsPerPage')); $this->assign('enableAnnouncements', $context->getSetting('enableAnnouncements')); $this->assign('contextSettings', $context->getSettingsDAO()->getSettings($context->getId())); // Assign stylesheets and footer $contextStyleSheet = $context->getSetting('journalStyleSheet'); if ($contextStyleSheet) { $this->addStyleSheet($request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()) . '/' . $contextStyleSheet['uploadName'], STYLE_SEQUENCE_LAST); } // Get a link to the settings page for the current context. // This allows us to reduce template duplication by using this // variable in templates/common/header.tpl, instead of // reproducing a lot of OMP/OJS-specific logic there. $router = $request->getRouter(); $dispatcher = $request->getDispatcher(); $this->assign('contextSettingsUrl', $dispatcher->url($request, ROUTE_PAGE, null, 'management', 'settings', 'journal')); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($request); $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured()); $this->assign('pageFooter', $context->getLocalizedSetting('journalPageFooter')); } else { // Add the site-wide logo, if set for this locale or the primary locale $displayPageHeaderTitle = $site->getLocalizedPageHeaderTitle(); $this->assign('displayPageHeaderTitle', $displayPageHeaderTitle); if (isset($displayPageHeaderTitle['altText'])) { $this->assign('displayPageHeaderTitleAltText', $displayPageHeaderTitle['altText']); } $this->assign('siteTitle', $site->getLocalizedTitle()); $this->assign('primaryLocale', $site->getPrimaryLocale()); } } }
/** * Given an issue, set up the template with all the required variables for * frontend/objects/issue_toc.tpl to function properly (i.e. current issue * and view issue). * @param $issue object The issue to display * @param $showToc boolean iff false and a custom cover page exists, * the cover page will be displayed. Otherwise table of contents * will be displayed. */ function _setupIssueTemplate($request, $issue, $showToc = false) { $journal = $request->getJournal(); $templateMgr = TemplateManager::getManager($request); // Determine pre-publication access // FIXME: Do that. (Bug #8278) if (!$issue) { $issue = $this->getAuthorizedContextObject(ASSOC_TYPE_ISSUE); } $templateMgr->assign(array('issueIdentification' => $issue->getIssueIdentification(), 'issueTitle' => $issue->getLocalizedTitle(), 'issueSeries' => $issue->getIssueIdentification(array('showTitle' => false)))); $locale = AppLocale::getLocale(); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $templateMgr->assign(array('coverPagePath' => $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId()) . '/', 'locale' => $locale)); if (!$showToc && $issue->getFileName($locale) && $issue->getShowCoverPage($locale) && !$issue->getHideCoverPageCover($locale)) { $templateMgr->assign(array('fileName' => $issue->getFileName($locale), 'width' => $issue->getWidth($locale), 'height' => $issue->getHeight($locale), 'coverPageAltText' => $issue->getCoverPageAltText($locale), 'originalFileName' => $issue->getOriginalFileName($locale), 'originalFileName' => $issue->getOriginalFileName($locale))); } else { $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO'); $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $templateMgr->assign(array('issueGalleys' => $issueGalleyDao->getByIssueId($issue->getId()), 'publishedArticles' => $publishedArticleDao->getPublishedArticlesInSections($issue->getId(), true))); $showToc = true; } $templateMgr->assign(array('showToc' => $showToc, 'issue' => $issue)); // Subscription Access import('classes.issue.IssueAction'); $issueAction = new IssueAction(); $subscriptionRequired = $issueAction->subscriptionRequired($issue); $subscribedUser = $issueAction->subscribedUser($journal); $subscribedDomain = $issueAction->subscribedDomain($journal); if ($showToc && $subscriptionRequired && !$subscribedUser && !$subscribedDomain) { $templateMgr->assign('subscriptionExpiryPartial', true); // Partial subscription expiry for issue $partial = $issueAction->subscribedUser($journal, $issue->getId()); if (!$partial) { $issueAction->subscribedDomain($journal, $issue->getId()); } $templateMgr->assign('issueExpiryPartial', $partial); // Partial subscription expiry for articles $publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticlesTemp =& $publishedArticleDao->getPublishedArticles($issue->getId()); $articleExpiryPartial = array(); foreach ($publishedArticlesTemp as $publishedArticle) { $partial = $issueAction->subscribedUser($journal, $issue->getId(), $publishedArticle->getId()); if (!$partial) { $issueAction->subscribedDomain($journal, $issue->getId(), $publishedArticle->getId()); } $articleExpiryPartial[$publishedArticle->getId()] = $partial; } $templateMgr->assign('articleExpiryPartial', $articleExpiryPartial); } $templateMgr->assign(array('showGalleyLinks' => !$subscriptionRequired || $journal->getSetting('showGalleyLinks'), 'hasAccess' => !$subscriptionRequired || $issue->getAccessStatus() == ISSUE_ACCESS_OPEN || $subscribedUser || $subscribedDomain)); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($request); if ($paymentManager->onlyPdfEnabled()) { $templateMgr->assign('restrictOnlyPdf', true); } if ($paymentManager->purchaseArticleEnabled()) { $templateMgr->assign('purchaseArticleEnabled', true); } if ($styleFileName = $issue->getStyleFileName()) { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $templateMgr->addStyleSheet($request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $styleFileName); } }
/** * Constructor. * Initialize template engine and assign basic template variables. * @param $request PKPRequest FIXME: is optional for backwards compatibility only - make mandatory */ function TemplateManager($request = null) { parent::PKPTemplateManager($request); // Retrieve the router $router =& $this->request->getRouter(); assert(is_a($router, 'PKPRouter')); // Are we using implicit authentication? $this->assign('implicitAuth', Config::getVar('security', 'implicit_auth')); if (!defined('SESSION_DISABLE_INIT')) { /** * Kludge to make sure no code that tries to connect to * the database is executed (e.g., when loading * installer pages). */ $journal =& $router->getContext($this->request); $site =& $this->request->getSite(); $publicFileManager = new PublicFileManager(); $siteFilesDir = $this->request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath(); $this->assign('sitePublicFilesDir', $siteFilesDir); $this->assign('publicFilesDir', $siteFilesDir); // May be overridden by journal $siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet($this->request->getBaseUrl() . '/' . $siteStyleFilename); } $this->assign('homeContext', array()); $this->assign('siteCategoriesEnabled', $site->getSetting('categoriesEnabled')); if (isset($journal)) { $this->assign_by_ref('currentJournal', $journal); $journalTitle = $journal->getLocalizedTitle(); $this->assign('siteTitle', $journalTitle); $this->assign('publicFilesDir', $this->request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId())); $this->assign('primaryLocale', $journal->getPrimaryLocale()); $this->assign('alternateLocales', $journal->getSetting('alternateLocales')); // Assign additional navigation bar items $navMenuItems =& $journal->getLocalizedSetting('navItems'); $this->assign_by_ref('navMenuItems', $navMenuItems); // Assign journal page header $this->assign('displayPageHeaderTitle', $journal->getLocalizedPageHeaderTitle()); $this->assign('displayPageHeaderLogo', $journal->getLocalizedPageHeaderLogo()); $this->assign('displayPageHeaderTitleAltText', $journal->getLocalizedSetting('pageHeaderTitleImageAltText')); $this->assign('displayPageHeaderLogoAltText', $journal->getLocalizedSetting('pageHeaderLogoImageAltText')); $this->assign('displayFavicon', $journal->getLocalizedFavicon()); $this->assign('faviconDir', $this->request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId())); $this->assign('alternatePageHeader', $journal->getLocalizedSetting('journalPageHeader')); $this->assign('metaSearchDescription', $journal->getLocalizedSetting('searchDescription')); $this->assign('metaSearchKeywords', $journal->getLocalizedSetting('searchKeywords')); $this->assign('metaCustomHeaders', $journal->getLocalizedSetting('customHeaders')); $this->assign('numPageLinks', $journal->getSetting('numPageLinks')); $this->assign('itemsPerPage', $journal->getSetting('itemsPerPage')); $this->assign('enableAnnouncements', $journal->getSetting('enableAnnouncements')); $this->assign('hideRegisterLink', !$journal->getSetting('allowRegReviewer') && !$journal->getSetting('allowRegReader') && !$journal->getSetting('allowRegAuthor')); // Load and apply theme plugin, if chosen $themePluginPath = $journal->getSetting('journalTheme'); if (!empty($themePluginPath)) { // Load and activate the theme $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath); if ($themePlugin) { $themePlugin->activate($this); } } // Assign stylesheets and footer $journalStyleSheet = $journal->getSetting('journalStyleSheet'); if ($journalStyleSheet) { $this->addStyleSheet($this->request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($journal->getId()) . '/' . $journalStyleSheet['uploadName']); } import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($this->request); $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured()); $this->assign('pageFooter', $journal->getLocalizedSetting('journalPageFooter')); } else { // Add the site-wide logo, if set for this locale or the primary locale $displayPageHeaderTitle = $site->getLocalizedPageHeaderTitle(); $this->assign('displayPageHeaderTitle', $displayPageHeaderTitle); if (isset($displayPageHeaderTitle['altText'])) { $this->assign('displayPageHeaderTitleAltText', $displayPageHeaderTitle['altText']); } $this->assign('siteTitle', $site->getLocalizedTitle()); // Load and apply theme plugin, if chosen $themePluginPath = $site->getSetting('siteTheme'); if (!empty($themePluginPath)) { // Load and activate the theme $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath); if ($themePlugin) { $themePlugin->activate($this); } } } if (!$site->getRedirect()) { $this->assign('hasOtherJournals', true); } // Add java script for notifications $user =& $this->request->getUser(); if ($user) { $this->addJavaScript('lib/pkp/js/lib/jquery/plugins/jquery.pnotify.js'); } } }
/** * Uploads a journal image. * @param $settingName string setting key associated with the file * @param $locale string */ function uploadImage($settingName, $locale) { $journal =& Request::getJournal(); $settingsDao =& DAORegistry::getDAO('JournalSettingsDAO'); $faviconTypes = array('.ico', '.png', '.gif'); import('classes.file.PublicFileManager'); $fileManager = new PublicFileManager(); if ($fileManager->uploadedFileExists($settingName)) { $type = $fileManager->getUploadedFileType($settingName); $extension = $fileManager->getImageExtension($type); if (!$extension) { return false; } if ($settingName == 'journalFavicon' && !in_array($extension, $faviconTypes)) { return false; } $uploadName = $settingName . '_' . $locale . $extension; if ($fileManager->uploadJournalFile($journal->getId(), $settingName, $uploadName)) { // Get image dimensions $filePath = $fileManager->getJournalFilesPath($journal->getId()); list($width, $height) = getimagesize($filePath . '/' . $uploadName); $value = $journal->getSetting($settingName); $newImage = empty($value[$locale]); $value[$locale] = array('name' => $fileManager->getUploadedFileName($settingName, $locale), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'mimeType' => $fileManager->getUploadedFileType($settingName), 'dateUploaded' => Core::getCurrentDate()); $journal->updateSetting($settingName, $value, 'object', true); if ($newImage) { $altText = $journal->getSetting($settingName . 'AltText'); if (!empty($altText[$locale])) { $this->setData($settingName . 'AltText', $altText); } } return true; } } return false; }
/** * Delete a journal. * @param $args array first parameter is the ID of the journal to delete * @param $request object */ function deleteJournal($args, &$request) { $this->validate(); $journalDao =& DAORegistry::getDAO('JournalDAO'); if (isset($args) && !empty($args) && !empty($args[0])) { $journalId = $args[0]; if ($journalDao->deleteJournalById($journalId)) { // Delete journal file tree // FIXME move this somewhere better. import('lib.pkp.classes.file.FileManager'); $fileManager = new FileManager(); $journalPath = Config::getVar('files', 'files_dir') . '/journals/' . $journalId; $fileManager->rmtree($journalPath); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->rmtree($publicFileManager->getJournalFilesPath($journalId)); } } $request->redirect(null, null, 'journals'); }
/** * Constructor. * Initialize template engine and assign basic template variables. * @param $request PKPRequest */ function __construct($request) { parent::__construct($request); if (!defined('SESSION_DISABLE_INIT')) { /** * Kludge to make sure no code that tries to connect to * the database is executed (e.g., when loading * installer pages). */ $context = $request->getContext(); $site = $request->getSite(); $publicFileManager = new PublicFileManager(); $siteFilesDir = $request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath(); $this->assign('sitePublicFilesDir', $siteFilesDir); $this->assign('publicFilesDir', $siteFilesDir); // May be overridden by journal $siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet('siteStylesheet', $request->getBaseUrl() . '/' . $siteStyleFilename, array('priority' => STYLE_SEQUENCE_LATE)); } // Pass app-specific details to template $this->assign(array('brandImage' => 'templates/images/ojs_brand.png', 'packageKey' => 'common.openJournalSystems', 'pkpLink' => 'http://pkp.sfu.ca/ojs')); // Get a count of unread tasks. if ($user = $request->getUser()) { $notificationDao = DAORegistry::getDAO('NotificationDAO'); // Exclude certain tasks, defined in the notifications grid handler import('lib.pkp.controllers.grid.notifications.TaskNotificationsGridHandler'); $this->assign('unreadNotificationCount', $notificationDao->getNotificationCount(false, $user->getId(), null, NOTIFICATION_LEVEL_TASK)); } if (isset($context)) { $this->assign(array('currentJournal' => $context, 'siteTitle' => $context->getLocalizedName(), 'publicFilesDir' => $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()), 'primaryLocale' => $context->getPrimaryLocale(), 'supportedLocales' => $context->getSupportedLocaleNames(), 'displayPageHeaderTitle' => $context->getLocalizedPageHeaderTitle(), 'displayPageHeaderLogo' => $context->getLocalizedPageHeaderLogo(), 'displayPageHeaderLogoAltText' => $context->getLocalizedSetting('pageHeaderLogoImageAltText'), 'numPageLinks' => $context->getSetting('numPageLinks'), 'itemsPerPage' => $context->getSetting('itemsPerPage'), 'enableAnnouncements' => $context->getSetting('enableAnnouncements'), 'contextSettings' => $context->getSettingsDAO()->getSettings($context->getId()), 'disableUserReg' => $context->getSetting('disableUserReg'))); // Assign meta tags $favicon = $context->getLocalizedFavicon(); if (!empty($favicon)) { $faviconDir = $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()); $this->addHeader('favicon', '<link rel="icon" href="' . $faviconDir . '/' . $favicon['uploadName'] . '">'); } // Assign stylesheets and footer $contextStyleSheet = $context->getSetting('styleSheet'); if ($contextStyleSheet) { $this->addStyleSheet('contextStylesheet', $request->getBaseUrl() . '/' . $publicFileManager->getJournalFilesPath($context->getId()) . '/' . $contextStyleSheet['uploadName'], array('priority' => STYLE_SEQUENCE_LATE)); } // Get a link to the settings page for the current context. // This allows us to reduce template duplication by using this // variable in templates/common/header.tpl, instead of // reproducing a lot of OMP/OJS-specific logic there. $dispatcher = $request->getDispatcher(); $this->assign('contextSettingsUrl', $dispatcher->url($request, ROUTE_PAGE, null, 'management', 'settings', 'journal')); import('classes.payment.ojs.OJSPaymentManager'); $paymentManager = new OJSPaymentManager($request); $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured()); $this->assign('pageFooter', $context->getLocalizedSetting('pageFooter')); } else { // Check if registration is open for any contexts $contextDao = Application::getContextDAO(); $contexts = $contextDao->getAll(true)->toArray(); $contextsForRegistration = array(); foreach ($contexts as $context) { if (!$context->getSetting('disableUserReg')) { $contextsForRegistration[] = $context; } } $this->assign(array('contexts' => $contextsForRegistration, 'disableUserReg' => empty($contextsForRegistration), 'displayPageHeaderTitle' => $site->getLocalizedPageHeaderTitle(), 'displayPageHeaderLogo' => $site->getLocalizedSetting('pageHeaderTitleImage'), 'siteTitle' => $site->getLocalizedTitle(), 'primaryLocale' => $site->getPrimaryLocale(), 'supportedLocales' => $site->getSupportedLocaleNames(), 'pageFooter' => $site->getLocalizedSetting('pageFooter'))); } } }