Пример #1
0
 public function process_action($process_id)
 {
     if (Request::isPost()) {
         if (Request::submitted("start")) {
             $protocol = array();
             $starttime = time();
             $this->process = FleximportProcess::find($process_id);
             $this->tables = $this->process->tables;
             foreach ($this->tables as $table) {
                 $table->fetchData();
             }
             foreach ($this->tables as $table) {
                 $table->doImport();
             }
             $duration = time() - $starttime;
             if ($duration >= 60) {
                 PageLayout::postMessage(MessageBox::success(sprintf(_("Import wurde durchgeführt und dauerte %s Minuten"), floor($duration / 60)), $protocol));
             } else {
                 PageLayout::postMessage(MessageBox::success(_("Import wurde durchgeführt"), $protocol));
             }
         } elseif ($_FILES['tableupload']) {
             foreach ($_FILES['tableupload']['tmp_name'] as $table_id => $tmp_name) {
                 if ($tmp_name) {
                     $table = new FleximportTable($table_id);
                     $output = $this->plugin->getCSVDataFromFile($tmp_name);
                     if ($table['tabledata']['source_encoding'] === "utf8") {
                         $output = studip_utf8decode($output);
                     }
                     $headline = array_shift($output);
                     $table->createTable($headline, $output);
                 }
             }
             PageLayout::postMessage(MessageBox::success(_("CSV-Datei hochgeladen")));
         }
     }
     $this->redirect("import/overview/" . $process_id);
 }