/** * Add an Asset to the feed * * @param object Asset $asset * @return object RSSItem * @access public * @since 8/8/06 */ function getAssetItem($asset) { $harmoni = Harmoni::instance(); $idManager = Services::getService("IdManager"); $assetId = $asset->getId(); $repository = $asset->getRepository(); $repositoryId = $repository->getId(); $item = new RSSItem(); $item->setTitle($asset->getDisplayName()); $item->setLink($harmoni->request->quickURL('asset', 'view', array('collection_id' => $repositoryId->getIdString(), 'asset_id' => $assetId->getIdString()))); if (RequestContext::value('order') == 'modification') { $item->setPubDate($asset->getModificationDate()); } else { $item->setPubDate($asset->getCreationDate()); } $type = $asset->getAssetType(); $item->addCategory($type->getKeyword(), $type->getDomain()); // The item HTML ob_start(); print "<div>"; /********************************************************* * Files *********************************************************/ print "\n\t<div id='files' style='float: right; max-width: 60%;'>"; $fileRecords = $asset->getRecordsByRecordStructure($idManager->getId("FILE")); while ($fileRecords->hasNext()) { $fileRecord = $fileRecords->next(); $fileUrl = RepositoryInputOutputModuleManager::getFileUrlForRecord($asset, $fileRecord); print "\n\t<div style='height: 200px; width: 200px; text-align: center; vertical-align: middle; float: left;'>"; print "\n\t\t<a href='" . $fileUrl . "'>"; print "\n\t\t<img src='"; print RepositoryInputOutputModuleManager::getThumbnailUrlForRecord($asset, $fileRecord); print "' style='vertical-align: middle;'/>"; print "\n\t\t</a>"; print "\n\t</div>"; // Add it as an enclosure $fileSizeParts = $fileRecord->getPartsByPartStructure($idManager->getId('FILE_SIZE')); $fileSizePart = $fileSizeParts->next(); $mimeTypeParts = $fileRecord->getPartsByPartStructure($idManager->getId('MIME_TYPE')); $mimeTypePart = $mimeTypeParts->next(); $item->addEnclosure($fileUrl, $fileSizePart->getValue(), $mimeTypePart->getValue()); } print "\n\t</div>"; /********************************************************* * Basic metadata *********************************************************/ 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>"; } $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>"; /********************************************************* * Other Info Records *********************************************************/ // Get the set of RecordStructures so that we can print them in order. $setManager = Services::getService("Sets"); $structSet = $setManager->getPersistentSet($repositoryId); $structSet->reset(); // 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(); if ($structureId->isEqual($idManager->getId("FILE"))) { continue; } $recordStructure = $repository->getRecordStructure($structureId); $records = $asset->getRecordsByRecordStructure($structureId); while ($records->hasNext()) { $record = $records->next(); $recordId = $record->getId(); print "\n\t<hr />"; print "\n\t<h3>" . $recordStructure->getDisplayName() . "</h3>"; $this->printRecord($repositoryId, $assetId, $record); } } print "</div>"; print "\n\t<div style='clear: both;'>"; print "</div>"; $item->setDescription(ob_get_clean()); return $item; }
/** * Add an Asset to the feed * * @param object Asset $asset * @return object RSSItem * @access public * @since 8/8/06 */ function getAssetItem($asset) { $harmoni = Harmoni::instance(); $idManager = Services::getService("IdManager"); $assetId = $asset->getId(); $item = new RSSItem(); $item->setTitle($asset->getDisplayName()); $item->addCategory("Slideshow"); $item->setPubDate($asset->getModificationDate()); $item->setLink(VIEWER_URL . "?&source=" . urlencode($harmoni->request->quickURL("exhibitions", "slideshowOutlineXml", array("slideshow_id" => $assetId->getIdString())))); /********************************************************* * Get number of slides and first thumbnail. *********************************************************/ $slides = $asset->getAssets(); $count = 0; while ($slides->hasNext()) { $slideAsset = $slides->next(); $count++; if (!isset($firstMediaUrl)) { $slideRecords = $slideAsset->getRecordsByRecordStructure($idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure")); if ($slideRecords->hasNext()) { $slideRecord = $slideRecords->next(); // Media $mediaIdStringObj = $this->getFirstPartValueFromRecord("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.target_id", $slideRecord); if (strlen($mediaIdStringObj->asString())) { $mediaId = $idManager->getId($mediaIdStringObj->asString()); $firstMediaUrl = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($mediaId); } } } } /********************************************************* * item description text. *********************************************************/ ob_start(); if (isset($firstMediaUrl)) { print "\n<img src='" . $firstMediaUrl . "' style='float: right'/>"; } print "\n<div style='margin-bottom: 10px'>" . $asset->getDescription() . "</div>"; print "\n<div style='clear: both'>(" . $count . " " . _("slides") . ")</div>"; $item->setDescription(ob_get_clean()); return $item; }