コード例 #1
0
 /**
  * Show the list of papers wit their status
  */
 function paperstatusAction()
 {
     $paperTbl = new Paper();
     $paperStatusTbl = new PaperStatus();
     $exportLatex = $exportExcel = false;
     if (isset($_REQUEST['export_latex'])) {
         $exportLatex = true;
         $this->view->message = "The LaTeX file <i>paperstatus.tex</i> has been generated in files/selection";
     }
     if (isset($_REQUEST['export_excel'])) {
         $exportExcel = true;
         $this->view->message = "The LaTeX file <i>paperstatus.tex</i> has been generated in files/selection";
     } else {
         $this->view->MESSAGE = "";
     }
     if (!$exportExcel) {
         $this->view->set_file("content", "paperstatus.xml");
         $this->view->set_block("content", "SELECTION_FORM");
         $this->view->set_block("content", "MESSAGE");
         $this->view->set_block("content", "SHOW_SELECTION_FORM");
         $this->view->set_file("ranked_papers_list", "ranked_papers.xml");
     } else {
         $this->view->set_file("ranked_papers_list", "paperstatus_excel.xml");
     }
     // Check whether the current selection must be changed
     if (isset($_POST['spStatus'])) {
         $this->config->changeCurrentSelection();
     }
     if (isset($_REQUEST['remove'])) {
         $reviewTbl = new Review();
         $review = $reviewTbl->find($_REQUEST['idPaper'], $_REQUEST['remove'])->current();
         if (is_object($review)) {
             $review->delete();
         }
     } else {
         if (isset($_REQUEST['idPaper'])) {
             // If the status is submitted: update in the DB
             $idPaper = $_REQUEST['idPaper'];
             $status = $_REQUEST['status'];
             foreach ($idPaper as $key => $val) {
                 if (isset($status[$val])) {
                     // echo "ID = $val<br/>";
                     $paper = $paperTbl->find($val)->current();
                     if (is_object($paper)) {
                         $paper->status = $status[$val];
                         $paper->save();
                     } else {
                         throw new Zmax_Exception("Unknown paper id sent to the change status function?");
                     }
                 }
             }
         }
     }
     // If required, hide the selection form
     if (isset($_REQUEST['hide_selection_form'])) {
         $this->config->show_selection_form = 'N';
         $this->config->save();
     } else {
         if (isset($_REQUEST['show_selection_form'])) {
             $this->config->show_selection_form = 'Y';
             $this->config->save();
         }
     }
     // Show the form for filtering papers, if required
     if ($this->config->show_selection_form == 'Y') {
         $this->view->set_var("FORM_SELECT_PAPERS", $this->formSelectPapers($this->view->base_url . "/admin/chair/paperstatus", $this->view, $this->db_v1));
         $this->view->set_var("SHOW_SELECTION_FORM", "");
     } else {
         $this->view->set_var("SELECTION_FORM", "");
     }
     // Create the list of lists to toggle all the selected papers
     $comma = $listLinks = "";
     $statusList = $paperStatusTbl->fetchAll("final_status='Y'");
     foreach ($statusList as $status) {
         $listLinks .= $comma . " <a href='#' onClick=\"TogglePaperStatus('{$status->id}')\">" . $status->label . "</a>";
         $comma = ",";
     }
     $this->view->set_var("TOGGLE_LIST", $listLinks);
     // Always list the papers
     if ($exportExcel) {
         $this->papersReviews($this->view, "ranked_papers_list", false);
     } else {
         $this->papersReviews($this->view, "ranked_papers_list");
     }
     // In addition, produce the Latex file
     if ($exportLatex) {
         $anonymized = false;
         if (isset($_REQUEST['anonymized'])) {
             $anonymized = true;
         }
         // Instantiate the data export object
         $dataExport = new DataExport($this->view->getScriptPaths());
         // Load the latex templates
         $dataExport->getView()->setFile("latex_papers_list", "paperstatus.tex");
         $this->papersReviews($dataExport->getView(), "latex_papers_list", false, $anonymized);
         // The directory where Latex files are produced
         $tex_dir = "selection/";
         $dataExport->getView()->assign("result", "latex_papers_list");
         $result = $dataExport->replaceBadChars($dataExport->getView()->result);
         $dataExport->writeFile($tex_dir, "paperstatus.tex", $result);
         $dataExport->downloadFile($tex_dir, "paperstatus.tex");
     }
     if ($exportExcel) {
         $this->view->assign("export", "ranked_papers_list");
         $this->exportFile("submissions.xls", "text/xls", $this->view->export);
         return;
     }
     echo $this->view->render("layout");
 }