/** * * * @param <##> * @return <##> * @access public * @since 1/18/06 */ public function printSiteShort(Asset $asset, $action, $num, Slot $otherSlot = null) { $harmoni = Harmoni::instance(); $assetId = $asset->getId(); $authZ = Services::getService('AuthZ'); $idMgr = Services::getService('Id'); if (!$authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId) && !$otherSlot->isUserOwner()) { return new UnstyledBlock('', BLANK); } $container = new Container(new YLayout(), BLOCK, STANDARD_BLOCK); $fillContainerSC = new StyleCollection("*.fillcontainer", "fillcontainer", "Fill Container", "Elements with this style will fill their container."); $fillContainerSC->addSP(new MinHeightSP("88%")); // $fillContainerSC->addSP(new WidthSP("100%")); // $fillContainerSC->addSP(new BorderSP("3px", "solid", "#F00")); $container->addStyle($fillContainerSC); $centered = new StyleCollection("*.centered", "centered", "Centered", "Centered Text"); $centered->addSP(new TextAlignSP("center")); // Use the alias instead of the Id if it is available. $viewUrl = SiteDispatcher::getSitesUrlForSiteId($assetId->getIdString()); $slotManager = SlotManager::instance(); try { $sitesTrueSlot = $slotManager->getSlotBySiteId($assetId); } catch (Exception $e) { } // Print out the content ob_start(); print "\n\t<div class='portal_list_slotname'>"; if (isset($sitesTrueSlot)) { if (is_null($otherSlot) || $sitesTrueSlot->getShortname() == $otherSlot->getShortname()) { print $sitesTrueSlot->getShortname(); } else { print $otherSlot->getShortname(); $targets = array(); $target = $otherSlot->getAliasTarget(); while ($target) { $targets[] = $target->getShortname(); if ($target->isAlias()) { $target = $target->getAliasTarget(); } else { $target = null; } } print "\n<br/>"; print str_replace('%1', implode(' » ', $targets), _("(an alias of %1)")); // Add Alias info. // if ($otherSlot->isAlias()) { // ob_start(); // // print _("This slot is an alias of ").$slot->getAliasTarget()->getShortname(); // // $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, LEFT, TOP); // } } } else { print _("ID#") . ": " . $assetId->getIdString(); } print "\n\t</div>"; print "\n\t<div class='portal_list_site_title'>"; if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { print "\n\t\t<a href='" . $viewUrl . "'>"; print "\n\t\t\t<strong>" . HtmlString::getSafeHtml($asset->getDisplayName()) . "</strong>"; print "\n\t\t</a>"; print "\n\t\t<br/>"; print "\n\t\t<a href='" . $viewUrl . "' style='font-size: smaller;'>"; print "\n\t\t\t" . $viewUrl; print "\n\t\t</a>"; } print "\n\t</div>"; print "\n\t<div class='portal_list_controls'>\n\t\t"; $controls = array(); if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { $controls[] = "<a href='" . $viewUrl . "'>" . _("view") . "</a>"; } // Hide all edit links if not authenticated to prevent web spiders from traversing them if ($this->isAuthenticated) { // While it is more correct to check modify permission permission, doing // so forces us to check AZs on the entire site until finding a node with // authorization or running out of nodes to check. Since edit-mode actions // devolve into view-mode if no authorization is had by the user, just // show the links all the time to cut page loads from 4-6 seconds to // less than 1 second. if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { $controls[] = "<a href='" . SiteDispatcher::quickURL($action->getUiModule(), 'editview', array('node' => $assetId->getIdString())) . "'>" . _("edit") . "</a>"; } // if ($action->getUiModule() == 'ui2') { // $controls[] = "<a href='".SiteDispatcher::quickURL($action->getUiModule(), 'arrangeview', array('node' => $assetId->getIdString()))."'>"._("arrange")."</a>"; // } // add link to tracking if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { $trackUrl = $harmoni->request->quickURL("participation", "actions", array('node' => $assetId->getIdString())); ob_start(); print " <a target='_blank' href='" . $trackUrl . "'"; print ' onclick="'; print "var url = '" . $trackUrl . "'; "; print "window.open(url, 'site_map', 'width=600,height=600,resizable=yes,scrollbars=yes'); "; print "return false;"; print '"'; print ">" . _("track") . "</a>"; $controls[] = ob_get_clean(); } if (!is_null($otherSlot) && $otherSlot->isAlias() && $otherSlot->isUserOwner()) { $controls[] = "<a href='" . $harmoni->request->quickURL('slots', 'remove_alias', array('slot' => $otherSlot->getShortname())) . "' onclick=\"if (!confirm('" . str_replace("%1", $otherSlot->getShortname(), str_replace("%2", $otherSlot->getAliasTarget()->getShortname(), _("Are you sure that you want \\'%1\\' to no longer be an alias of \\'%2\\'?"))) . "')) { return false; }\">" . _("remove alias") . "</a>"; } else { if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.delete'), $assetId)) { $controls[] = "<a href='" . $harmoni->request->quickURL($action->getUiModule(), 'deleteComponent', array('node' => $assetId->getIdString())) . "' onclick=\"if (!confirm('" . _("Are you sure that you want to permenantly delete this site?") . "')) { return false; }\">" . _("delete") . "</a>"; } } // Add a control to select this site for copying. This should probably // have its own authorization, but we'll use add_children/modify for now. if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $assetId)) { if (isset($sitesTrueSlot) && (is_null($otherSlot) || $sitesTrueSlot->getShortname() == $otherSlot->getShortname())) { $controls[] = Segue_Selection::instance()->getAddLink(SiteDispatcher::getSiteDirector()->getSiteComponentFromAsset($asset)); } } } print implode("\n\t\t | ", $controls); print "\n\t</div>"; if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) { $description = HtmlString::withValue($asset->getDescription()); $description->trim(25); print "\n\t<div class='portal_list_site_description'>" . $description->asString() . "</div>"; } print "\n\t<div style='clear: both;'></div>"; print $this->getExportControls($assetId, $otherSlot, $sitesTrueSlot); $component = new UnstyledBlock(ob_get_clean()); $container->add($component, "100%", null, LEFT, TOP); return $container; }
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; }
function printSlideShort($asset, $params, $slideshowIdString, $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")); $idManager = Services::getService("Id"); $repositoryManager = Services::getService("Repository"); $authZ = Services::getService("AuthZ"); // Get our record and its data $slideRecords = $asset->getRecordsByRecordStructure($idManager->getId("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure")); if ($slideRecords->hasNext()) { $slideRecord = $slideRecords->next(); // Text-Position $textPosition = getFirstPartValueFromRecord("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.text_position", $slideRecord); // Display Metadata $displayMetadata = getFirstPartValueFromRecord("Repository::edu.middlebury.concerto.exhibition_repository::edu.middlebury.concerto.slide_record_structure.edu.middlebury.concerto.slide_record_structure.display_metadata", $slideRecord); // Media $mediaIdStringObj = 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()); } else { $mediaId = null; } } // ------------------------------------------ ob_start(); print "\n\t<a style='cursor: pointer;'"; print " onclick='Javascript:window.open("; print '"' . VIEWER_URL . "?&source="; print urlencode($harmoni->request->quickURL('exhibitions', "slideshowOutlineXml", array('slideshow_id' => $slideshowIdString))); print '&start=' . ($num - 1) . '", '; print '"_blank", '; print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"'; print ")'>"; $viewerATag = ob_get_clean(); /********************************************************* * Media *********************************************************/ if (isset($mediaId) && $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $mediaId) && $_SESSION["show_thumbnail"] == 'true') { $mediaAsset = $repositoryManager->getAsset($mediaId); $mediaAssetId = $mediaAsset->getId(); $mediaAssetRepository = $mediaAsset->getRepository(); $mediaAssetRepositoryId = $mediaAssetRepository->getId(); $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($mediaAsset); if ($thumbnailURL !== FALSE) { $thumbSize = $_SESSION["thumbnail_size"] . "px"; ob_start(); print "\n<div style='height: {$thumbSize}; width: {$thumbSize}; margin: auto;'>"; print $viewerATag; print "\n\t\t<img src='{$thumbnailURL}' alt='Thumbnail Image' style='max-height: {$thumbSize}; max-width: {$thumbSize};' class='thumbnail_image' />"; print "\n\t</a>"; print "\n</div>"; $component = new UnstyledBlock(ob_get_clean()); $component->addStyle($centered); $container->add($component, "100%", null, CENTER, CENTER); } // other files $fileRecords = $mediaAsset->getRecordsByRecordStructure($idManager->getId("FILE")); } // Link to viewer $numFiles = 0; if (isset($fileRecords)) { while ($fileRecords->hasNext()) { $record = $fileRecords->next(); $numFiles++; } } ob_start(); print "\n<div height='15px; font-size: small;'>"; print $viewerATag; print _("Open in Viewer"); if ($numFiles > 1) { print " (" . ($numFiles - 1) . " " . _("more files") . ")"; } print "\n\t</a>"; print "\n</div>"; $component = new UnstyledBlock(ob_get_clean()); $component->addStyle($centered); $container->add($component, "100%", null, CENTER, CENTER); // Title ob_start(); if ($_SESSION["show_displayName"] == 'true') { print "\n\t<div style='font-weight: bold; height: 50px; overflow: auto;'>" . htmlspecialchars($asset->getDisplayName()) . "</div>"; } // Caption if ($_SESSION["show_description"] == 'true') { $description = HtmlString::withValue($asset->getDescription()); $description->clean(); if (isset($thumbnailURL)) { print "\n\t<div style='font-size: smaller; height: 100px; overflow: auto;'>"; } else { print "\n\t<div style='font-size: smaller; height: " . ($_SESSION["thumbnail_size"] + 100) . "px; overflow: auto;'>"; } print $description->asString(); if (isset($displayMetadata) && $displayMetadata->isTrue() && isset($mediaId) && $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $mediaId)) { print "\t\t\t<hr/>\n"; $mediaAsset = $repositoryManager->getAsset($mediaId); printTargetAsset($mediaAsset); } // Unauthorized to view Media Message if (isset($mediaId) && !$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $mediaId)) { print "\t\t\t<div style='font-size: large; font-weight: bold; border: 2px dotted; padding: 5px;'>"; $harmoni = Harmoni::instance(); print "\n\t\t\t\t<p>"; print _("You are not authorized to view the media for this slide."); print "</p>\n\t\t\t\t<p>"; print _("If you have not done so, please go to "); print "<a href='" . $harmoni->request->quickURL("home", "welcome"); print "'>Concerto</a>"; print _(" and log in."); print "\t\t\t\t</p>\n\t\t\t</div>\n"; } print "</div>"; } $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, LEFT, TOP); // Controls ob_start(); // Authorization Icons print _("Slide: ") . AuthZPrinter::getAZIcon($asset->getId()); if (isset($mediaId) && $mediaId) { print "<br/>" . _("Media: ") . AuthZPrinter::getAZIcon($mediaId); } $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, LEFT, BOTTOM); return $container; }
function printAssetShort($assetId, $num) { $harmoni = Harmoni::instance(); $repositoryManager = Services::getService("Repository"); $asset = $repositoryManager->getAsset($assetId); $container = new Container(new YLayout(), BLOCK, STANDARD_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') { $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($asset); if ($thumbnailURL !== FALSE) { $xmlStart = $num - 1; $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 '"' . VIEWER_URL . "?&source="; print urlencode($harmoni->request->quickURL("basket", "browse_xml")); print '&start=' . $xmlStart . '", '; 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 thumbnail_image' 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(25); print "\n\t<div style='font-size: smaller; height: 50px; overflow: auto;'>" . $description->asString() . "</div>"; } $component = new UnstyledBlock(ob_get_contents()); ob_end_clean(); $container->add($component, "100%", null, LEFT, TOP); ob_start(); print "\n<a href='"; print $harmoni->request->quickURL("basket", "remove", array('asset_id' => $assetId->getIdString())); print "' title='" . _("Remove from Selection") . "'>"; print _('remove'); print "</a>"; print "\n | <a href='"; print $harmoni->request->quickURL("basket", "up", array('asset_id' => $assetId->getIdString())); print "' title='" . _('move up') . "'>"; // print "<img src='".POLYPHONY_PATH."/icons/basket/arrowleft.png' width='25px' border='0' alt='"._("Move Up")."' />"; print "<--"; print "</a>"; print "\n | <a href='"; print $harmoni->request->quickURL("basket", "down", array('asset_id' => $assetId->getIdString())); print "' title='" . _('move down') . "'>"; // print "<img src='".POLYPHONY_PATH."/icons/basket/arrowright.png' width='25px' border='0' alt='"._("Move Down")."' />"; print "-->"; print "</a>"; $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, RIGHT, BOTTOM); return $container; }