00001 <?php
00002
00015
00016
00017
00018 import('classes.plugins.ReportPlugin');
00019
00020 class ArticleReportPlugin extends ReportPlugin {
00027 function register($category, $path) {
00028 $success = parent::register($category, $path);
00029 if ($success) {
00030 $this->import('ArticleReportDAO');
00031 $articleReportDAO =& new ArticleReportDAO();
00032 DAORegistry::registerDAO('ArticleReportDAO', $articleReportDAO);
00033 }
00034 $this->addLocaleData();
00035 return $success;
00036 }
00037
00043 function getName() {
00044 return 'ArticleReportPlugin';
00045 }
00046
00047 function getDisplayName() {
00048 return Locale::translate('plugins.reports.articles.displayName');
00049 }
00050
00051 function getDescription() {
00052 return Locale::translate('plugins.reports.articles.description');
00053 }
00054
00055 function display(&$args) {
00056 $journal =& Request::getJournal();
00057
00058 header('content-type: text/comma-separated-values');
00059 header('content-disposition: attachment; filename=report.csv');
00060
00061 $articleReportDao =& DAORegistry::getDAO('ArticleReportDAO');
00062 list($articlesIterator, $decisionsIteratorsArray) = $articleReportDao->getArticleReport($journal->getJournalId());
00063
00064 $decisions = array();
00065 foreach ($decisionsIteratorsArray as $decisionsIterator){
00066 while ($row =& $decisionsIterator->next()) {
00067 $decisions[$row['article_id']] = $row['decision'];
00068 }
00069 }
00070
00071 import('classes.article.Article');
00072 $decisionMessages = array(
00073 SUBMISSION_EDITOR_DECISION_ACCEPT => Locale::translate('editor.article.decision.accept'),
00074 SUBMISSION_EDITOR_DECISION_PENDING_REVISIONS => Locale::translate('editor.article.decision.pendingRevisions'),
00075 SUBMISSION_EDITOR_DECISION_RESUBMIT => Locale::translate('editor.article.decision.resubmit'),
00076 SUBMISSION_EDITOR_DECISION_DECLINE => Locale::translate('editor.article.decision.decline'),
00077 null => Locale::translate('plugins.reports.articles.nodecision')
00078 );
00079
00080 $columns = array(
00081 'article_id' => Locale::translate('article.submissionId'),
00082 'title' => Locale::translate('article.title'),
00083 'abstract' => Locale::translate('article.abstract'),
00084 'fname' => Locale::translate('user.firstName'),
00085 'mname' => Locale::translate('user.middleName'),
00086 'lname' => Locale::translate('user.lastName'),
00087 'phone' => Locale::translate('user.phone'),
00088 'fax' => Locale::translate('user.fax'),
00089 'address' => Locale::translate('common.mailingAddress'),
00090 'country' => Locale::translate('common.country'),
00091 'affiliation' => Locale::translate('user.affiliation'),
00092 'email' => Locale::translate('user.email'),
00093 'url' => Locale::translate('user.url'),
00094 'biography' => Locale::translate('user.biography'),
00095 'section_title' => Locale::translate('section.title'),
00096 'language' => Locale::translate('common.language'),
00097 'status' => Locale::translate('common.status')
00098 );
00099
00100 $fp = fopen('php://output', 'wt');
00101 String::fputcsv($fp, array_values($columns));
00102
00103 while ($row =& $articlesIterator->next()) {
00104 foreach ($columns as $index => $junk) {
00105 if ( $index == "article_id" ){
00106 $columns[$index] = $row[$index];
00107 if (isset($decisions[$row[$index]])) {
00108 $columns['status'] = $decisionMessages[$decisions[$row[$index]]];
00109 } else {
00110 $columns['status'] = $decisionMessages[NULL];
00111 }
00112 } else if ($index == "status") {
00113 continue;
00114 } else {
00115 $columns[$index] = $row[$index];
00116 }
00117 }
00118 String::fputcsv($fp, $columns);
00119 unset($row);
00120 }
00121
00122 fclose($fp);
00123 }
00124 }
00125
00126 ?>