/** * Exporter of Assets * * @access public * @since 10/17/05 */ function exportAssets() { $hasRootSearch = FALSE; $rootSearchType = new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", ""); $searchTypes = $this->_object->getSearchTypes(); while ($searchTypes->hasNext()) { if ($rootSearchType->isEqual($searchTypes->next())) { $hasRootSearch = TRUE; break; } } if ($hasRootSearch) { $criteria = NULL; $children = $this->_object->getAssetsBySearch($criteria, $rootSearchType, new HarmoniProperties(new Type('Repository', 'edu.middlebury', 'null'))); } else { $children = $this->_object->getAssets(); } $this->_status = new StatusStars(str_replace('%1', $this->_object->getDisplayName(), _("Exporting all Assets in the Collection, '%1'"))); $this->_status->initializeStatistics($children->count(), 100); while ($children->hasNext()) { $child = $children->next(); $exporter = XMLAssetExporter::withDir($this->_xml, $this->_repDir); $exporter->export($child); $this->_status->updateStatistics(); } unset($exporter); }
/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $idManager = Services::getService("Id"); $repositoryManager = Services::getService("Repository"); $exhibitionRepositoryId = $idManager->getId("edu.middlebury.concerto.exhibition_repository"); $repository = $repositoryManager->getRepository($exhibitionRepositoryId); // If the Repository supports searching of root assets, just get those $hasRootSearch = FALSE; $rootSearchType = new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", ""); $searchTypes = $repository->getSearchTypes(); while ($searchTypes->hasNext()) { if ($rootSearchType->isEqual($searchTypes->next())) { $hasRootSearch = TRUE; break; } } ob_start(); print "<p>"; print _("Some <em>Exhibitions</em> and <em>Slide-Shows</em> may be restricted to certain users or groups of users. Log in above to ensure your greatest access to all parts of the system."); print "</p>"; $authZ = Services::getService("AuthZ"); //===== Create Link =====// if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $exhibitionRepositoryId)) { print "\n<p>"; print "\n\t<a href='" . $harmoni->request->quickURL("exhibitions", "create_exhibition") . "'>" . _("Create a new <em>Exhibition</em>") . "</a>"; //===== Import Link =====// // $harmoni->request->startNamespace("import"); // print "\t|\t<a href='". // $harmoni->request->quickURL("exhibitions", "import_exhibition"). // "'>". // _("Import <em>Exhibition(s)</em>"). // "</a>"; // $harmoni->request->endNamespace(); print "\n</p>"; } $introText = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $actionRows->add($introText, "100%", null, CENTER, CENTER); //*********************************** // Get the assets to display //*********************************** if ($hasRootSearch) { $criteria = NULL; $searchProperties = new HarmoniProperties(HarmoniType::fromString("repository::harmoni::order")); $searchProperties->addProperty("order", $arg = "DisplayName"); unset($arg); $searchProperties->addProperty("direction", $arg = "ASC"); unset($arg); $assets = $repository->getAssetsBySearch($criteria, $rootSearchType, $searchProperties); } else { $assets = $repository->getAssets(); } //*********************************** // print the results //*********************************** $resultPrinter = new IteratorResultPrinter($assets, 1, 20, "printAssetShort", $harmoni); $resultLayout = $resultPrinter->getLayout("canView"); $actionRows->add($resultLayout, "100%", null, LEFT, CENTER); }
/** * Delete a Repository. * * @param object Id $repositoryId * * @throws object RepositoryException An exception with one of * the following messages defined in * org.osid.repository.RepositoryException may be thrown: {@link * org.osid.repository.RepositoryException#OPERATION_FAILED * OPERATION_FAILED}, {@link * org.osid.repository.RepositoryException#PERMISSION_DENIED * PERMISSION_DENIED}, {@link * org.osid.repository.RepositoryException#CONFIGURATION_ERROR * CONFIGURATION_ERROR}, {@link * org.osid.repository.RepositoryException#UNIMPLEMENTED * UNIMPLEMENTED}, {@link * org.osid.repository.RepositoryException#NULL_ARGUMENT * NULL_ARGUMENT}, {@link * org.osid.repository.RepositoryException#UNKNOWN_ID UNKNOWN_ID} * * @access public */ function deleteRepository(Id $repositoryId) { $repository = $this->getRepository($repositoryId); // Check to see if this DR has any assets. $assets = $repository->getAssets(); // If so, delete them. if ($assets->hasNext()) { // We need to delete the assets by deleting the root assets $hasRootSearch = FALSE; $rootSearchType = new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", ""); $searchTypes = $repository->getSearchTypes(); while ($searchTypes->hasNext()) { if ($rootSearchType->isEqual($searchTypes->next())) { $hasRootSearch = TRUE; break; } } if ($hasRootSearch) { $criteria = NULL; $rootAssets = $repository->getAssetsBySearch($criteria, $rootSearchType, new HarmoniProperties(new Type('Repository', 'edu.middlebury', 'null'))); while ($rootAssets->hasNext()) { $asset = $rootAssets->next(); $repository->deleteAsset($asset->getId()); } } else { // if we cant then sort the asset ids by depth $infoIterator = $this->_hierarchy->traverse($repositoryId, Hierarchy::TRAVERSE_MODE_DEPTH_FIRST, Hierarchy::TRAVERSE_DIRECTION_DOWN, Hierarchy::TRAVERSE_LEVELS_ALL); $levels = array(); while ($infoIterator->hasNextTraversalInfo()) { $info = $infoIterator->nextTraversalInfo(); if (!is_array($levels[$info->getLevel()])) { $levels[$info->getLevel()] = array(); } $levels[$info->getLevel()][] = $info->getNodeId(); } for ($i = count($levels) - 1; $i > 0; $i--) { $level = $levels[$i]; foreach (array_keys($level) as $key) { $repository->deleteAsset($level[$key]); } } } } // Delete the node for the DR $this->_hierarchy->deleteNode($repositoryId); // Delete type type for the Repository $query = new DeleteQuery(); $query->setTable("dr_repository_type"); $query->addWhereEqual("repository_id", $repositoryId->getIdString()); $dbc = Services::getService("DatabaseManager"); $dbc->query($query, $this->_dbIndex); unset($this->_createdRepositories[$repositoryId->getIdString()]); }
/** * Add the slideshow hierarchy to the menu for the selected Id. * * @param object Menu $mainMenu * @param object Id $assetId * @return void * @access public * @since 5/22/06 */ function addSlideshowHierarchy($mainMenu, $assetId, $viewMode = true) { $idManager = Services::getService("Id"); $repositoryManager = Services::getService("Repository"); $harmoni = Harmoni::instance(); list($module, $action) = explode(".", $harmoni->request->getRequestedModuleAction()); $exhibitionRepositoryId = $idManager->getId("edu.middlebury.concerto.exhibition_repository"); $exhibitionRepository = $repositoryManager->getRepository($exhibitionRepositoryId); $asset = $exhibitionRepository->getAsset($assetId); $assets = array(); $assets[] = $asset; $this->addFirstParents($asset, $assets); $slideshowType = new HarmoniType("Asset Types", "edu.middlebury.concerto", "Slideshow", "Slide-Shows are ordered collections of slides that contain captions and may reference media Assets."); $altSlideshowType = new HarmoniType("exhibitions", "edu.middlebury.concerto", "slideshow", "Slide-Shows are ordered collections of slides that contain captions and may reference media Assets."); $exhibitionType = new Type("Asset Types", "edu.middlebury.concerto", "Exhibition", "Exhibition Assets are containers for Slideshows."); $j = 0; for ($i = count($assets) - 1; $i >= 0; $i--) { $currentAssetId = $assets[$i]->getId(); if ($slideshowType->isEqual($assets[$i]->getAssetType()) || $altSlideshowType->isEqual($assets[$i]->getAssetType())) { if ($viewMode) { $mainMenu->add(new MenuItemLink($assets[$i]->getDisplayName(), $harmoni->request->quickURL("exhibitions", 'browseSlideshow', array('asset_id' => $currentAssetId->getIdString())), $action == "browseSlideshow" ? TRUE : FALSE, $j + 3), "100%", null, LEFT, CENTER); } else { $harmoni->request->startNamespace("modify_slideshow"); $mainMenu->add(new MenuItemLink($assets[$i]->getDisplayName(), $harmoni->request->quickURL("exhibitions", 'modify_slideshow', array('slideshow_id' => $currentAssetId->getIdString())), $action == "modify_slideshow" && RequestContext::value('slideshow_id') == $currentAssetId->getIdString() ? TRUE : FALSE, $j + 3), "100%", null, LEFT, CENTER); $harmoni->request->endNamespace(); } } else { if ($exhibitionType->isEqual($assets[$i]->getAssetType())) { $mainMenu->add(new MenuItemLink($assets[$i]->getDisplayName(), $harmoni->request->quickURL("exhibitions", 'browse_exhibition', array('exhibition_id' => $currentAssetId->getIdString())), $viewMode && $action == "browse_exhibition" ? TRUE : FALSE, $j + 3), "100%", null, LEFT, CENTER); } else { $mainMenu->add(new MenuItemLink($assets[$i]->getDisplayName(), '', FALSE, $j + 3), "100%", null, LEFT, CENTER); } } $j++; } }
/** * Answer true if this repository supports root search * * @return boolean * @access public * @since 5/15/06 */ function hasRootSearch() { $repository = $this->getRepository(); // If the Repository supports searching of root assets, just get those $rootSearchType = new HarmoniType("Repository", "edu.middlebury.harmoni", "RootAssets", ""); $searchTypes = $repository->getSearchTypes(); while ($searchTypes->hasNext()) { if ($rootSearchType->isEqual($searchTypes->next())) { return true; } } return false; }