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;
 }
Exemple #2
0
 /**
  * Import a directories that contain metadata.xml files
  * 
  * @param string $directory
  * @param optional object Asset $parentAsset
  * @return void
  * @access public
  * @since 12/7/06
  */
 function importDirectory($directory, $parentAsset = null)
 {
     $importer = XMLRepositoryImporter::withObject($this->_ignore, $this->_repository, $directory . "/metadata.xml", $this->_importType);
     if ($parentAsset) {
         $importer->setParent($parentAsset);
     }
     $importer->parseAndImportBelow("asset", 100);
     // something happened so tell the end user
     if ($importer->hasErrors()) {
         $importer->printErrorMessages();
         $this->_hasErrors = true;
     }
     unset($importer);
 }
 $results->free();
 $db->commitTransaction(IMPORTER_CONNECTION);
 // Check for the dublin core record structure
 $dcId = $idManager->getId('dc');
 $dcExists = FALSE;
 $recStructs = $repository->getRecordStructures();
 while ($recStructs->hasNext()) {
     $recStruct = $recStructs->next();
     if ($dcId->isEqual($recStruct->getId())) {
         $dcExists = true;
         break;
     }
 }
 if (!$dcExists) {
     $array = array();
     $importer = XMLRepositoryImporter::withObject($array, $repository, MYDIR . "/sampledata/SchemaInstallCollection.xml", "insert");
     $importer->parseAndImportBelow("recordstructure");
     if ($importer->hasErrors()) {
         $importer->printErrorMessages();
         exit;
     }
 }
 /*********************************************************
  * Segue "CourseGroups" group
  *********************************************************/
 $agentMgr = Services::getService("Agent");
 if (!$agentMgr->isGroup($idManager->getId("edu.middlebury.segue.coursegroups"))) {
     $groupType = new Type("System", "edu.middlebury", "SystemGroups", "Groups for administrators and others with special privileges.");
     $nullType = new Type("System", "edu.middlebury.harmoni", "NULL");
     $properties = new HarmoniProperties($nullType);
     $agentMgr->createGroup("Segue Course-Groups", $groupType, "Groupings of Segue Course-Sections.", $properties, $idManager->getId("edu.middlebury.segue.coursegroups"));
Exemple #4
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);
     if ($properties['file_type'] == "XML") {
         $repository = $repositoryManager->getRepository($idManager->getId($harmoni->request->get('collection_id')));
         $matrixMaker = new XMLRepositoryImporter();
         $matrixMaker->doIdMatrix();
         // recordstructures into idmatrix
         $importer = XMLAssetImporter::withObject($repository->getAsset($idManager->getId($harmoni->request->get("asset_id"))), $newName, $properties['import_type']);
         $importer->parseAndImportBelow("asset");
         $matrixMaker->dropIdMatrix();
         unset($matrixMaker);
     }
     $centerPane->add(new Block(ob_get_contents(), 1));
     ob_end_clean();
     return true;
 }
 /**
  * Organizes the import
  * 
  * @param object mixed $topImporter is the importer instance that parsed the XML
  * @param object DOMIT_Node
  * @param string
  * @param object mixed
  * @param string
  * @return object HarmoniId
  * @access public
  * @since 10/5/05
  */
 function import($topImporter, $node, $type, $parent)
 {
     $path = $node->getText();
     if (!preg_match("#^([a-zA-Z]+://|[a-zA-Z]+:\\|/)#", $path)) {
         $path = $node->ownerDocument->xmlPath . $path;
     }
     // @todo keep the topImporter passing down to new importer hierarchies!!!
     $imp = XMLRepositoryImporter::withFile($this->_existingArray, $path, $type);
     $imp->parseAndImport("asset");
     unset($imp);
 }