00001 <?php
00002
00015
00016
00017
00018 import('rt.RT');
00019
00020 import('rt.ojs.RTDAO');
00021 import('rt.ojs.JournalRT');
00022
00023 import('article.ArticleHandler');
00024
00025 class RTHandler extends ArticleHandler {
00029 function bio($args) {
00030 $articleId = isset($args[0]) ? $args[0] : 0;
00031 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00032 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00033
00034 $rtDao = &DAORegistry::getDAO('RTDAO');
00035 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00036
00037 if (!$journalRt || !$journalRt->getAuthorBio()) {
00038 Request::redirect(null, Request::getRequestedPage());
00039 }
00040
00041 $templateMgr = &TemplateManager::getManager();
00042 $templateMgr->assign('articleId', $articleId);
00043 $templateMgr->assign_by_ref('article', $article);
00044 $templateMgr->assign('galleyId', $galleyId);
00045 $templateMgr->display('rt/bio.tpl');
00046 }
00047
00051 function metadata($args) {
00052 $articleId = isset($args[0]) ? $args[0] : 0;
00053 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00054 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00055
00056 $rtDao = &DAORegistry::getDAO('RTDAO');
00057 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00058
00059 if (!$journalRt || !$journalRt->getViewMetadata()) {
00060 Request::redirect(null, Request::getRequestedPage());
00061 }
00062
00063 $sectionDao = &DAORegistry::getDAO('SectionDAO');
00064 $section = &$sectionDao->getSection($article->getSectionId());
00065
00066 $templateMgr = &TemplateManager::getManager();
00067 $templateMgr->assign('articleId', $articleId);
00068 $templateMgr->assign('galleyId', $galleyId);
00069 $templateMgr->assign_by_ref('journalRt', $journalRt);
00070 $templateMgr->assign_by_ref('article', $article);
00071 $templateMgr->assign_by_ref('issue', $issue);
00072 $templateMgr->assign_by_ref('section', $section);
00073 $templateMgr->assign_by_ref('journalSettings', $journal->getSettings());
00074 $templateMgr->display('rt/metadata.tpl');
00075 }
00076
00080 function context($args) {
00081 $articleId = isset($args[0]) ? $args[0] : 0;
00082 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00083 $contextId = Isset($args[2]) ? (int) $args[2] : 0;
00084
00085 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00086
00087 $rtDao = &DAORegistry::getDAO('RTDAO');
00088 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00089
00090 $context = &$rtDao->getContext($contextId);
00091 if ($context) $version = &$rtDao->getVersion($context->getVersionId(), $journal->getJournalId());
00092
00093 if (!$context || !$version || !$journalRt || $journalRt->getVersion()==null || $journalRt->getVersion() != $context->getVersionId()) {
00094 Request::redirect(null, 'article', 'view', array($articleId, $galleyId));
00095 }
00096
00097
00098
00099
00100 $searches = array();
00101
00102
00103
00104
00105 $searchParams = array();
00106 foreach ($context->getSearches() as $search) {
00107 $params = array();
00108 $searchParams += RTHandler::getParameterNames($search->getSearchUrl());
00109 if ($search->getSearchPost()) {
00110 $searchParams += RTHandler::getParameterNames($search->getSearchPost());
00111 $postParams = explode('&', $search->getSearchPost());
00112 foreach ($postParams as $param) {
00113
00114 $nameValue = explode('=', $param);
00115 if (!isset($nameValue[0])) break;
00116
00117 $name = $nameValue[0];
00118 $value = trim(isset($nameValue[1])?$nameValue[1]:'');
00119 if (!empty($name)) $params[] = array('name' => $name, 'value' => $value);
00120 }
00121 }
00122
00123 $search->postParams = $params;
00124 $searches[] = $search;
00125 }
00126
00127
00128 $searchParams = array_unique($searchParams);
00129 $searchValues = array();
00130
00131 foreach ($searchParams as $key => $param) switch ($param) {
00132 case 'author':
00133 $searchValues[$param] = $article->getAuthorString();
00134 break;
00135 case 'coverageGeo':
00136 $searchValues[$param] = $article->getArticleCoverageGeo();
00137 break;
00138 case 'title':
00139 $searchValues[$param] = $article->getArticleTitle();
00140 break;
00141 default:
00142
00143 unset($searchParams[$key]);
00144 break;
00145 }
00146
00147 $templateMgr = &TemplateManager::getManager();
00148 $templateMgr->assign('articleId', $articleId);
00149 $templateMgr->assign('galleyId', $galleyId);
00150 $templateMgr->assign_by_ref('article', $article);
00151 $templateMgr->assign_by_ref('version', $version);
00152 $templateMgr->assign_by_ref('context', $context);
00153 $templateMgr->assign_by_ref('searches', $searches);
00154 $templateMgr->assign('searchParams', $searchParams);
00155 $templateMgr->assign('searchValues', $searchValues);
00156 $templateMgr->assign('defineTerm', Request::getUserVar('defineTerm'));
00157 $templateMgr->assign('keywords', explode(';', $article->getArticleSubject()));
00158 $templateMgr->assign('coverageGeo', $article->getArticleCoverageGeo());
00159 $templateMgr->assign_by_ref('journalSettings', $journal->getSettings());
00160 $templateMgr->display('rt/context.tpl');
00161 }
00162
00166 function captureCite($args) {
00167 $articleId = isset($args[0]) ? $args[0] : 0;
00168 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00169 $citeType = isset($args[2]) ? $args[2] : null;
00170
00171 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00172
00173 $rtDao = &DAORegistry::getDAO('RTDAO');
00174 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00175
00176 if (!$journalRt || !$journalRt->getCaptureCite()) {
00177 Request::redirect(null, Request::getRequestedPage());
00178 }
00179
00180 $templateMgr = &TemplateManager::getManager();
00181 $templateMgr->assign('articleId', $articleId);
00182 $templateMgr->assign('galleyId', $galleyId);
00183 $templateMgr->assign_by_ref('journalRt', $journalRt);
00184 $templateMgr->assign_by_ref('journal', $journal);
00185 $templateMgr->assign_by_ref('issue', $issue);
00186 $templateMgr->assign_by_ref('article', $article);
00187
00188 $templateMgr->assign_by_ref('journalSettings', $journal->getSettings());
00189
00190 $citationPlugins =& PluginRegistry::loadCategory('citationFormats');
00191 uasort($citationPlugins, create_function('$a, $b', 'return strcmp($a->getDisplayName(), $b->getDisplayName());'));
00192 $templateMgr->assign_by_ref('citationPlugins', $citationPlugins);
00193 if (isset($citationPlugins[$citeType])) {
00194
00195 $citationPlugin =& $citationPlugins[$citeType];
00196 } else {
00197
00198 $citationPlugin = $citationPlugins[array_shift(array_keys($citationPlugins))];
00199 }
00200 $citationPlugin->cite($article, $issue);
00201 }
00202
00206 function printerFriendly($args) {
00207 $articleId = isset($args[0]) ? $args[0] : 0;
00208 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00209 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00210
00211 $rtDao = &DAORegistry::getDAO('RTDAO');
00212 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00213
00214 if (!$journalRt || !$journalRt->getPrinterFriendly()) {
00215 Request::redirect(null, Request::getRequestedPage());
00216 }
00217
00218 $articleGalleyDao = &DAORegistry::getDAO('ArticleGalleyDAO');
00219 $galley = &$articleGalleyDao->getGalley($galleyId, $article->getArticleId());
00220
00221 $sectionDao = &DAORegistry::getDAO('SectionDAO');
00222 $section = &$sectionDao->getSection($article->getSectionId());
00223
00224 $templateMgr = &TemplateManager::getManager();
00225 $templateMgr->assign_by_ref('galley', $galley);
00226 $templateMgr->assign_by_ref('article', $article);
00227 $templateMgr->assign_by_ref('section', $section);
00228 $templateMgr->assign_by_ref('issue', $issue);
00229 $templateMgr->assign_by_ref('journal', $journal);
00230 $templateMgr->assign('articleId', $articleId);
00231 $templateMgr->assign('galleyId', $galleyId);
00232
00233
00234 if ($galley && $galley->isHTMLGalley() && $styleFile =& $galley->getStyleFile()) {
00235 $templateMgr->addStyleSheet(Request::url(null, 'article', 'viewFile', array(
00236 $article->getArticleId(),
00237 $galley->getBestGalleyId($journal),
00238 $styleFile->getFileId()
00239 )));
00240 }
00241
00242 $templateMgr->display('rt/printerFriendly.tpl');
00243 }
00244
00248 function emailColleague($args) {
00249 $articleId = isset($args[0]) ? $args[0] : 0;
00250 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00251
00252 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00253
00254 $rtDao = &DAORegistry::getDAO('RTDAO');
00255 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00256 $user = &Request::getUser();
00257
00258 if (!$journalRt || !$journalRt->getEmailOthers() || !$user) {
00259 Request::redirect(null, Request::getRequestedPage());
00260 }
00261
00262 import('mail.MailTemplate');
00263 $email = &new MailTemplate('EMAIL_LINK');
00264
00265 if (Request::getUserVar('send') && !$email->hasErrors()) {
00266 $email->send();
00267
00268 $templateMgr = &TemplateManager::getManager();
00269 $templateMgr->display('rt/sent.tpl');
00270 } else {
00271 if (!Request::getUserVar('continued')) {
00272 $primaryAuthor = $article->getAuthors();
00273 $primaryAuthor = $primaryAuthor[0];
00274
00275 $email->setSubject('[' . $journal->getLocalizedSetting('initials') . '] ' . strip_tags($article->getArticleTitle()));
00276 $email->assignParams(array(
00277 'articleTitle' => strip_tags($article->getArticleTitle()),
00278 'volume' => $issue?$issue->getVolume():null,
00279 'number' => $issue?$issue->getNumber():null,
00280 'year' => $issue?$issue->getYear():null,
00281 'authorName' => $primaryAuthor->getFullName(),
00282 'articleUrl' => Request::url(null, 'article', 'view', $article->getBestArticleId())
00283 ));
00284 }
00285 $email->displayEditForm(Request::url(null, null, 'emailColleague', array($articleId, $galleyId)), null, 'rt/email.tpl', array('op' => 'emailColleague'));
00286 }
00287 }
00288
00292 function emailAuthor($args) {
00293 $articleId = isset($args[0]) ? $args[0] : 0;
00294 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00295
00296 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00297
00298 $rtDao = &DAORegistry::getDAO('RTDAO');
00299 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00300 $user = &Request::getUser();
00301
00302 if (!$journalRt || !$journalRt->getEmailAuthor() || !$user) {
00303 Request::redirect(null, Request::getRequestedPage());
00304 }
00305
00306 import('mail.MailTemplate');
00307 $email = &new MailTemplate();
00308 $email->setAddressFieldsEnabled(false);
00309
00310 if (Request::getUserVar('send') && !$email->hasErrors()) {
00311 $authors = &$article->getAuthors();
00312 $author = &$authors[0];
00313 $email->addRecipient($author->getEmail(), $author->getFullName());
00314
00315 $email->send();
00316
00317 $templateMgr = &TemplateManager::getManager();
00318 $templateMgr->display('rt/sent.tpl');
00319 } else {
00320 if (!Request::getUserVar('continued')) {
00321 $email->setSubject('[' . $journal->getLocalizedSetting('initials') . '] ' . strip_tags($article->getArticleTitle()));
00322 }
00323 $email->displayEditForm(Request::url(null, null, 'emailAuthor', array($articleId, $galleyId)), null, 'rt/email.tpl', array('op' => 'emailAuthor'));
00324 }
00325 }
00326
00330 function suppFiles($args) {
00331 $articleId = isset($args[0]) ? $args[0] : 0;
00332 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00333 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00334
00335 $rtDao = &DAORegistry::getDAO('RTDAO');
00336 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00337
00338 if (!$journalRt || !$journalRt->getSupplementaryFiles()) {
00339 Request::redirect(null, Request::getRequestedPage());
00340 }
00341
00342 $templateMgr = &TemplateManager::getManager();
00343 $templateMgr->assign('articleId', $articleId);
00344 $templateMgr->assign('galleyId', $galleyId);
00345 $templateMgr->assign_by_ref('journalRt', $journalRt);
00346 $templateMgr->assign_by_ref('article', $article);
00347 $templateMgr->assign_by_ref('journalSettings', $journal->getSettings());
00348 $templateMgr->display('rt/suppFiles.tpl');
00349 }
00350
00354 function suppFileMetadata($args) {
00355 $articleId = isset($args[0]) ? $args[0] : 0;
00356 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00357 $suppFileId = isset($args[2]) ? (int) $args[2] : 0;
00358 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00359
00360 $rtDao = &DAORegistry::getDAO('RTDAO');
00361 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00362
00363 $suppFileDao = &DAORegistry::getDAO('SuppFileDAO');
00364 $suppFile = $suppFileDao->getSuppFile($suppFileId, $article->getArticleId());
00365
00366 if (!$journalRt || !$journalRt->getSupplementaryFiles() || !$suppFile) {
00367 Request::redirect(null, Request::getRequestedPage());
00368 }
00369
00370 $templateMgr = &TemplateManager::getManager();
00371 $templateMgr->assign('articleId', $articleId);
00372 $templateMgr->assign('galleyId', $galleyId);
00373 $templateMgr->assign_by_ref('suppFile', $suppFile);
00374 $templateMgr->assign_by_ref('journalRt', $journalRt);
00375 $templateMgr->assign_by_ref('article', $article);
00376 $templateMgr->assign_by_ref('journalSettings', $journal->getSettings());
00377 $templateMgr->display('rt/suppFileView.tpl');
00378 }
00379
00383 function findingReferences($args) {
00384 $articleId = isset($args[0]) ? $args[0] : 0;
00385 $galleyId = isset($args[1]) ? (int) $args[1] : 0;
00386 list($journal, $issue, $article) = RTHandler::validate($articleId, $galleyId);
00387
00388 $rtDao = &DAORegistry::getDAO('RTDAO');
00389 $journalRt = &$rtDao->getJournalRTByJournal($journal);
00390
00391 if (!$journalRt || !$journalRt->getFindingReferences()) {
00392 Request::redirect(null, Request::getRequestedPage());
00393 }
00394
00395 $templateMgr = &TemplateManager::getManager();
00396 $templateMgr->assign('articleId', $articleId);
00397 $templateMgr->assign('galleyId', $galleyId);
00398 $templateMgr->assign_by_ref('journalRt', $journalRt);
00399 $templateMgr->assign_by_ref('article', $article);
00400 $templateMgr->display('rt/findingReferences.tpl');
00401 }
00402
00406 function getParameterNames($value) {
00407 $matches = null;
00408 String::regexp_match_all('/\{\$([a-zA-Z0-9]+)\}/', $value, $matches);
00409
00410 return $matches[1];
00411 }
00412 }
00413
00414 ?>