/** * 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'); }
function uploadArchiveImage() { import('classes.file.PublicFileManager'); $fileManager = new PublicFileManager(); $archive =& $this->archive; $type = $fileManager->getUploadedFileType('archiveImage'); $extension = $fileManager->getImageExtension($type); if (!$extension) { return false; } $uploadName = 'archiveImage-' . (int) $archive->getArchiveId() . $extension; if (!$fileManager->uploadSiteFile('archiveImage', $uploadName)) { return false; } $filePath = $fileManager->getSiteFilesPath(); list($width, $height) = getimagesize($filePath . '/' . $uploadName); if (!Validation::isSiteAdmin() && ($width > 150 || $height > 150 || $width <= 0 || $height <= 0)) { $archiveSetting = null; $archive->updateSetting('archiveImage', $archiveSetting); $fileManager->removeSiteFile($filePath); return false; } $archiveSetting = array('name' => $fileManager->getUploadedFileName('archiveImage'), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate()); $archive->updateSetting('archiveImage', $archiveSetting); return true; }
/** * Save the new image file. * @param $request Request. */ function execute($request) { $temporaryFile = $this->fetchTemporaryFile($request); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if (is_a($temporaryFile, 'TemporaryFile')) { $type = $temporaryFile->getFileType(); $extension = $publicFileManager->getImageExtension($type); if (!$extension) { return false; } $locale = AppLocale::getLocale(); $context = $request->getContext(); $uploadName = $this->getFileSettingName() . '_' . $locale . $extension; if ($publicFileManager->copyContextFile($context->getAssocType(), $context->getId(), $temporaryFile->getFilePath(), $uploadName)) { // Get image dimensions $filePath = $publicFileManager->getContextFilesPath($context->getAssocType(), $context->getId()); list($width, $height) = getimagesize($filePath . '/' . $uploadName); $value = $context->getSetting($this->getFileSettingName()); $imageAltText = $this->getData('imageAltText'); $value[$locale] = array('name' => $temporaryFile->getOriginalFileName(), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate(), 'altText' => $imageAltText[$locale]); $settingsDao = $context->getSettingsDAO(); $settingsDao->updateSetting($context->getId(), $this->getFileSettingName(), $value, 'object', true); // Clean up the temporary file. $this->removeTemporaryFile($request); return true; } } return false; }
/** * 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); }
/** * 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 press $siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet($request->getBaseUrl() . '/' . $siteStyleFilename, STYLE_SEQUENCE_LAST); } if (isset($context)) { $this->assign('currentPress', $context); $this->assign('siteTitle', $context->getLocalizedName()); $this->assign('publicFilesDir', $request->getBaseUrl() . '/' . $publicFileManager->getContextFilesPath($context->getAssocType(), $context->getId())); $this->assign('primaryLocale', $context->getPrimaryLocale()); $this->assign('alternateLocales', $context->getSetting('alternateLocales')); // Assign page header $this->assign('displayPageHeaderTitle', $context->getPageHeaderTitle()); $this->assign('displayPageHeaderLogo', $context->getPageHeaderLogo()); $this->assign('alternatePageHeader', $context->getLocalizedSetting('pageHeader')); $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('styleSheet'); if ($contextStyleSheet) { $this->addStyleSheet($request->getBaseUrl() . '/' . $publicFileManager->getContextFilesPath(ASSOC_TYPE_PRESS, $context->getId()) . '/' . $contextStyleSheet['uploadName'], STYLE_SEQUENCE_LAST); } // 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('pageFooter')); } 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()); } } }
/** * 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(); } }
/** * Display the form. */ function display() { import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $schedConf =& Request::getSchedConf(); $templateMgr =& TemplateManager::getManager(); $site =& Request::getSite(); $templateMgr->assign('helpTopicId', 'conference.currentConferences.accommodation'); $templateMgr->assign('publicSchedConfFilesDir', Request::getBaseUrl() . '/' . $publicFileManager->getSchedConfFilesPath($schedConf->getId())); $templateMgr->assign('accommodationFiles', $schedConf->getSetting('accommodationFiles')); parent::display(); }
/** * 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']; } }
function uploadProfileImage() { import('file.PublicFileManager'); $fileManager = new PublicFileManager(); $user =& $this->user; $type = $fileManager->getUploadedFileType('profileImage'); $extension = $fileManager->getImageExtension($type); if (!$extension) { return false; } $uploadName = 'profileImage-' . (int) $user->getId() . $extension; if ($fileManager->uploadError('profileImage')) { return false; } if (!$fileManager->uploadSiteFile('profileImage', $uploadName)) { return false; } $filePath = $fileManager->getSiteFilesPath(); list($width, $height) = getimagesize($filePath . '/' . $uploadName); if ($width > 150 || $height > 150 || $width <= 0 || $height <= 0) { $userSetting = null; $user->updateSetting('profileImage', $userSetting); $fileManager->removeSiteFile($filePath); return false; } $userSetting = array('name' => $fileManager->getUploadedFileName('profileImage'), 'uploadName' => $uploadName, 'width' => $width, 'height' => $height, 'dateUploaded' => Core::getCurrentDate()); $user->updateSetting('profileImage', $userSetting); return true; }
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); }
/** * 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) { // FIXME: for backwards compatibility only - remove if (!isset($request)) { // FIXME: Trigger a deprecation warning when enough instances of this // call have been fixed to not clutter the error log. $request =& Registry::get('request'); } assert(is_a($request, 'PKPRequest')); 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). */ $site =& $request->getSite(); $publicFileManager = new PublicFileManager(); $siteFilesDir = $request->getBaseUrl() . '/' . $publicFileManager->getSiteFilesPath(); $this->assign('sitePublicFilesDir', $siteFilesDir); $this->assign('publicFilesDir', $siteFilesDir); $this->assign('isAdmin', Validation::isSiteAdmin()); // assign an empty home context $this->assign('homeContext', array()); $siteStyleFilename = $publicFileManager->getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet($request->getBaseUrl() . '/' . $siteStyleFilename); } // Load and apply theme plugin, if chosen $themePluginPath = $site->getSetting('theme'); if (!empty($themePluginPath)) { // Load and activate the theme $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath); if ($themePlugin) { $themePlugin->activate($this); } } // Add the site-wide logo, if set for this locale or the primary locale $this->assign('displayPageHeaderTitle', $site->getLocalizedPageHeaderTitle()); $customLogo = $site->getSetting('customLogo'); if ($customLogo) { $this->assign('displayPageHeaderLogo', $customLogo); } $this->assign('siteTitle', $site->getLocalizedTitle()); $this->assign('enableSubmit', $site->getSetting('enableSubmit')); } }
/** * 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; }
/** * An action to delete an article cover image. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function deleteCoverImage($args, $request) { assert(!empty($args['coverImage']) && !empty($args['submissionId'])); $submission = $this->getSubmission(); $submissionDao = Application::getSubmissionDAO(); $file = $args['coverImage']; // Remove cover image and alt text from article settings $submission->setCoverImage(''); $submission->setCoverImageAltText(''); $submissionDao->updateObject($submission); // Remove the file $publicFileManager = new PublicFileManager(); if ($publicFileManager->removeJournalFile($submission->getJournalId(), $file)) { $json = new JSONMessage(true); $json->setEvent('fileDeleted'); return $json; } else { return new JSONMessage(false, __('editor.article.removeCoverImageFileNotFound')); } }
/** * Validate and save changes to site settings. * @param $args array * @param $request object */ function saveSettings($args, &$request) { $this->validate(); $this->setupTemplate($request, true); $site =& $request->getSite(); import('classes.admin.form.SiteSettingsForm'); $settingsForm = new SiteSettingsForm(); $settingsForm->readInputData(); if ($request->getUserVar('uploadSiteStyleSheet')) { if (!$settingsForm->uploadSiteStyleSheet()) { $settingsForm->addError('siteStyleSheet', __('admin.settings.siteStyleSheetInvalid')); } } elseif ($request->getUserVar('deleteSiteStyleSheet')) { $publicFileManager = new PublicFileManager(); $publicFileManager->removeSiteFile($site->getSiteStyleFilename()); } elseif ($request->getUserVar('uploadPageHeaderTitleImage')) { if (!$settingsForm->uploadPageHeaderTitleImage($settingsForm->getFormLocale())) { $settingsForm->addError('pageHeaderTitleImage', __('admin.settings.homeHeaderImageInvalid')); } } elseif ($request->getUserVar('deletePageHeaderTitleImage')) { $publicFileManager = new PublicFileManager(); $setting = $site->getSetting('pageHeaderTitleImage'); $formLocale = $settingsForm->getFormLocale(); if (isset($setting[$formLocale])) { $publicFileManager->removeSiteFile($setting[$formLocale]['uploadName']); $setting[$formLocale] = array(); $site->updateSetting('pageHeaderTitleImage', $setting, 'object', true); // Refresh site header $templateMgr =& TemplateManager::getManager($request); $templateMgr->assign('displaySitePageHeaderTitle', $site->getLocalizedPageHeaderTitle()); } } elseif ($settingsForm->validate()) { $settingsForm->execute(); import('classes.notification.NotificationManager'); $notificationManager = new NotificationManager(); $user =& $request->getUser(); $notificationManager->createTrivialNotification($user->getId()); $request->redirect(null, null, null, 'index'); } $settingsForm->display(); }
/** * Validate and save changes to site settings. */ function saveSettings() { $this->validate(); $this->setupTemplate(true); $site =& Request::getSite(); import('admin.form.SiteSettingsForm'); $settingsForm = new SiteSettingsForm(); $settingsForm->readInputData(); if (Request::getUserVar('uploadSiteStyleSheet')) { if (!$settingsForm->uploadSiteStyleSheet()) { $settingsForm->addError('siteStyleSheet', Locale::translate('admin.settings.siteStyleSheetInvalid')); } } elseif (Request::getUserVar('deleteSiteStyleSheet')) { $publicFileManager = new PublicFileManager(); $publicFileManager->removeSiteFile($site->getSiteStyleFilename()); } elseif (Request::getUserVar('uploadPageHeaderTitleImage')) { if (!$settingsForm->uploadPageHeaderTitleImage($settingsForm->getFormLocale())) { $settingsForm->addError('pageHeaderTitleImage', Locale::translate('admin.settings.homeHeaderImageInvalid')); } } elseif (Request::getUserVar('deletePageHeaderTitleImage')) { $publicFileManager = new PublicFileManager(); $setting = $site->getSetting('pageHeaderTitleImage'); $formLocale = $settingsForm->getFormLocale(); if (isset($setting[$formLocale])) { $publicFileManager->removeSiteFile($setting[$formLocale]['uploadName']); $setting[$formLocale] = array(); $site->updateSetting('pageHeaderTitleImage', $setting, 'object', true); // Refresh site header $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('displaySitePageHeaderTitle', $site->getLocalizedPageHeaderTitle()); } } elseif ($settingsForm->validate()) { $settingsForm->execute(); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign(array('currentUrl' => Request::url(null, null, null, 'settings'), 'pageTitle' => 'admin.siteSettings', 'message' => 'common.changesSaved', 'backLink' => Request::url(null, null, Request::getRequestedPage()), 'backLinkLabel' => 'admin.siteAdmin')); $templateMgr->display('common/message.tpl'); exit; } $settingsForm->display(); }
/** * Save the new image file. * @param $request Request. */ function execute($request) { $temporaryFile = $this->fetchTemporaryFile($request); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if (is_a($temporaryFile, 'TemporaryFile')) { $type = $temporaryFile->getFileType(); if ($type != 'text/plain' && $type != 'text/css') { return false; } $settingName = $this->getFileSettingName(); $uploadName = $settingName . '.css'; $context = $request->getContext(); if ($publicFileManager->copyContextFile($context->getAssocType(), $context->getId(), $temporaryFile->getFilePath(), $uploadName)) { $value = array('name' => $temporaryFile->getOriginalFileName(), 'uploadName' => $uploadName, 'dateUploaded' => Core::getCurrentDate()); $settingsDao = $context->getSettingsDAO(); $settingsDao->updateSetting($context->getId(), $settingName, $value, 'object'); // Clean up the temporary file $this->removeTemporaryFile($request); return true; } } return false; }
/** * Save the new image file. * @param $request Request. */ function execute($request) { $temporaryFile = $this->fetchTemporaryFile($request); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if (is_a($temporaryFile, 'TemporaryFile')) { $type = $temporaryFile->getFileType(); if ($type != 'text/plain' && $type != 'text/css') { return false; } $settingName = $this->getFileSettingName(); $site = $request->getSite(); $uploadName = $site->getSiteStyleFilename(); if ($publicFileManager->copyFile($temporaryFile->getFilePath(), $publicFileManager->getSiteFilesPath() . '/' . $uploadName)) { $siteDao = DAORegistry::getDAO('SiteDAO'); $site->setOriginalStyleFilename($temporaryFile->getOriginalFileName()); $siteDao->updateObject($site); // Clean up the temporary file $this->removeTemporaryFile($request); return true; } } return false; }
/** * Constructor. * Initialize template engine and assign basic template variables. */ function TemplateManager() { parent::PKPTemplateManager(); 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). */ $site =& Request::getSite(); $siteFilesDir = Request::getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath(); $this->assign('sitePublicFilesDir', $siteFilesDir); $this->assign('publicFilesDir', $siteFilesDir); $this->assign('isAdmin', Validation::isSiteAdmin()); // assign an empty home context $this->assign('homeContext', array()); $siteStyleFilename = PublicFileManager::getSiteFilesPath() . '/' . $site->getSiteStyleFilename(); if (file_exists($siteStyleFilename)) { $this->addStyleSheet(Request::getBaseUrl() . '/' . $siteStyleFilename); } // Load and apply theme plugin, if chosen $themePluginPath = $site->getSetting('theme'); if (!empty($themePluginPath)) { // Load and activate the theme $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath); if ($themePlugin) { $themePlugin->activate($this); } } // Add the site-wide logo, if set for this locale or the primary locale $this->assign('displayPageHeaderTitle', $site->getLocalizedPageHeaderTitle()); $customLogo = $site->getSetting('customLogo'); if ($customLogo) { $this->assign('useCustomLogo', $customLogo); } $this->assign('siteTitle', $site->getLocalizedTitle()); $this->assign('enableSubmit', $site->getSetting('enableSubmit')); } }
/** * Uploads conference custom stylesheet. * @param $settingName string setting key associated with the file */ function uploadStyleSheet($settingName) { $conference =& Request::getConference(); $settingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO'); import('file.PublicFileManager'); $fileManager = new PublicFileManager(); if ($fileManager->uploadError($settingName)) { return false; } if ($fileManager->uploadedFileExists($settingName)) { $type = $fileManager->getUploadedFileType($settingName); if ($type != 'text/plain' && $type != 'text/css') { return false; } $uploadName = $settingName . '.css'; if ($fileManager->uploadConferenceFile($conference->getId(), $settingName, $uploadName)) { $value = array('name' => $fileManager->getUploadedFileName($settingName), 'uploadName' => $uploadName, 'dateUploaded' => date("Y-m-d g:i:s")); $settingsDao->updateSetting($conference->getId(), $settingName, $value, 'object'); return true; } } return false; }
/** * Remove the cover page image for the book for review * @param $bookId int */ function removeCoverPage($bookId, $locale) { $book = $this->getBookForReview($bookId); if ($book) { // Delete cover image file from the filesystem and settings import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->removeJournalFile($book->getJournalId(), $book->getFileName($locale)); $book->setFileName(null, $locale); $book->setWidth(null, $locale); $book->setHeight(null, $locale); $book->setOriginalFileName(null, $locale); $book->setCoverPageAltText(null, $locale); $this->updateObject($book); } }
/** * Remove cover page from article * @param $submission object * @param $formLocale string * @return boolean true iff ready for redirect */ function removeArticleCoverPage($submission, $formLocale) { $journal =& Request::getJournal(); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->removeJournalFile($journal->getId(), $submission->getFileName($formLocale)); $submission->setFileName('', $formLocale); $submission->setOriginalFileName('', $formLocale); $submission->setWidth('', $formLocale); $submission->setHeight('', $formLocale); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $articleDao->updateArticle($submission); return true; }
/** * Remove cover page from article */ function removeArticleCoverPage($args, &$request) { $articleId = isset($args[0]) ? (int) $args[0] : 0; $this->validate($articleId); $formLocale = $args[1]; if (!Locale::isLocaleValid($formLocale)) { $request->redirect(null, null, 'viewMetadata', $articleId); } $submission =& $this->submission; $journal =& $request->getJournal(); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $publicFileManager->removeJournalFile($journal->getId(), $submission->getFileName($formLocale)); $submission->setFileName('', $formLocale); $submission->setOriginalFileName('', $formLocale); $submission->setWidth('', $formLocale); $submission->setHeight('', $formLocale); $articleDao =& DAORegistry::getDAO('ArticleDAO'); $articleDao->updateArticle($submission); $request->redirect(null, null, 'viewMetadata', $articleId); }
/** * Fetch the form. * @param $request PKPRequest * @return string JSON-encoded form contents. */ function fetch($request) { $templateMgr = TemplateManager::getManager($request); $publicFileManager = new PublicFileManager(); $templateMgr->assign(array('profileImage' => $request->getUser()->getSetting('profileImage'), 'profileImageMaxWidth' => PROFILE_IMAGE_MAX_WIDTH, 'profileImageMaxHeight' => PROFILE_IMAGE_MAX_HEIGHT, 'publicSiteFilesPath' => $publicFileManager->getSiteFilesPath())); return parent::fetch($request); }
/** * Save issue settings. * @param $request PKPRequest * @return int Issue ID for created/updated issue */ function execute($request) { $journal = $request->getJournal(); $issueDao = DAORegistry::getDAO('IssueDAO'); if ($this->issue) { $isNewIssue = false; $issue = $this->issue; } else { $issue = $issueDao->newDataObject(); $isNewIssue = true; } $volume = $this->getData('volume'); $number = $this->getData('number'); $year = $this->getData('year'); $issue->setJournalId($journal->getId()); $issue->setTitle($this->getData('title'), null); // Localized $issue->setVolume(empty($volume) ? 0 : $volume); $issue->setNumber(empty($number) ? 0 : $number); $issue->setYear(empty($year) ? 0 : $year); if (!$isNewIssue) { $issue->setDatePublished($this->getData('datePublished')); } $issue->setDescription($this->getData('description'), null); // Localized $issue->setStoredPubId('publisher-id', $this->getData('publicIssueId')); $issue->setShowVolume($this->getData('showVolume')); $issue->setShowNumber($this->getData('showNumber')); $issue->setShowYear($this->getData('showYear')); $issue->setShowTitle($this->getData('showTitle')); $issue->setAccessStatus($this->getData('accessStatus') ? $this->getData('accessStatus') : ISSUE_ACCESS_OPEN); // See bug #6324 if ($this->getData('enableOpenAccessDate')) { $issue->setOpenAccessDate($this->getData('openAccessDate')); } else { $issue->setOpenAccessDate(null); } // consider the additional field names from the public identifer plugins import('classes.plugins.PubIdPluginHelper'); $pubIdPluginHelper = new PubIdPluginHelper(); $pubIdPluginHelper->execute($this, $issue); // if issueId is supplied, then update issue otherwise insert a new one if (!$isNewIssue) { parent::execute(); $issueDao->updateObject($issue); } else { $issue->setPublished(0); $issue->setCurrent(0); $issueDao->insertObject($issue); } // Copy an uploaded CSS file for the issue, if there is one. // (Must be done after insert for new issues as issue ID is in the filename.) if ($temporaryFileId = $this->getData('temporaryFileId')) { $user = $request->getUser(); $temporaryFileDao = DAORegistry::getDAO('TemporaryFileDAO'); $temporaryFile = $temporaryFileDao->getTemporaryFile($temporaryFileId, $user->getId()); import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $newFileName = 'style_' . $issue->getId() . '.css'; $publicFileManager->copyJournalFile($journal->getId(), $temporaryFile->getFilePath(), $newFileName); $issue->setStyleFileName($newFileName); $issue->setOriginalStyleFileName($publicFileManager->truncateFileName($temporaryFile->getOriginalFileName(), 127)); $issueDao->updateObject($issue); } }
/** * 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); }
/** * Delete an uploaded file. * @param $fileSettingName string * @param $request PKPRequest * @return boolean */ function deleteFile($fileSettingName, $request) { $context = $request->getContext(); $locale = AppLocale::getLocale(); // Get the file. $file = $this->getData($fileSettingName); // Check if the file is localized. if (key_exists($locale, $file)) { // We use the current localized file value. $file = $file[$locale]; } else { $locale = null; } // Deletes the file and its settings. import('classes.file.PublicFileManager'); $publicFileManager = new PublicFileManager(); if ($publicFileManager->removeContextFile($context->getAssocType(), $context->getId(), $file['uploadName'])) { $settingsDao = $context->getSettingsDao(); $settingsDao->deleteSetting($context->getId(), $fileSettingName, $locale); return true; } else { 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'); }
/** * 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; }
/** * Given a scheduled conference, set up the template with all the * required variables for schedConf/view.tpl to function properly. * @param $schedConf object The scheduled conference to display * the cover page will be displayed. Otherwise table of contents * will be displayed. */ function setupTemplate(&$conference, &$schedConf) { parent::setupTemplate(); $templateMgr =& TemplateManager::getManager(); AppLocale::requireComponents(array(LOCALE_COMPONENT_OCS_MANAGER)); // Ensure the user is entitled to view the scheduled conference... if (isset($schedConf) && ($conference->getEnabled() || (Validation::isDirector($conference->getId()) || Validation::isConferenceManager($conference->getId())))) { // Assign header and content for home page $templateMgr->assign('displayPageHeaderTitle', $conference->getPageHeaderTitle(true)); $templateMgr->assign('displayPageHeaderLogo', $conference->getPageHeaderLogo(true)); $templateMgr->assign('displayPageHeaderTitleAltText', $conference->getLocalizedSetting('homeHeaderTitleImageAltText')); $templateMgr->assign('displayPageHeaderLogoAltText', $conference->getLocalizedSetting('homeHeaderLogoImageAltText')); $templateMgr->assign_by_ref('schedConf', $schedConf); $templateMgr->assign('additionalHomeContent', $conference->getLocalizedSetting('additionalHomeContent')); } else { Request::redirect(null, 'index'); } if ($styleFileName = $schedConf->getStyleFileName()) { import('file.PublicFileManager'); $publicFileManager = new PublicFileManager(); $templateMgr->addStyleSheet(Request::getBaseUrl() . '/' . $publicFileManager->getConferenceFilesPath($conference->getId()) . '/' . $styleFileName); } $this->checkRole($conference, $schedConf); $templateMgr->assign("conferenceUrl", Request::url(null, 'index')); $templateMgr->assign("conferenceId", $conference->getId()); $templateMgr->assign("schedConfId", $schedConf->getId()); $templateMgr->assign("schedConfUrl", Request::url(null, $conference->getSetting('path'))); $templateMgr->assign("conferencePath", $conference->getSetting('path')); }
/** * 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()); } } }