/** * @see FileLoader::execute() */ function execute() { if (!$this->_plugin) { return false; } $plugin = $this->_plugin; $journals = $this->_getJournals(); $request =& Application::getRequest(); foreach ($journals as $journal) { $unregisteredArticles = $plugin->_getUnregisteredArticles($journal); $unregisteredArticlesIds = array(); foreach ($unregisteredArticles as $articleData) { $article = $articleData['article']; if (is_a($article, 'PublishedArticle')) { $unregisteredArticlesIds[$article->getId()] = $article; } } $toBeDepositedIds = array(); foreach ($unregisteredArticlesIds as $id => $article) { if (!$plugin->updateDepositStatus($request, $journal, $article)) { array_push($toBeDepositedIds, $id); } } // If there are unregistered things and we want automatic deposits if (count($toBeDepositedIds) && $plugin->getSetting($journal->getId(), 'automaticRegistration')) { $exportSpec = array(DOI_EXPORT_ARTICLES => $toBeDepositedIds); $plugin->registerObjects($request, $exportSpec, $journal); } } }
/** * Constructor. * @param $submission object * @param $step int */ function SubmissionSubmitForm($context, $submission, $step) { parent::Form(sprintf('submission/form/step%d.tpl', $step)); $this->addCheck(new FormValidatorPost($this)); $this->step = (int) $step; $this->submission = $submission; $this->submissionId = $submission ? $submission->getId() : null; $this->context = $context; // Determine whether or not the current user belongs to a manager, editor, or assistant group // and could potentially expedite this submission. $request = Application::getRequest(); $user = $request->getUser(); $userGroupAssignmentDao = DAORegistry::getDAO('UserGroupAssignmentDAO'); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $userGroupAssignments = $userGroupAssignmentDao->getByUserId($user->getId(), $context->getId()); if (!$userGroupAssignments->wasEmpty()) { while ($userGroupAssignment = $userGroupAssignments->next()) { $userGroup = $userGroupDao->getById($userGroupAssignment->getUserGroupId()); if (in_array($userGroup->getRoleId(), array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT))) { $this->_canExpedite = true; break; } } } }
public function __construct() { $this->_request = Application::getRequest(); $this->_response = Application::getResponse(); $this->view = Application::getView(); $this->init(); }
/** * Initialize the theme's styles, scripts and hooks. This is run on the * currently active theme and it's parent themes. * * @return null */ public function init() { // Load Noto Sans font from Google Font CDN // To load extended latin or other character sets, see: // https://www.google.com/fonts#UsePlace:use/Collection:Noto+Sans if (Config::getVar('general', 'enable_cdn')) { $this->addStyle('fontNotoSans', '//fonts.googleapis.com/css?family=Noto+Sans:400,400italic,700,700italic', array('baseUrl' => '')); } // Load primary stylesheet $this->addStyle('stylesheet', 'styles/index.less'); // Load jQuery from a CDN or, if CDNs are disabled, from a local copy. $min = Config::getVar('general', 'enable_minified') ? '.min' : ''; $request = Application::getRequest(); if (Config::getVar('general', 'enable_cdn')) { $jquery = '//ajax.googleapis.com/ajax/libs/jquery/' . CDN_JQUERY_VERSION . '/jquery' . $min . '.js'; $jqueryUI = '//ajax.googleapis.com/ajax/libs/jqueryui/' . CDN_JQUERY_UI_VERSION . '/jquery-ui' . $min . '.js'; } else { // Use OJS's built-in jQuery files $jquery = $request->getBaseUrl() . '/lib/pkp/lib/vendor/components/jquery/jquery' . $min . '.js'; $jqueryUI = $request->getBaseUrl() . '/lib/pkp/lib/vendor/components/jqueryui/jquery-ui' . $min . '.js'; } // Use an empty `baseUrl` argument to prevent the theme from looking for // the files within the theme directory $this->addScript('jQuery', $jquery, array('baseUrl' => '')); $this->addScript('jQueryUI', $jqueryUI, array('baseUrl' => '')); $this->addScript('jQueryTagIt', $request->getBaseUrl() . '/lib/pkp/js/lib/jquery/plugins/jquery.tag-it.js', array('baseUrl' => '')); // Load custom JavaScript for this theme $this->addScript('default', 'js/main.js'); }
/** * コンストラクタ * * @param Application $application */ public function __construct($application) { $this->controller_name = strtolower(substr(get_class($this), 0, -10)); $this->application = $application; $this->request = $application->getRequest(); $this->response = $application->getResponse(); $this->session = $application->getSession(); $this->db_manager = $application->getDbManager(); }
/** * Constructor */ function __construct() { // import app-specific grid data provider for access policies. $request = Application::getRequest(); $fileId = $request->getUserVar('fileId'); // authorized in authorize() method. import('lib.pkp.controllers.grid.files.dependent.DependentFilesGridDataProvider'); parent::__construct(new DependentFilesGridDataProvider($fileId), WORKFLOW_STAGE_ID_PRODUCTION, FILE_GRID_ADD | FILE_GRID_DELETE | FILE_GRID_VIEW_NOTES | FILE_GRID_EDIT); $this->addRoleAssignment(array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT, ROLE_ID_AUTHOR), array('fetchGrid', 'fetchRow')); }
/** * Constructor */ function __construct() { import('lib.pkp.controllers.grid.files.query.QueryNoteFilesCategoryGridDataProvider'); $request = Application::getRequest(); $stageId = $request->getUservar('stageId'); // authorized by data provider. parent::__construct(new QueryNoteFilesCategoryGridDataProvider(), $stageId, FILE_GRID_DELETE | FILE_GRID_VIEW_NOTES | FILE_GRID_EDIT); $this->addRoleAssignment(array(ROLE_ID_SUB_EDITOR, ROLE_ID_MANAGER, ROLE_ID_ASSISTANT), array('fetchGrid', 'fetchCategory', 'fetchRow', 'addFile', 'downloadFile', 'deleteFile', 'updateQueryNoteFiles')); // Set the grid title. $this->setTitle('submission.queryNoteFiles'); }
/** * Constructor. * @param $template string Form template * @param $pubObject object * @param $approval boolean * @param $confirmationText string */ function __construct($template, $pubObject, $approval, $confirmationText) { parent::__construct($template); $this->_pubObject = $pubObject; $this->_approval = $approval; $this->_confirmationText = $confirmationText; $request = Application::getRequest(); $context = $request->getContext(); $this->_contextId = $context->getId(); $this->addCheck(new FormValidatorPost($this)); $this->addCheck(new FormValidatorCSRF($this)); }
/** * Constructor */ function QueryNoteFilesGridHandler() { // import app-specific grid data provider for access policies. $request = Application::getRequest(); $stageId = $request->getUservar('stageId'); // authorized in authorize() method. import('lib.pkp.controllers.grid.files.query.QueryNoteFilesGridDataProvider'); parent::FileListGridHandler(new QueryNoteFilesGridDataProvider($request->getUserVar('noteId')), $stageId, FILE_GRID_ADD | FILE_GRID_DELETE | FILE_GRID_VIEW_NOTES | FILE_GRID_EDIT); $this->addRoleAssignment(array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT, ROLE_ID_AUTHOR), array('fetchGrid', 'fetchRow', 'selectFiles')); // Set grid title. $this->setTitle('submission.queries.attachedFiles'); }
/** * Check the number of lisbuilder rows. If it's equal to 0, return false. * * @see FormValidator::isValid() * @return boolean */ function isValid() { $value = $this->getFieldValue(); import('lib.pkp.classes.controllers.listbuilder.ListbuilderHandler'); $request =& Application::getRequest(); ListbuilderHandler::unpack($request, $value); if ($this->_valid) { return true; } else { return false; } }
/** * Constructor. * @param $pressId Press id. * @param $categoryId Category id. */ function CategoryForm($pressId, $categoryId = null) { parent::Form('controllers/grid/settings/category/form/categoryForm.tpl'); $this->_pressId = $pressId; $this->_categoryId = $categoryId; $request = Application::getRequest(); $user = $request->getUser(); $this->_userId = $user->getId(); // Validation checks for this form $this->addCheck(new FormValidatorLocale($this, 'name', 'required', 'grid.category.nameRequired')); $this->addCheck(new FormValidatorAlphaNum($this, 'path', 'required', 'grid.category.pathAlphaNumeric')); $this->addCheck(new FormValidatorCustom($this, 'path', 'required', 'grid.category.pathExists', create_function('$path,$form,$categoryDao,$pressId', 'return !$categoryDao->categoryExistsByPath($path,$pressId) || ($form->getData(\'oldPath\') != null && $form->getData(\'oldPath\') == $path);'), array(&$this, DAORegistry::getDAO('CategoryDAO'), $pressId))); $this->addCheck(new FormValidatorPost($this)); }
/** * Perform additional validation checks * @copydoc Form::validate */ function validate() { if (!parent::validate()) { return false; } // Validate that the section ID is attached to this journal. $request = Application::getRequest(); $context = $request->getContext(); $sectionDao = DAORegistry::getDAO('SectionDAO'); $section = $sectionDao->getById($this->getData('sectionId'), $context->getId()); if (!$section) { return false; } return true; }
/** * Constructor. * @param $submissionId integer * @param $userId integer * @param $stageId integer * @param $formParams array */ function IssueEntryPublicationMetadataForm($submissionId, $userId, $stageId = null, $formParams = null) { parent::Form('controllers/tab/issueEntry/form/publicationMetadataFormFields.tpl'); $submissionDao = Application::getSubmissionDAO(); $this->_submission = $submissionDao->getById($submissionId); $this->_stageId = $stageId; $this->_formParams = $formParams; $this->_userId = $userId; $this->addCheck(new FormValidatorPost($this)); if (isset($formParams['expeditedSubmission']) && $formParams['expeditedSubmission']) { // make choosing an issue mandatory for expedited submissions. $request = Application::getRequest(); $context = $request->getContext(); $this->addCheck(new FormValidatorCustom($this, 'issueId', 'required', 'author.submit.form.issueRequired', array(DAORegistry::getDAO('IssueDAO'), 'issueIdExists'), array($context->getId()))); } }
/** * Constructor. * @param $template string Form template path * @param $pubObject object * @param $stageId integer * @param $formParams array */ function PKPPublicIdentifiersForm($pubObject, $stageId = null, $formParams = null) { parent::Form('controllers/tab/pubIds/form/publicIdentifiersForm.tpl'); $this->_pubObject = $pubObject; $this->_stageId = $stageId; $this->_formParams = $formParams; $request = Application::getRequest(); $context = $request->getContext(); $this->_contextId = $context->getId(); AppLocale::requireComponents(LOCALE_COMPONENT_PKP_EDITOR); $this->addCheck(new FormValidatorPost($this)); $this->addCheck(new FormValidatorCSRF($this)); // action links for pub id reset requests $pubIdPluginHelper = new PKPPubIdPluginHelper(); $pubIdPluginHelper->setLinkActions($this->getContextId(), $this, $pubObject); }
/** * Perform additional validation checks * @copydoc Form::validate */ function validate() { if (!parent::validate()) { return false; } // Validate that the series ID is attached to this press. if ($seriesId = $this->getData('seriesId')) { $request = Application::getRequest(); $context = $request->getContext(); $seriesDao = DAORegistry::getDAO('SeriesDAO'); $series = $seriesDao->getById($seriesId, $context->getId()); if (!$series) { return false; } } return true; }
/** * Perform additional validation checks * @copydoc Form::validate */ function validate() { if (!parent::validate()) { return false; } // Ensure that the user is in the specified authorUserGroupId $authorUserGroupId = $this->getData('authorUserGroupId'); $userGroupDao = DAORegistry::getDAO('UserGroupDAO'); $request = Application::getRequest(); $context = $request->getContext(); $user = $request->getUser(); if (!$user) { return false; } $userGroups = $userGroupDao->getByUserId($user->getId(), $context->getId()); while ($userGroup = $userGroups->next()) { if ($userGroup->getId() == $authorUserGroupId) { return true; } } return false; }
/** * @copydoc GridCellProvider::getTemplateVarsFromRowColumn() */ function getTemplateVarsFromRowColumn($row, $column) { $monograph = $row->getData(); switch ($column->getId()) { case 'id': return array('label' => $monograph->getId()); case 'title': // Delegate to the submission grid cell provider that holds the logic // for the submission title plus author name. $user = Application::getRequest()->getUser(); import('lib.pkp.controllers.grid.submissions.SubmissionsListGridCellProvider'); $submissionsListCellProvider = new SubmissionsListGridCellProvider($user); return $submissionsListCellProvider->getTemplateVarsFromRowColumn($row, $column); case 'isFeatured': $featureDao = DAORegistry::getDAO('FeatureDAO'); return array('selected' => $featureDao->isFeatured($monograph->getId(), $this->_assocType, $this->_assocId)); case 'isNewRelease': $newReleaseDao = DAORegistry::getDAO('NewReleaseDAO'); return array('selected' => $newReleaseDao->isNewRelease($monograph->getId(), $this->_assocType, $this->_assocId)); } return parent::getTemplateVarsFromRowColumn($row, $column); }
/** * @see ImportExportPlugin::executeCLI() */ function executeCLI($scriptName, &$args) { $result = array(); // Add additional locale file. AppLocale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON)); // Command. $command = strtolower_codesafe(array_shift($args)); if (!in_array($command, array('export', 'register'))) { $result = false; } if ($command == 'export') { // Output file. if (is_array($result)) { $xmlFile = array_shift($args); if (empty($xmlFile)) { $result = false; } } } // Journal. if (is_array($result)) { $journalPath = array_shift($args); $journalDao =& DAORegistry::getDAO('JournalDAO'); $journal =& $journalDao->getJournalByPath($journalPath); if (!$journal) { if ($journalPath != '') { $result[] = array('plugins.importexport.common.export.error.unknownJournal', $journalPath); } elseif (empty($result)) { $result = false; } } } // Object type. if (is_array($result) && empty($result)) { $objectType = strtolower_codesafe(array_shift($args)); // Accept both singular and plural forms. if (substr($objectType, -1) == 's') { $objectType = substr($objectType, 0, -1); } if ($objectType == 'suppfile') { $objectType = 'suppFile'; } // Check whether the object type exists. $objectTypes = $this->getAllObjectTypes(); if (!in_array($objectType, array_keys($objectTypes))) { // Return an error for unhandled object types. $result[] = array('plugins.importexport.common.export.error.unknownObjectType', $objectType); } } // Export (or register) objects. if (is_array($result) && empty($result)) { assert(isset($objectTypes[$objectType])); $exportSpec = array($objectTypes[$objectType] => $args); $request =& Application::getRequest(); if ($command == 'export') { $result = $this->exportObjects($request, $exportSpec, $journal, $xmlFile); } else { $result = $this->registerObjects($request, $exportSpec, $journal); if ($result === true) { echo __('plugins.importexport.common.register.success') . "\n"; } } } if ($result !== true) { $this->_usage($scriptName, $result); } }
/** * @see GridFeature::getRequestArgs() * @param $args array */ function getRequestArgs($args) { $grid = $args['grid']; $requestArgs =& $args['requestArgs']; // Add paging info so grid actions will not loose paging context. // Only works if grid link actions use the getRequestArgs // returned content. $request = Application::getRequest(); $rangeInfo = $grid->getGridRangeInfo($request, $grid->getId()); $requestArgs[GridHandler::getPageParamName($grid->getId())] = $rangeInfo->getPage(); $requestArgs[$this->_getItemsPerPageParamName($grid->getId())] = $rangeInfo->getCount(); }
/** * 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; }
/** * Return the currently selected result * set ordering option (default: descending relevance). * @param $journal Journal * @return array An array with the order field as the * first entry and the order direction as the second * entry. */ function _getResultSetOrdering($journal) { // Retrieve the request. $request =& Application::getRequest(); // Order field. $orderBy = $request->getUserVar('orderBy'); $orderByOptions = $this->_getResultSetOrderingOptions($journal); if (is_null($orderBy) || !in_array($orderBy, array_keys($orderByOptions))) { $orderBy = 'score'; } // Ordering direction. $orderDir = $request->getUserVar('orderDir'); $orderDirOptions = $this->_getResultSetOrderingDirectionOptions(); if (is_null($orderDir) || !in_array($orderDir, array_keys($orderDirOptions))) { if (in_array($orderBy, array('score', 'publicationDate', 'issuePublicationDate'))) { $orderDir = 'desc'; } else { $orderDir = 'asc'; } } return array($orderBy, $orderDir); }
function display(&$args) { $journal =& Request::getJournal(); $issueDao =& DAORegistry::getDAO('IssueDAO'); $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO'); $galleyDao =& DAORegistry::getDAO('ArticleGalleyDAO'); /* @var $galleyDao ArticleGalleyDAO */ $metricsDao =& DAORegistry::getDAO('MetricsDAO'); /* @var $metricsDao MetricsDAO */ $columns = array(__('plugins.reports.views.articleId'), __('plugins.reports.views.articleTitle'), __('issue.issue'), __('plugins.reports.views.datePublished'), __('plugins.reports.views.abstractViews'), __('plugins.reports.views.galleyViews')); $galleyLabels = array(); $galleyViews = array(); $galleyViewTotals = array(); $abstractViewCounts = array(); $issueIdentifications = array(); $issueDatesPublished = array(); $articleTitles = array(); $articleIssueIdentificationMap = array(); $firstTime = true; $result = array(); import('classes.db.DBResultRange'); $dbResultRange = new DBResultRange(STATISTICS_MAX_ROWS); $page = 3; $request =& Application::getRequest(); if ($request->getUserVar('metricType') === OJS_METRIC_TYPE_COUNTER) { $metricType = OJS_METRIC_TYPE_COUNTER; } else { $metricType = OJS_METRIC_TYPE_LEGACY_DEFAULT; } while (true) { $dbResultRange->setPage($page); $result = $metricsDao->getMetrics($metricType, array(STATISTICS_DIMENSION_ASSOC_ID), array(STATISTICS_DIMENSION_ASSOC_TYPE => ASSOC_TYPE_ARTICLE, STATISTICS_DIMENSION_CONTEXT_ID => $journal->getId()), array(), $dbResultRange); $page++; foreach ($result as $record) { $articleId = $record[STATISTICS_DIMENSION_ASSOC_ID]; $publishedArticle =& $publishedArticleDao->getPublishedArticleByArticleId($articleId, null, true); if (!is_a($publishedArticle, 'PublishedArticle')) { continue; } $issueId = $publishedArticle->getIssueId(); if (!$issueId) { continue; } $articleTitles[$articleId] = $publishedArticle->getArticleTitle(); // Store the abstract view count, making // sure both metric types will be counted. if (isset($abstractViewCounts[$articleId])) { $abstractViewCounts[$articleId] += $record[STATISTICS_METRIC]; } else { $abstractViewCounts[$articleId] = $record[STATISTICS_METRIC]; } // Make sure we get the issue identification $articleIssueIdentificationMap[$articleId] = $issueId; if (!isset($issueIdentifications[$issueId])) { $issue =& $issueDao->getIssueById($issueId); $issueIdentifications[$issueId] = $issue->getIssueIdentification(); $issueDatesPublished[$issueId] = $issue->getDatePublished(); unset($issue); } // For each galley, store the label and the count $galleysResult =& $metricsDao->getMetrics($metricType, array(STATISTICS_DIMENSION_ASSOC_ID), array(STATISTICS_DIMENSION_ASSOC_TYPE => ASSOC_TYPE_GALLEY, STATISTICS_DIMENSION_SUBMISSION_ID => $articleId)); $galleyViews[$articleId] = array(); $galleyViewTotals[$articleId] = 0; foreach ($galleysResult as $galleyRecord) { $galleyId = $galleyRecord[STATISTICS_DIMENSION_ASSOC_ID]; $galley =& $galleyDao->getGalley($galleyId); $label = $galley->getGalleyLabel(); $i = array_search($label, $galleyLabels); if ($i === false) { $i = count($galleyLabels); $galleyLabels[] = $label; } // Make sure the array is the same size as in previous iterations // so that we insert values into the right location if (count($galleyViews[$articleId]) !== count($galleyLabels)) { $galleyViews[$articleId] = array_pad($galleyViews[$articleId], count($galleyLabels), ''); } $views = $galleyRecord[STATISTICS_METRIC]; // Make sure both metric types will be counted. $galleyViews[$articleId][$i] += $views; $galleyViewTotals[$articleId] += $views; } // Clean up unset($publishedArticle, $galleys); } $firstTime = false; if (count($result) < STATISTICS_MAX_ROWS) { break; } } header('content-type: text/comma-separated-values'); header('content-disposition: attachment; filename=views-' . date('Ymd') . '.csv'); $fp = fopen('php://output', 'wt'); fputcsv($fp, array_merge($columns, $galleyLabels)); ksort($abstractViewCounts); $dateFormatShort = Config::getVar('general', 'date_format_short'); foreach ($abstractViewCounts as $articleId => $abstractViewCount) { $values = array($articleId, $articleTitles[$articleId], $issueIdentifications[$articleIssueIdentificationMap[$articleId]], strftime($dateFormatShort, strtotime($issueDatesPublished[$articleIssueIdentificationMap[$articleId]])), $abstractViewCount, $galleyViewTotals[$articleId]); fputcsv($fp, array_merge($values, $galleyViews[$articleId])); } fclose($fp); }
/** * @see PKPPageRouter::route() * @todo Remove this callback for OJS 3.0. The issue current * operation should redirect to the view operation in core. */ function callbackLoadHandler($hookName, $args) { // Check the page. $page = $args[0]; if ($page !== 'issue') { return; } // Check the operation. $op = $args[1]; if ($op !== 'current') { return; } // Check current issue. $request =& Application::getRequest(); $journal = $request->getJournal(); $issueDao = DAORegistry::getDAO('IssueDAO'); $issue = $issueDao->getCurrent($journal->getId(), true); if (!$issue) { // Let the default current operation work. return false; } // Replace the default Issue handler by ours. define('HANDLER_CLASS', 'UsageStatsHandler'); $handlerFile =& $args[2]; $handlerFile = $this->getPluginPath() . '/' . 'UsageStatsHandler.inc.php'; }
function handleRequest($hookName, $args) { $page =& $args[0]; $op =& $args[1]; $sourceFile =& $args[2]; $request = Application::getRequest(); if ($page !== 'backup') { return false; } // We've already verified that this is a site admin through // conditional hook registration. AppLocale::requireComponents(LOCALE_COMPONENT_PKP_ADMIN, LOCALE_COMPONENT_APPLICATION_COMMON); $returnValue = 0; switch ($op) { case 'index': $templateMgr = TemplateManager::getManager($request); $templateMgr->assign('isDumpConfigured', Config::getVar('cli', 'dump') != ''); $templateMgr->assign('isTarConfigured', Config::getVar('cli', 'tar') != ''); $templateMgr->display($this->getTemplatePath() . 'index.tpl'); exit; case 'db': $dumpTool = Config::getVar('cli', 'dump'); header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename=db-' . strftime('%Y-%m-%d') . '.sql'); header('Content-Type: text/plain'); header('Content-Transfer-Encoding: binary'); passthru(sprintf($dumpTool, escapeshellarg(Config::getVar('database', 'host')), escapeshellarg(Config::getVar('database', 'username')), escapeshellarg(Config::getVar('database', 'password')), escapeshellarg(Config::getVar('database', 'name'))), $returnValue); if ($returnValue !== 0) { $request->redirect(null, null, 'failure'); } exit; case 'files': $tarTool = Config::getVar('cli', 'tar'); header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename=files-' . strftime('%Y-%m-%d') . '.tar.gz'); header('Content-Type: text/plain'); header('Content-Transfer-Encoding: binary'); passthru($tarTool . ' -c -z ' . escapeshellarg(Config::getVar('files', 'files_dir')), $returnValue); if ($returnValue !== 0) { $request->redirect(null, null, 'failure'); } exit; case 'code': $tarTool = Config::getVar('cli', 'tar'); header('Content-Description: File Transfer'); header('Content-Disposition: attachment; filename=code-' . strftime('%Y-%m-%d') . '.tar.gz'); header('Content-Type: text/plain'); header('Content-Transfer-Encoding: binary'); passthru($tarTool . ' -c -z ' . escapeshellarg(dirname(dirname(dirname(dirname(__FILE__))))), $returnValue); if ($returnValue !== 0) { $request->redirect(null, null, 'failure'); } exit; case 'failure': $templateMgr = TemplateManager::getManager($request); $templateMgr->assign('message', 'plugins.generic.backup.failure'); $templateMgr->assign('backLink', $request->url(null, null, 'backup')); $templateMgr->assign('backLinkLabel', 'plugins.generic.backup.link'); $templateMgr->display('common/message.tpl'); exit; } return false; }
/** * RouteManager constructor. * @param Application $app */ function __construct(Application $app) { $this->app = $app; $this->routes = $app->getRoutes(); $this->incoming_url = $app->getRequest()->getPathInfo(); }
/** * Get the journal object. * @param $journalId integer * @return Journal */ function &_getJournal($journalId) { assert(is_numeric($journalId)); // Get the journal object from the context (optimized). $request =& Application::getRequest(); $router =& $request->getRouter(); $journal =& $router->getContext($request); /* @var $journal Journal */ // Check whether we still have to retrieve the journal from the database. if (!$journal || $journal->getId() != $journalId) { unset($journal); $journalDao =& DAORegistry::getDAO('JournalDAO'); $journal =& $journalDao->getById($journalId); } return $journal; }
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]; }
function initialize() { // This code cannot be called in the constructor because of // reference problems, i.e. callers that need getManager fail. // Load the block plugins. $plugins =& PluginRegistry::loadCategory('blocks'); if (!defined('SESSION_DISABLE_INIT')) { $request =& Application::getRequest(); $user =& $request->getUser(); $hasSystemNotifications = false; if ($user) { // Assign the user name to be used in the sitenav $this->assign('loggedInUsername', $user->getUserName()); $notificationDao =& DAORegistry::getDAO('NotificationDAO'); $notifications =& $notificationDao->getByUserId($user->getId(), NOTIFICATION_LEVEL_TRIVIAL); if ($notifications->getCount() > 0) { $hasSystemNotifications = true; } $this->assign('initialHelpState', (int) $user->getInlineHelp()); } $this->assign('hasSystemNotifications', $hasSystemNotifications); } $this->initialized = true; }
/** * Generate doi_data element - this is what assigns the DOI * @param $doc XMLNode * @param $DOI string * @param $url string * @param $galleys array */ function &_generateDOIdataDom(&$doc, $DOI, $url, $galleys = null) { $request = Application::getRequest(); $journal = $request->getJournal(); $DOIdataNode =& XMLCustomWriter::createElement($doc, 'doi_data'); XMLCustomWriter::createChildWithText($doc, $DOIdataNode, 'doi', $DOI); XMLCustomWriter::createChildWithText($doc, $DOIdataNode, 'resource', $url); /* article galleys */ if ($galleys) { $collectionNode = XMLCustomWriter::createElement($doc, 'collection'); XMLCustomWriter::setAttribute($collectionNode, 'property', 'text-mining'); XMLCustomWriter::appendChild($DOIdataNode, $collectionNode); foreach ($galleys as $galley) { $itemNode = XMLCustomWriter::createElement($doc, 'item'); XMLCustomWriter::appendChild($collectionNode, $itemNode); $resourceNode = XMLCustomWriter::createElement($doc, 'resource'); XMLCustomWriter::appendChild($itemNode, $resourceNode); XMLCustomWriter::setAttribute($resourceNode, 'mime_type', $galley->getFileType()); $urlNode = XMLCustomWriter::createTextNode($doc, $request->url(null, 'article', 'viewFile', array($galley->getArticleId(), $galley->getBestGalleyId($journal)))); XMLCustomWriter::appendChild($resourceNode, $urlNode); } } return $DOIdataNode; }
/** * Create and return an issue node, either as work or as manifestation. * @param $doc DOMDocument * @param $pubObject Issue * @return DOMElement */ function createIssueNode($doc, $pubObject) { $deployment = $this->getDeployment(); $context = $deployment->getContext(); $cache = $deployment->getCache(); $plugin = $deployment->getPlugin(); $request = Application::getRequest(); $router = $request->getRouter(); $issueNodeName = $this->isWork($context, $plugin) ? 'DOISerialIssueWork' : 'DOISerialIssueVersion'; $issueNode = $doc->createElementNS($deployment->getNamespace(), $issueNodeName); // Notification type (mandatory) $doi = $pubObject->getStoredPubId('doi'); $registeredDoi = $pubObject->getData('medra::registeredDoi'); assert(empty($registeredDoi) || $registeredDoi == $doi); $notificationType = empty($registeredDoi) ? O4DOI_NOTIFICATION_TYPE_NEW : O4DOI_NOTIFICATION_TYPE_UPDATE; $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'NotificationType', $notificationType)); // DOI (mandatory) $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'DOI', htmlspecialchars($doi, ENT_COMPAT, 'UTF-8'))); // DOI URL (mandatory) $url = $router->url($request, $context->getPath(), 'article', 'view', $pubObject->getBestIssueId(), null, null, true); if ($plugin->isTestMode($context)) { // Change server domain for testing. $url = PKPString::regexp_replace('#://[^\\s]+/index.php#', '://example.com/index.php', $url); } $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'DOIWebsiteLink', $url)); // DOI strucural type $structuralType = $this->isWork($context, $plugin) ? 'Abstraction' : 'DigitalFixation'; $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'DOIStructuralType', $structuralType)); // Registrant (mandatory) $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'RegistrantName', htmlspecialchars($plugin->getSetting($context->getId(), 'registrantName'), ENT_COMPAT, 'UTF-8'))); // Registration authority (mandatory) $issueNode->appendChild($node = $doc->createElementNS($deployment->getNamespace(), 'RegistrationAuthority', 'mEDRA')); // Work/ProductIdentifier - proprietary ID $pubObjectProprietaryId = $context->getId() . '-' . $pubObject->getId(); $workOrProduct = $this->isWork($context, $plugin) ? 'Work' : 'Product'; $issueNode->appendChild($this->createIdentifierNode($doc, $workOrProduct, O4DOI_ID_TYPE_PROPRIETARY, $pubObjectProprietaryId)); // Issue/journal and object locale precedence. $journalLocalePrecedence = $objectLocalePrecedence = $this->getObjectLocalePrecedence($context, null, null); // Serial Publication (mandatory) $issueNode->appendChild($this->createSerialPublicationNode($doc, $journalLocalePrecedence, O4DOI_EPUB_FORMAT_HTML)); // Journal Issue (mandatory) $issueId = $pubObject->getId(); if (!$cache->isCached('issues', $issueId)) { $cache->add($pubObject, null); } $issueNode->appendChild($this->createJournalIssueNode($doc, $pubObject, $journalLocalePrecedence)); // Object Description 'OtherText' $descriptions = $this->getTranslationsByPrecedence($pubObject->getDescription(null), $objectLocalePrecedence); foreach ($descriptions as $locale => $description) { $issueNode->appendChild($this->createOtherTextNode($doc, $locale, $description)); } // 4) issue (as-work and as-manifestation): // related works: // - includes articles-as-work $articleDao = DAORegistry::getDAO('PublishedArticleDAO'); /* @var $articleDao PublishedArticleDAO */ $articlesByIssue = $articleDao->getPublishedArticles($issueId); $galleyDao = DAORegistry::getDAO('ArticleGalleyDAO'); /* @var $galleyDao ArticleGalleyDAO */ $galleysByIssue = array(); foreach ($articlesByIssue as $relatedArticle) { $articleProprietaryId = $context->getId() . '-' . $pubObject->getId() . '-' . $relatedArticle->getId(); $relatedArticleIds = array(O4DOI_ID_TYPE_PROPRIETARY => $articleProprietaryId); $doi = $relatedArticle->getStoredPubId('doi'); if (!empty($doi)) { $relatedArticleIds[O4DOI_ID_TYPE_DOI] = $doi; } $issueNode->appendChild($this->createRelatedNode($doc, 'Work', O4DOI_RELATION_INCLUDES, $relatedArticleIds)); // Collect galleys by issue $galleysByArticle = $galleyDao->getBySubmissionId($relatedArticle->getId())->toArray(); $galleysByIssue = array_merge($galleysByIssue, $galleysByArticle); unset($relatedArticle, $relatedArticleIds); } // related products: // - includes articles-as-manifestation foreach ($galleysByIssue as $relatedGalley) { $galleyProprietaryId = $context->getId() . '-' . $pubObject->getId() . '-' . $relatedGalley->getSubmissionId() . '-g' . $relatedGalley->getId(); $relatedGalleyIds = array(O4DOI_ID_TYPE_PROPRIETARY => $galleyProprietaryId); $doi = $relatedGalley->getStoredPubId('doi'); if (!empty($doi)) { $relatedGalleyIds[O4DOI_ID_TYPE_DOI] = $doi; } $issueNode->appendChild($this->createRelatedNode($doc, 'Product', O4DOI_RELATION_INCLUDES, $relatedGalleyIds)); unset($relatedGalley, $relatedGalleyIds); } return $issueNode; }