/** * @copydoc PKPUsageEventPlugin::getUSageEventData() */ protected function getUsageEventData($hookName, $hookArgs, $request, $router, $templateMgr, $context) { list($pubObject, $downloadSuccess, $assocType, $idParams, $canonicalUrlPage, $canonicalUrlOp, $canonicalUrlParams) = parent::getUsageEventData($hookName, $hookArgs, $request, $router, $templateMgr, $context); if (!$pubObject) { switch ($hookName) { // Press index page, issue content page and article abstract. case 'TemplateManager::display': $page = $router->getRequestedPage($request); $op = $router->getRequestedOp($request); $args = $router->getRequestedArgs($request); $wantedPages = array('issue', 'article'); $wantedOps = array('index', 'view'); if (!in_array($page, $wantedPages) || !in_array($op, $wantedOps)) { break; } // View requests with 1 argument might relate to journal // or article. With more than 1 is related with other objects // that we are not interested in or that are counted using a // different hook. if ($op == 'view' && count($args) > 1) { break; } $journal = $templateMgr->get_template_vars('currentContext'); $issue = $templateMgr->get_template_vars('issue'); $publishedArticle = $templateMgr->get_template_vars('publishedArticle'); // No published objects, no usage event. if (!$journal && !$issue && !$publishedArticle) { break; } if ($journal) { $pubObject = $journal; $assocType = ASSOC_TYPE_JOURNAL; $canonicalUrlOp = ''; } if ($issue) { $pubObject = $issue; $assocType = ASSOC_TYPE_ISSUE; $canonicalUrlParams = array($issue->getId()); $idParams = array('s' . $issue->getId()); } if ($publishedArticle) { $pubObject = $publishedArticle; $assocType = ASSOC_TYPE_ARTICLE; $canonicalUrlParams = array($pubObject->getId()); $idParams = array('m' . $pubObject->getId()); } $downloadSuccess = true; $canonicalUrlOp = $op; break; // Issue galley. // Issue galley. case 'IssueHandler::download': $assocType = ASSOC_TYPE_ISSUE_GALLEY; $issue = $hookArgs[0]; $galley = $hookArgs[1]; $canonicalUrlOp = 'download'; $canonicalUrlParams = array($issue->getId(), $galley->getId()); $idParams = array('i' . $issue->getId(), 'f' . $galley->getId()); $downloadSuccess = false; $pubObject = $galley; break; // Article file. // Article file. case 'ArticleHandler::download': $assocType = ASSOC_TYPE_SUBMISSION_FILE; $article = $hookArgs[0]; $galley = $hookArgs[1]; $fileId = $hookArgs[2]; $canonicalUrlOp = 'download'; $canonicalUrlParams = array($article->getId(), $galley->getId(), $fileId); $idParams = array('a' . $article->getId(), 'g' . $galley->getId(), 'f' . $fileId); $downloadSuccess = false; $submissionFileDao = DAORegistry::getDAO('SubmissionFileDAO'); $pubObject = $submissionFileDao->getLatestRevision($fileId); break; default: // Why are we called from an unknown hook? assert(false); } } return array($pubObject, $downloadSuccess, $assocType, $idParams, $canonicalUrlPage, $canonicalUrlOp, $canonicalUrlParams); }
/** * @see PKPUsageEventPlugin::getUsageEventData() */ protected function getUsageEventData($hookName, $hookArgs, $request, $router, $templateMgr, $context) { list($pubObject, $downloadSuccess, $assocType, $idParams, $canonicalUrlPage, $canonicalUrlOp, $canonicalUrlParams) = parent::getUsageEventData($hookName, $hookArgs, $request, $router, $templateMgr, $context); if (!$pubObject) { switch ($hookName) { // Press index page, series content page and monograph abstract. case 'TemplateManager::display': $page = $router->getRequestedPage($request); $op = $router->getRequestedOp($request); $wantedPages = array('catalog'); $wantedOps = array('index', 'book', 'series'); if (!in_array($page, $wantedPages) || !in_array($op, $wantedOps)) { break; } $press = $templateMgr->get_template_vars('currentContext'); /* @var $press Press */ $series = $templateMgr->get_template_vars('series'); /* @var $series Series */ $publishedMonograph = $templateMgr->get_template_vars('publishedMonograph'); // No published objects, no usage event. if (!$press && !$series && !$publishedMonograph) { break; } if ($press) { $pubObject = $press; $assocType = ASSOC_TYPE_PRESS; $canonicalUrlOp = ''; } if ($series) { $pubObject = $series; $assocType = ASSOC_TYPE_SERIES; $canonicalUrlParams = array($series->getPath()); $idParams = array('s' . $series->getId()); } if ($publishedMonograph) { $pubObject = $publishedMonograph; $assocType = ASSOC_TYPE_MONOGRAPH; $canonicalUrlParams = array($pubObject->getId()); $idParams = array('m' . $pubObject->getId()); } $downloadSuccess = true; $canonicalUrlOp = $op; break; // Publication format file. // Publication format file. case 'CatalogBookHandler::view': case 'CatalogBookHandler::download': $pubObject = $hookArgs[3]; $assocType = ASSOC_TYPE_SUBMISSION_FILE; $canonicalUrlOp = 'download'; $publishedMonograph = $hookArgs[1]; $canonicalUrlParams = array($publishedMonograph->getId(), $pubObject->getAssocId(), $pubObject->getFileId() . '-' . $pubObject->getRevision()); $idParams = array('m' . $publishedMonograph->getId(), 'f' . $pubObject->getId()); $downloadSuccess = false; break; default: // Why are we called from an unknown hook? assert(false); } } switch ($assocType) { case ASSOC_TYPE_PRESS: case ASSOC_TYPE_SERIES: case ASSOC_TYPE_MONOGRAPH: case ASSOC_TYPE_SUBMISSION_FILE: $canonicalUrlPage = 'catalog'; break; } return array($pubObject, $downloadSuccess, $assocType, $idParams, $canonicalUrlPage, $canonicalUrlOp, $canonicalUrlParams); }