예제 #1
0
 /**
  * Shows export formats.
  *
  * @param    string $format The export format
  *
  * @return    string
  */
 public function showExport($format)
 {
     return FormatHandler::export($this->publication, $format);
 }
예제 #2
0
 /** @noinspection PhpUnusedPrivateMethodInspection
  * @param Request $request
  *
  * @return bool
  */
 private function import(Request $request)
 {
     $format = Validator::sanitizeText($request->post('format'));
     $bulkimport = Validator::sanitizeBoolean($request->post('bulkimport'));
     $input = $request->post('input');
     if ($input && $format) {
         try {
             if ($bulkimport && filter_var($input, FILTER_VALIDATE_URL)) {
                 $input = $this->getInputFromUrl($input);
                 if ($input == false) {
                     $this->errors[] = 'Could not get content from URL.';
                     return false;
                 }
             }
             $entries = FormatHandler::import($input, $format);
             if ($bulkimport) {
                 $_SESSION['bulkimport_msg'] = $this->bulkimport($entries);
                 return true;
             }
             $_SESSION['input_raw'] = $input;
             $_SESSION['input_format'] = $format;
             $this->setInputAndRestInSession($entries);
             return true;
         } catch (Exception $e) {
             $this->errors[] = $e->getMessage();
         }
     } else {
         $this->errors[] = 'No input to import given';
     }
     return false;
 }