/** * @see PKPUsageStatsLoader::getAssoc() */ protected function getAssoc($assocType, $contextPaths, $page, $op, $args) { list($assocTypeToReturn, $assocId) = parent::getAssoc($assocType, $contextPaths, $page, $op, $args); if (!$assocId && !$assocTypeToReturn) { switch ($assocType) { case ASSOC_TYPE_SUBMISSION_FILE: if (!isset($args[0])) { break; } $submissionId = $args[0]; $submissionDao = DAORegistry::getDAO('MonographDAO'); $monograph = $submissionDao->getById($submissionId); if (!$monograph) { break; } if (!isset($args[2])) { break; } $fileIdAndRevision = $args[2]; list($fileId, $revision) = array_map(create_function('$a', 'return (int) $a;'), preg_split('/-/', $fileIdAndRevision)); $monographFileDao = DAORegistry::getDAO('SubmissionFileDAO'); /* @var $monographFileDao SubmissionFileDAO */ $monographFile = $monographFileDao->getRevision($fileId, $revision); if ($monographFile) { $assocId = $monographFile->getFileId(); } $assocTypeToReturn = $assocType; break; case ASSOC_TYPE_SERIES: if (!isset($args[0])) { break; } $seriesPath = $args[0]; $seriesDao = Application::getSectionDAO(); /* @var $seriesDao SeriesDAO */ if (isset($this->_contextsByPath[current($contextPaths)])) { $context = $this->_contextsByPath[current($contextPaths)]; $series = $seriesDao->getByPath($seriesPath, $context->getId()); if ($series) { $assocId = $series->getId(); } } break; } } return array($assocId, $assocType); }
/** * @copydoc PKPUsageStatsLoader::getFileType() */ protected function getFileTypeFromAssoc($assocType, $assocId) { $type = parent::getFileTypeFromAssoc($assocType, $assocId); if (!$type) { switch ($assocType) { case ASSOC_TYPE_ISSUE_GALLEY: $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO'); $issueGalley = $issueGalleyDao->getById($assocId); $type = $this->getFileTypeFromFile($issueGalley); break; } } return $type; }
/** * @see PKPUsageStatsLoader::getAssoc() */ protected function getAssoc($assocType, $contextPaths, $page, $op, $args) { list($assocTypeToReturn, $assocId) = parent::getAssoc($assocType, $contextPaths, $page, $op, $args); if (!$assocId && !$assocTypeToReturn) { switch ($assocType) { case ASSOC_TYPE_SUBMISSION_FILE: if (!isset($args[0])) { break; } $submissionId = $args[0]; $submissionDao = DAORegistry::getDAO('ArticleDAO'); $article = $submissionDao->getById($submissionId); if (!$article) { break; } if (!isset($args[2])) { break; } $fileIdAndRevision = $args[2]; list($fileId, $revision) = array_map(create_function('$a', 'return (int) $a;'), preg_split('/-/', $fileIdAndRevision)); $articleFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $articleFile = $articleFileDao->getRevision($fileId, $revision); if ($articleFile) { $assocId = $articleFile->getFileId(); } $assocTypeToReturn = $assocType; break; case ASSOC_TYPE_ISSUE: case ASSOC_TYPE_ISSUE_GALLEY: if (!isset($args[0])) { break; } $issueId = $args[0]; $issueDao = DAORegistry::getDAO('IssueDAO'); if (isset($this->_contextsByPath[current($contextPaths)])) { $context = $this->_contextsByPath[current($contextPaths)]; $issue = $issueDao->getById($issueId, $context->getId()); if ($issue) { $assocId = $issue->getId(); } else { break; } } else { break; } $assocTypeToReturn = $assocType; // Allows next case. // Allows next case. case ASSOC_TYPE_ISSUE_GALLEY: if (!isset($issue) || !isset($args[1])) { break; } $issueGalleyId = $args[1]; $issueGalleyDao = DAORegistry::getDAO('IssueGalleyDAO'); $issueGalley = $issueGalleyDao->getById($issueGalleyId, $issue->getId()); if ($issueGalley) { $assocId = $issueGalley->getId(); } else { // Make sure we clean up values from the above case. $assocId = $assocTypeToReturn = null; } break; } } return array($assocId, $assocTypeToReturn); }