/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $idManager = Services::getService("Id"); $repositoryManager = Services::getService("Repository"); $repositoryId = $idManager->getId(RequestContext::value('collection_id')); $repository = $repositoryManager->getRepository($repositoryId); $displayName = $repository->getDisplayName(); // Delete all of the tags for the assets in the repository $itemsToDelete = array(); $assets = $repository->getAssets(); while ($assets->hasNext()) { $asset = $assets->next(); $itemsToDelete[] = TaggedItem::forId($asset->getId(), 'concerto'); } $tagManager = Services::getService('Tagging'); $tagManager->deleteItems($itemsToDelete, 'concerto'); $repositoryManager->deleteRepository($idManager->getId(RequestContext::value('collection_id'))); // Log the success or failure if (Services::serviceRunning("Logging")) { $loggingManager = Services::getService("Logging"); $log = $loggingManager->getLogForWriting("Concerto"); $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified."); $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events."); $item = new AgentNodeEntryItem("Delete Node", "Repository deleted:\n<br/> " . $displayName); $item->addNodeId($repositoryId); $log->appendLogWithTypes($item, $formatType, $priorityType); } RequestContext::locationHeader($harmoni->request->quickURL("collections", "namebrowse")); }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $idManager = Services::getService("Id"); $repositoryManager = Services::getService("Repository"); $repository = $repositoryManager->getRepository($idManager->getId(RequestContext::value('collection_id'))); $asset = $repository->getAsset($idManager->getId(RequestContext::value('asset_id'))); // Remove this asset from the tagging manager $tagManager = Services::getService('Tagging'); $tagManager->deleteItems(TaggedItem::forId($asset->getId(), 'concerto')); // Log the action if (Services::serviceRunning("Logging")) { $loggingManager = Services::getService("Logging"); $log = $loggingManager->getLogForWriting("Concerto"); $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified."); $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events."); $item = new AgentNodeEntryItem("Delete Node", "Asset deleted:\n<br/> " . $asset->getDisplayName()); $item->addNodeId($asset->getId()); $item->addNodeId($repository->getId()); $log->appendLogWithTypes($item, $formatType, $priorityType); } $repository->deleteAsset($idManager->getId(RequestContext::value('asset_id'))); $harmoni->history->goBack("concerto/asset/delete-return"); }
/** * Constructor * * @param mixed object or string $id * @param string $system The system an Id is accessed through * @return object * @access public * @since 11/2/06 * @static */ static function forId($id, $system, $class = 'HarmoniNodeTaggedItem') { if (is_string($id)) { $idManager = Services::getService("Id"); $id = $idManager->getId($id); } $item = TaggedItem::forId($id, $system, $class); return $item; }
/** * Execute this action. * * @param object Harmoni $harmoni * @return mixed * @access public * @since 11/10/06 */ function execute() { $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-tags"); $itemId = RequestContext::value('item_id'); $system = RequestContext::value('system'); $harmoni->request->endNamespace(); $item = TaggedItem::forId($itemId, $system); $this->writeXmlResponse($item->getTags()); }
/** * Answer the next Item * * @return mixed object or false * @access public * @since 11/8/06 */ function next() { if (!$this->hasNext()) { $false = false; return $false; } else { $item = TaggedItem::forDatabaseRow($this->_result->next()); return $item; } }
/** * Execute this action. * * @param object Harmoni $harmoni * @return mixed * @access public * @since 11/10/06 */ function execute() { $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-tags"); $itemId = RequestContext::value('item_id'); $system = RequestContext::value('system'); $tagValue = RequestContext::value('tag'); $harmoni->request->endNamespace(); $item = TaggedItem::forId($itemId, $system); // Add the tag $tag = new Tag($tagValue); $tag->removeFromItems($item); // send the new tag list $this->writeXmlResponse($item->getUserTags()); }
/** * Execute this action. * * @param object Harmoni $harmoni * @return mixed * @access public * @since 11/10/06 */ function execute() { $harmoni = Harmoni::instance(); $harmoni->request->startNamespace("polyphony-tags"); $itemId = RequestContext::value('item_id'); $system = RequestContext::value('system'); $tagValue = RequestContext::value('tag'); $harmoni->request->endNamespace(); $item = TaggedItem::forId($itemId, $system); // Add the tag $tag = new Tag($tagValue); if (!$tag->getValue()) { $this->error(_("Cannot tag with an empty value.")); } else { $tag->tagItem($item); } // send the new tag list $this->writeXmlResponse($item->getUserTags()); }
/** * Constructor * * @param mixed object or string $id * @param string $system The system an Id is accessed through * @return object * @access public * @since 11/2/06 * @static */ static function forId($id, $system, $class = 'UrlTaggedItem') { $item = TaggedItem::forId($id, $system, $class); return $item; }
/** * Build the content for this action * * @return boolean * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $asset = $this->getAsset(); $repositoryId = $this->getRepositoryId(); // function links ob_start(); AssetPrinter::printAssetFunctionLinks($harmoni, $asset); $layout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $actionRows->add($layout, "100%", null, LEFT, CENTER); // Columns for Description and thumbnail. $xLayout = new XLayout(); $contentCols = new Container($xLayout, OTHER, 1); $actionRows->add($contentCols, "100%", null, LEFT, CENTER); // Description and dates ob_start(); $assetId = $asset->getId(); print "\n\t<dl>"; if ($asset->getDescription()) { $description = HtmlString::withValue($asset->getDescription()); $description->clean(); print "\n\t\t<dt style='font-weight: bold;'>" . _("Description:") . "</dt>"; print "\n\t\t<dd>" . $description->asString() . "</dd>"; } print "\n\t\t<dt style='font-weight: bold;'>"; print _("ID#"); print ":</dt>\n\t\t<dd >"; print $assetId->getIdString(); print "</dd>"; print "\n\t\t<dt style='font-weight: bold;'>"; print _("Type"); print ":</dt>\n\t\t<dd >"; try { print $asset->getAssetType()->asString(); } catch (UnimplementedException $e) { print "unknown"; } print "</dd>"; try { $date = $asset->getModificationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Modification Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } catch (UnimplementedException $e) { } try { $date = $asset->getCreationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Creation Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } catch (UnimplementedException $e) { } try { if (is_object($asset->getEffectiveDate())) { $date = $asset->getEffectiveDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Effective Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } } catch (UnimplementedException $e) { } try { if (is_object($asset->getExpirationDate())) { $date = $asset->getExpirationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Expiration Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } print "\n\t</dl>"; } catch (UnimplementedException $e) { } $contentCols->add(new Block(ob_get_clean(), STANDARD_BLOCK), "60%", null, LEFT, TOP); // Add the tagging manager script to the header $outputHandler = $harmoni->getOutputHandler(); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<script type='text/javascript' src='" . POLYPHONY_PATH . "javascript/Tagger.js'></script>" . "\n\t\t<link rel='stylesheet' type='text/css' href='" . POLYPHONY_PATH . "javascript/Tagger.css' />"); // Tags ob_start(); print "\n\t<div style='font-weight: bold; margin-bottom: 10px;'>" . _("Tags given to this Asset: ") . "</div>"; print "\n\t<div style=' text-align: justify;'>"; print TagAction::getTagCloudForItem(TaggedItem::forId($assetId, 'concerto'), 'view'); print "\n\t</div>"; $contentCols->add(new Block(ob_get_clean(), STANDARD_BLOCK), "40%", null, LEFT, TOP); //*********************************** // Info Records //*********************************** ob_start(); $printedRecordIds = array(); // Get the set of RecordStructures so that we can print them in order. $setManager = Services::getService("Sets"); $structSet = $setManager->getPersistentSet($repositoryId); if ($structSet->hasNext()) { // First, lets go through the info structures listed in the set and print out // the info records for those structures in order. while ($structSet->hasNext()) { $structureId = $structSet->next(); $records = $asset->getRecordsByRecordStructure($structureId); while ($records->hasNext()) { $record = $records->next(); $recordId = $record->getId(); $printedRecordIds[] = $recordId->getIdString(); print "<hr />"; printRecord($repositoryId, $assetId, $record); } } } else { $structures = $asset->getRecordStructures(); while ($structures->hasNext()) { $structure = $structures->next(); $structureId = $structure->getId(); $records = $asset->getRecordsByRecordStructure($structureId); while ($records->hasNext()) { $record = $records->next(); $recordId = $record->getId(); $printedRecordIds[] = $recordId->getIdString(); print "<hr />"; printRecord($repositoryId, $assetId, $record); } } } $layout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $actionRows->add($layout, "100%", null, LEFT, CENTER); //*********************************** // Content // If we can, we may want to print the content here. // @todo Add some sniffing of content so that we can either put it in if // it is text, image, etc, or do otherwise with it if it is some other form // of data. //*********************************** try { $content = $asset->getContent(); if ($string = $content->asString()) { ob_start(); print "\n<textarea readonly='readonly' rows='30' cols='80'>"; print htmlspecialchars($string); print "</textarea>"; $layout = new Block(ob_get_contents(), STANDARD_BLOCK); ob_end_clean(); $actionRows->add($layout, "100%", null, LEFT, CENTER); } } catch (UnimplementedException $e) { } }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $idManager = Services::getService("Id"); $repositoryManager = Services::getService("Repository"); if (RequestContext::value('collection_id')) { $collectionId = $idManager->getId(RequestContext::value('collection_id')); $repository = $repositoryManager->getRepository($collectionId); } else { if (RequestContext::value('asset_id')) { $parentAssetId = $idManager->getId(RequestContext::value('asset_id')); $parentAsset = $repositoryManager->getAsset($parentAssetId); $repository = $parentAsset->getRepository(); } else { if (count($this->getAssetIds())) { $assetIds = $this->getAssetIds(); $firstAsset = $repositoryManager->getAsset(current($assetIds)); $repository = $firstAsset->getRepository(); } } } // Log the action if (Services::serviceRunning("Logging")) { $loggingManager = Services::getService("Logging"); $log = $loggingManager->getLogForWriting("Concerto"); $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified."); $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events."); } $itemsToDelete = array(); $assetIds = $this->getAssetIds(); $status = new StatusStars(_("Deleting Assets")); $status->initializeStatistics(count($assetIds)); foreach ($assetIds as $id) { $asset = $repository->getAsset($id); // Record the Tagged item to delete. $itemsToDelete[] = TaggedItem::forId($id, 'concerto'); if (isset($log)) { $item = new AgentNodeEntryItem("Delete Node", "Asset deleted:\n<br/> " . $asset->getDisplayName()); $item->addNodeId($asset->getId()); $item->addNodeId($repository->getId()); $log->appendLogWithTypes($item, $formatType, $priorityType); } $repository->deleteAsset($id); $status->updateStatistics(); } // Remove this asset from the tagging manager $tagManager = Services::getService('Tagging'); $tagManager->deleteItems($itemsToDelete, 'concerto'); $harmoni->history->goBack("concerto/asset/delete-return"); }
/** * Answer the tags for a block * * @param object BlockSiteComponent $block * @return string * @access public * @since 4/3/08 */ function getTags($block) { $harmoni = Harmoni::instance(); ob_start(); // Tags print "\n\t<div class='tagging_tags_display'>"; print "Tags: "; SiteDispatcher::passthroughContext(); $item = TaggedItem::forId($block->getQualifierId(), 'segue'); print TagAction::getTagCloud($item->getTags(), 'sitetag', array('font-size: 90%;', 'font-size: 100%;')); SiteDispatcher::forgetContext(); print "\n\t</div>"; return ob_get_clean(); }
function printAssetShort($asset, $params, $num) { $harmoni = Harmoni::instance(); $container = new Container(new YLayout(), BLOCK, EMPHASIZED_BLOCK); $fillContainerSC = new StyleCollection("*.fillcontainer", "fillcontainer", "Fill Container", "Elements with this style will fill their container."); $fillContainerSC->addSP(new MinHeightSP("88%")); $container->addStyle($fillContainerSC); $centered = new StyleCollection("*.centered", "centered", "Centered", "Centered Text"); $centered->addSP(new TextAlignSP("center")); $assetId = $asset->getId(); if ($_SESSION["show_thumbnail"] == 'true') { try { $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($asset); } catch (Exception $e) { $thumbnailURL = false; } if ($thumbnailURL !== FALSE) { if (RepositoryInputOutputModuleManager::hasThumbnailNotIcon($asset)) { $thumbClass = 'thumbnail_image'; } else { $thumbClass = 'thumbnail_icon'; } } else { $thumbnailURL = POLYPHONY_PATH . "/icons/filetypes/unknown.png"; $thumbClass = 'thumbnail_icon'; } $thumbSize = $_SESSION["thumbnail_size"] . "px"; ob_start(); print "\n<div style='height: {$thumbSize}; width: {$thumbSize}; margin: auto;'>"; print "\n\t<a style='cursor: pointer;'"; print " onclick='Javascript:window.open("; print '"' . AssetPrinter::getSlideshowLink($asset, $num) . '", '; // print '"'.preg_replace("/[^a-z0-9]/i", '_', $assetId->getIdString()).'", '; print '"_blank", '; print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"'; print ")'>"; print "\n\t\t<img src='{$thumbnailURL}' class='thumbnail {$thumbClass}' alt='Thumbnail Image' style='max-height: {$thumbSize}; max-width: {$thumbSize};' />"; print "\n\t</a>"; print "\n</div>"; $component = new UnstyledBlock(ob_get_contents()); $component->addStyle($centered); ob_end_clean(); $container->add($component, "100%", null, CENTER, CENTER); } ob_start(); if ($_SESSION["show_displayName"] == 'true') { print "\n\t<div style='font-weight: bold; height: 50px; overflow: auto;'>" . htmlspecialchars($asset->getDisplayName()) . "</div>"; } if ($_SESSION["show_id"] == 'true') { print "\n\t<div>" . _("ID#") . ": " . $assetId->getIdString() . "</div>"; } if ($_SESSION["show_description"] == 'true') { $description = HtmlString::withValue($asset->getDescription()); $description->trim(16); $descriptionShort = preg_replace('/\\.\\.\\.$/', "<a onclick=\"" . "var panel = Panel.run(" . "'" . addslashes(htmlspecialchars($asset->getDisplayName())) . "', " . "100, 400, this.parentNode); " . "if (!panel.contentElement.innerHTML) " . "{panel.contentElement.innerHTML = this.parentNode.nextSibling.innerHTML;}" . "\">...</a>", $description->asString()); print "\n\t<div style='font-size: smaller; height: 50px; overflow: auto;'>"; print $descriptionShort; print "</div>"; if (preg_match('/\\.\\.\\.$/', $description->asString())) { print "<div style='display: none'>" . $asset->getDescription() . "</div>"; } } if ($_SESSION["show_tags"] == 'true') { // Tags print "\n\t<div style='font-size: smaller; height: 50px; overflow: auto; text-align: justify; margin-top: 5px;'>"; print TagAction::getTagCloudForItem(TaggedItem::forId($assetId, 'concerto'), 'view', array('font-size: 90%;', 'font-size: 100%;')); print "\n\t</div>"; } $component = new UnstyledBlock(ob_get_contents()); ob_end_clean(); $container->add($component, "100%", null, LEFT, TOP); // Bottom controls if ($_SESSION["show_controls"] == 'true') { $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); ob_start(); print "\n<div style='margin-top: 5px; font-size: small; white-space: nowrap;'>"; AssetPrinter::printAssetFunctionLinks($harmoni, $asset, NULL, $num, false); print " | "; $harmoni->request->startNamespace("AssetMultiEdit"); print "\n<input type='checkbox'"; print " name='" . RequestContext::name("asset") . "'"; print " value='" . $assetId->getIdString() . "'"; print "/>"; print "\n<input type='hidden'"; print " name='" . RequestContext::name("asset_can_modify_" . $assetId->getIdString()) . "'"; try { if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $assetId)) { print " value='true'"; } else { print " value='false'"; } } catch (UnknownIdException $e) { // allow non-harmoni Repositories. print " value='true'"; } print "/>"; print "\n<input type='hidden'"; print " name='" . RequestContext::name("asset_can_delete_" . $assetId->getIdString()) . "'"; try { if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $assetId)) { print " value='true'"; } else { print " value='false'"; } } catch (UnknownIdException $e) { // allow non-harmoni Repositories. print " value='true'"; } print "/>"; $harmoni->request->endNamespace(); print "</div>"; $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, RIGHT, BOTTOM); } return $container; }
/** * Answer the tags for a block * * @param object BlockSiteComponent $block * @return string * @access public * @since 4/3/08 */ function getTags($block) { $harmoni = Harmoni::instance(); ob_start(); // Tags SiteDispatcher::passthroughContext(); $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); $item = TaggedItem::forId($block->getQualifierId(), 'segue'); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $block->getQualifierId())) { print "\n\t<div class='tagging_tags_display'>"; print TagAction::getTagCloudForItem($item, 'sitetag', array('font-size: 90%;', 'font-size: 100%;')); } else { print TagAction::getTagCloud($item->getTags(), 'sitetag', array('font-size: 90%;', 'font-size: 100%;')); } SiteDispatcher::forgetContext(); print "\n\t</div>"; return ob_get_clean(); }
function canViewItem(TaggedItem $item) { if ($item->getSystem() == ARBITRARY_URL) { return true; } $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.access"), $item->getId()) || $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $item->getId())) { return TRUE; } else { return FALSE; } }
/** * Visit a Block * * @param object BlockSiteComponent $siteComponent * @return mixed * @access public * @since 8/31/07 */ public function visitBlock(BlockSiteComponent $siteComponent) { $harmoni = Harmoni::instance(); // check to see if user is authorized to view block $authZ = Services::getService("AuthZ"); $idManager = Services::getService("Id"); if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $idManager->getId($siteComponent->getId()))) { return; } $item = $this->addItem(new RSSItem()); $item->setTitle($siteComponent->getDisplayName()); $item->setLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId())), true); $item->setPubDate($siteComponent->getModificationDate()); $agentMgr = Services::getService("Agent"); $agent = $agentMgr->getAgent($siteComponent->getCreator()); $item->setAuthor($agent->getDisplayName()); $item->setCommentsLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId()))); $pluginMgr = Services::getService("PluginManager"); $plugin = $pluginMgr->getPlugin($siteComponent->getAsset()); $item->setDescription($plugin->executeAndGetMarkup()); // MediaFile eclosures. try { foreach ($plugin->getRelatedMediaFiles() as $file) { $item->addEnclosure($file->getUrl(), $file->getSize()->value(), $file->getMimeType()); } } catch (UnimplementedException $e) { } // Tags $taggedItem = TaggedItem::forId($siteComponent->getQualifierId(), 'segue'); $tags = $taggedItem->getTags(); while ($tags->hasNext()) { $item->addCategory($tags->next()->getValue()); } }
/** * Build the content for this action * * @return void * @access public * @since 4/26/05 */ function buildContent() { $this->init(); $actionRows = $this->getActionRows(); $harmoni = Harmoni::instance(); $asset = $this->getAsset(); $assetId = $asset->getId(); // function links ob_start(); AssetPrinter::printAssetFunctionLinks($harmoni, $asset); $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), null, null, CENTER, CENTER); ob_start(); print "\n<table width='100%'>\n<tr><td style='text-align: left; vertical-align: top'>"; print "\n\t<dl>"; if ($asset->getDisplayName()) { print "\n\t\t<dt style='font-weight: bold;'>" . _("Title:") . "</dt>"; print "\n\t\t<dd>" . $asset->getDisplayName() . "</dd>"; } if ($asset->getDescription()) { $description = HtmlString::withValue($asset->getDescription()); $description->clean(); print "\n\t\t<dt style='font-weight: bold;'>" . _("Description:") . "</dt>"; print "\n\t\t<dd>" . $description->asString() . "</dd>"; } print "\n\t\t<dt style='font-weight: bold;'>"; print _("ID#"); print ":</dt>\n\t\t<dd >"; print $assetId->getIdString(); print "</dd>"; print "\n\t\t<dt style='font-weight: bold;'>"; print _("Type"); print ":</dt>\n\t\t<dd >"; print $asset->getAssetType()->asString(); print "</dd>"; $date = $asset->getModificationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Modification Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; $date = $asset->getCreationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Creation Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; if (is_object($asset->getEffectiveDate())) { $date = $asset->getEffectiveDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Effective Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } if (is_object($asset->getExpirationDate())) { $date = $asset->getExpirationDate(); print "\n\t\t<dt style='font-weight: bold;'>"; print _("Expiration Date"); print ":</dt>\n\t\t<dd >"; print $date->monthName() . " " . $date->dayOfMonth() . ", " . $date->year() . " " . $date->hmsString() . " " . $date->timeZoneAbbreviation(); print "</dd>"; } print "\n\t</dl>"; print "\n</td><td style='text-align: right; vertical-align: top'>"; $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($assetId); if ($thumbnailURL !== FALSE) { print "\n\t\t<img src='{$thumbnailURL}' alt='Thumbnail Image' align='right' class='thumbnail_image' style='margin-bottom: 5px;' />"; } // Add the tagging manager script to the header $outputHandler = $harmoni->getOutputHandler(); $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<script type='text/javascript' src='" . POLYPHONY_PATH . "javascript/Tagger.js'></script>" . "\n\t\t<link rel='stylesheet' type='text/css' href='" . POLYPHONY_PATH . "javascript/Tagger.css' />"); // Tags print "\n\t<div style='font-weight: bold; margin-bottom: 10px; text-align: left; clear: both;'>" . _("Tags given to this Asset: ") . "</div>"; print "\n\t<div style=' text-align: justify;'>"; print TagAction::getTagCloudForItem(TaggedItem::forId($assetId, 'concerto'), 'view'); print "\n\t</div>"; print "\n</td></tr></table>"; // print "\n\t<hr/>"; $actionRows->add(new Block(ob_get_contents(), STANDARD_BLOCK), "100%", null, LEFT, CENTER); ob_end_clean(); $searchBar = new Container(new YLayout(), BLOCK, STANDARD_BLOCK); $actionRows->add($searchBar, "100%", null, CENTER, CENTER); //*********************************** // Get the assets to display //*********************************** $assets = $asset->getAssets(); $tmpAssets = array(); while ($assets->hasNext()) { $asset = $assets->next(); switch ($_SESSION["asset_order"]) { case 'DisplayName': $assetKey = $asset->getDisplayName(); break; case 'Id': $id = $asset->getId(); $assetKey = $id->getIdString(); break; case 'ModificationDate': $date = $asset->getModificationDate(); $assetKey = $date->asString(); break; case 'CreationDate': $date = $asset->getCreationDate(); $assetKey = $date->asString(); break; default: $assetKey = '0'; } $i = 0; while (isset($tmpAssets[$assetKey . "_" . $i])) { $i++; } $tmpAssets[$assetKey . "_" . $i] = $asset; } if ($_SESSION["asset_order_direction"] == 'ASC') { ksort($tmpAssets); } else { krsort($tmpAssets); } //*********************************** // print the results //*********************************** $resultPrinter = new ArrayResultPrinter($tmpAssets, $_SESSION["asset_columns"], $_SESSION["assets_per_page"], array($this, "printAssetShort"), $this->getParams()); $resultPrinter->setStartingNumber($this->_state['startingNumber']); $resultLayout = $resultPrinter->getLayout(array($this, "canView")); $resultLayout->setPreHTML("<form id='AssetMultiEditForm' name='AssetMultiEditForm' action='' method='post'>"); $resultLayout->setPostHTML("</form>"); $actionRows->add($resultLayout, "100%", null, LEFT, CENTER); /********************************************************* * Display options *********************************************************/ $currentUrl = $harmoni->request->mkURL(); $searchBar->setPreHTML("\n<form action='" . $currentUrl->write() . "' method='post'>\n\t<input type='hidden' name='" . RequestContext::name('form_submitted') . "' value='true'/>"); $searchBar->setPostHTML("\n</form>"); ob_start(); print "\n\t<strong>" . _("Child Assets") . ":</strong>"; $searchBar->add(new UnstyledBlock(ob_get_clean()), null, null, LEFT, TOP); $searchBar->add($this->getDisplayOptions($resultPrinter), null, null, LEFT, TOP); }
/** * Answer the tag cloud for the assets in a repository * * @param object Repository $repository * @return string * @access public * @since 11/14/06 * @static */ static function getTagCloudForRepository($repository, $system, $viewAction = 'viewRepository', $styles = null) { if (!is_object($repository)) { return ""; } $repositoryId = $repository->getId(); $tagManager = Services::getService('Tagging'); $items = array(); $assets = $repository->getAssets(); while ($assets->hasNext()) { $asset = $assets->next(); $items[] = TaggedItem::forId($asset->getId(), $system); } return TagAction::getTagCloudDiv($tagManager->getTagsForItems(new HarmoniIterator($items), TAG_SORT_ALFA, 100), $viewAction, $styles, array('repository_id' => $repositoryId->getIdString(), 'system' => $system)); }
/** * Regenerate tags for a single Asset * * @param object Asset $asset * @param object Id $agent Id The agent id to associate with these tags * @param string $system The system to associate with these tags * @param optional object Id $repositoryId Not required, but can enhance * efficiency if it is known ahead of time. * @return void * @access public * @since 11/27/06 */ function regenerateTagsForAsset($asset, $agentId, $system, $repositoryId = null) { if (!is_object($repositoryId)) { $repository = $asset->getRepository(); $repositoryId = $repository->getId(); } $assetId = $asset->getId(); printpre("<hr/>Asset: " . $assetId->getIdString() . " " . $asset->getDisplayName()); $item = TaggedItem::forId($asset->getId(), $system); $item->deleteTagsByAgent($agentId); // Loop through the records and generate tags from the values $partStructIds = $this->getPartStructureIdsForTagGeneration($repositoryId); while ($partStructIds->hasNext()) { $values = $asset->getPartValuesByPartStructure($partStructIds->next()); while ($values->hasNext()) { $value = $values->next(); $tag = new Tag($value->asString()); $tag->tagItemForAgent($item, $agentId); printpre("Adding Tag: " . $tag->getValue()); } } }
/** * Answer an TagInfoIterator that lists information on tags attached to an item. * * @param object TaggedItem $item * @return object TagInfoIterator * @access public * @since 4/18/08 */ public function getTagInfoForItem(TaggedItem $item) { $query = new SelectQuery(); $query->addTable('tag'); $query->addColumn('value'); $query->addColumn('user_id'); $query->addColumn('tstamp'); $query->addWhereEqual("fk_item", $item->getDatabaseId()); $dbc = Services::getService("DatabaseManager"); $result = $dbc->query($query, $this->getDatabaseIndex()); $iterator = new HarmoniIterator(array()); $idManager = Services::getService("Id"); while ($result->hasNext()) { $row = $result->next(); $iterator->add(new TagInfo(new Tag($row['value']), $item, $idManager->getId($row['user_id']), DateAndTime::fromString($row['tstamp']))); } return $iterator; }
/** * Update the auto-generated tags for the asset * * @param object Id $assetId * @return void * @access public * @since 11/21/06 */ function updateAssetTags($assetId) { // Clean the values into nice tag values $newTagValues = array(); foreach ($this->_newStructuredTagValues[$assetId->getIdString()] as $value) { $tag = new Tag($value); if ($tag->getValue()) { $newTagValues[] = $tag->getValue(); } } // Get the TaggedItem for this asset $idManager = Services::getService("Id"); $systemAgentId = $idManager->getId('system:concerto'); $item = TaggedItem::forId($assetId, 'concerto'); // Remove any missing tags $systemTags = $item->getTagsByAgent($systemAgentId); $existingTagValues = array(); while ($systemTags->hasNext()) { $tag = $systemTags->next(); if (in_array($tag->getValue(), $newTags)) { $existingTagValues[] = $tag->getValue(); } else { $tag->removeFromItemsForAgent($item, $systemAgentId); printpre("Removing tag '{$tagValue}'"); } } // Add any new tags foreach ($newTagValues as $tagValue) { if (!in_array($tagValue, $existingTagValues)) { printpre("Adding tag '{$tagValue}'"); $tag = new Tag($tagValue); $tag->tagItemForAgent($item, $systemAgentId); } } unset($this->_newStructuredTagValues[$assetId->getIdString()]); }