Exemple #1
0
 /**
  * Save our results. Tearing down and unsetting the Wizard is handled by
  * in {@link runWizard()} and does not need to be implemented here.
  * 
  * @param string $cacheName
  * @return boolean TRUE if save was successful and tear-down/cleanup of the
  *		Wizard should ensue.
  * @access public
  * @since 7/27/05
  */
 function saveWizard($cacheName)
 {
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $wizard = $this->getWizard($cacheName);
     $properties = $wizard->getAllValues();
     $centerPane = $this->getActionRows();
     ob_start();
     $path = $properties['filename']['tmp_name'];
     $filename = $properties['filename']['name'];
     if ($properties['filename']['name'] == "") {
         print "Please choose a file to upload!";
         $centerPane->add(new Block(ob_get_contents(), 1));
         ob_end_clean();
         return FALSE;
     }
     $newName = $this->moveArchive($path, $filename);
     //===== THIS ARRAY DEFINES THINGS THAT SHOULD NOT BE IMPORTED =====//
     $array = array("REMOTE_FILE", "FILE_URL", "FILE", "FILE_DATA", "FILE_NAME", "MIME_TYPE", "THUMBNAIL_DATA", "THUMBNAIL_MIME_TYPE", "FILE_SIZE", "DIMENSIONS", "THUMBNAIL_DIMENSIONS", "edu.middlebury.harmoni.repository.asset_content", "edu.middlebury.harmoni.repository.asset_content.Content", "edu.middlebury.concerto.exhibition_repository", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.target_id", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.text_position", "Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.display_metadata");
     $hasErrors = false;
     if ($properties['file_type'] == "XML") {
         //	define an empty importer for decompression
         if ($properties['is_archived'] == TRUE) {
             $importer = new XMLImporter($array);
             $directory = $importer->decompress($newName);
             // something happened so tell the end user
             if ($importer->hasErrors()) {
                 $importer->printErrorMessages();
                 $hasErrors = true;
             }
             unset($importer);
             $dir = opendir($directory);
             while ($file = readdir($dir)) {
                 // each folder is a collection
                 if (is_dir($directory . "/" . $file) && $file != "." && $file != "..") {
                     $importer = XMLRepositoryImporter::withFile($array, $directory . "/" . $file . "/metadata.xml", $properties['import_type']);
                     $importer->parseAndImport("asset");
                     // something happened so tell the end user
                     if ($importer->hasErrors()) {
                         $importer->printErrorMessages();
                         $hasErrors = true;
                     }
                     unset($importer);
                 }
             }
             closedir($dir);
             // Unlink the directory
             $this->deleteRecursive($directory);
         } else {
             // not compressed, only one xml file
             $importer = XMLRepositoryImporter::withFile($array, $newName, $properties['import_type']);
             $importer->parseAndImport("asset");
             // something happened so tell the end user
             if ($importer->hasErrors()) {
                 $importer->printErrorMessages();
                 $hasErrors = true;
             }
         }
     }
     if (file_exists($newName)) {
         unlink($newName);
     }
     if ($hasErrors) {
         $centerPane->add(new Block(ob_get_contents(), 1));
         ob_end_clean();
         return FALSE;
     }
     // clean and clear
     $centerPane->add(new Block(ob_get_contents(), 1));
     ob_end_clean();
     return TRUE;
 }