示例#1
0
 /**
  * Answer out an XML block representing the given asset, its Dublin Core, and
  * its file records
  * 
  * @param object Asset $asset
  * @return void
  * @access public
  * @since 1/26/07
  */
 function getAssetXml($asset)
 {
     try {
         $idManager = Services::getService("Id");
         $authZ = Services::getService("AuthZ");
         if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $asset->getId())) {
             return '';
         }
         ob_start();
         $assetId = $asset->getId();
         $repository = $asset->getRepository();
         $repositoryId = $repository->getId();
         print "\n\t<asset id=\"" . $assetId->getIdString() . "\" repositoryId=\"" . $repositoryId->getIdString() . "\">";
         print "\n\t\t<displayName><![CDATA[";
         print HtmlString::getSafeHtml($asset->getDisplayName());
         print "]]></displayName>";
         print "\n\t\t<description><![CDATA[";
         print HtmlString::getSafeHtml($asset->getDescription());
         print "]]></description>";
         print "\n\t\t<modificationDate><![CDATA[";
         $date = $asset->getModificationDate();
         print $date->asString();
         print "]]></modificationDate>";
         print "\n\t\t<authorization function='edu.middlebury.authorization.view' />";
         if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $asset->getId())) {
             print "\n\t\t<authorization function='edu.middlebury.authorization.modify' />";
         }
         if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $asset->getId())) {
             print "\n\t\t<authorization function='edu.middlebury.authorization.delete' />";
         }
         /*********************************************************
          * Files
          *********************************************************/
         $fileRecords = $asset->getRecordsByRecordStructure($idManager->getId('FILE'));
         while ($fileRecords->hasNext()) {
             $fileRecord = $fileRecords->next();
             $fileRecordId = $fileRecord->getId();
             print "\n\t\t<file id=\"" . $fileRecordId->getIdString() . "\"";
             print " mimetype=\"" . $fileRecord->getPartsByPartStructure($idManager->getId("MIME_TYPE"))->next()->getValue() . "\"";
             print ">";
             $parts = $fileRecord->getPartsByPartStructure($idManager->getId("FILE_NAME"));
             $part = $parts->next();
             print "\n\t\t\t<name><![CDATA[" . HtmlString::getSafeHtml($part->getValue()) . "]]></name>";
             $parts = $fileRecord->getPartsByPartStructure($idManager->getId("FILE_SIZE"));
             $part = $parts->next();
             print "\n\t\t\t<size>" . $part->getValue() . "</size>";
             print "\n\t\t\t<url><![CDATA[";
             print RepositoryInputOutputModuleManager::getFileUrlForRecord($asset, $fileRecord);
             print "]]></url>";
             print "\n\t\t\t<thumbnailUrl><![CDATA[";
             print RepositoryInputOutputModuleManager::getThumbnailUrlForRecord($asset, $fileRecord);
             print "]]></thumbnailUrl>";
             print "\n\t\t</file>";
         }
         /*********************************************************
          * Dublin Core
          *********************************************************/
         $records = $asset->getRecordsByRecordStructure($idManager->getId('dc'));
         if ($records->hasNext()) {
             $record = $records->next();
             $recordId = $record->getId();
             print "\n\t\t<dublinCore id=\"" . $recordId->getIdString() . "\">";
             $parts = $record->getPartsByPartStructure($idManager->getId("dc.title"));
             if ($parts->hasNext()) {
                 $part = $parts->next();
                 $valueObj = $part->getValue();
                 print "\n\t\t\t<title><![CDATA[" . HtmlString::getSafeHtml($valueObj->asString()) . "]]></title>";
             }
             $parts = $record->getPartsByPartStructure($idManager->getId("dc.description"));
             if ($parts->hasNext()) {
                 $part = $parts->next();
                 $valueObj = $part->getValue();
                 print "\n\t\t\t<description><![CDATA[" . HtmlString::getSafeHtml($valueObj->asString()) . "]]></description>";
             }
             $parts = $record->getPartsByPartStructure($idManager->getId("dc.creator"));
             if ($parts->hasNext()) {
                 $part = $parts->next();
                 $valueObj = $part->getValue();
                 print "\n\t\t\t<creator><![CDATA[" . HtmlString::getSafeHtml($valueObj->asString()) . "]]></creator>";
             }
             $parts = $record->getPartsByPartStructure($idManager->getId("dc.source"));
             if ($parts->hasNext()) {
                 $part = $parts->next();
                 $valueObj = $part->getValue();
                 print "\n\t\t\t<source><![CDATA[" . HtmlString::getSafeHtml($valueObj->asString()) . "]]></source>";
             }
             $parts = $record->getPartsByPartStructure($idManager->getId("dc.publisher"));
             if ($parts->hasNext()) {
                 $part = $parts->next();
                 $valueObj = $part->getValue();
                 print "\n\t\t\t<publisher><![CDATA[" . HtmlString::getSafeHtml($valueObj->asString()) . "]]></publisher>";
             }
             $parts = $record->getPartsByPartStructure($idManager->getId("dc.date"));
             if ($parts->hasNext()) {
                 $part = $parts->next();
                 $valueObj = $part->getValue();
                 $date = $valueObj->asDate();
                 print "\n\t\t\t<date><![CDATA[";
                 print $date->asString();
                 print "]]></date>";
             }
             print "\n\t\t</dublinCore>";
         }
         print "\n\t\t<permsHtml><![CDATA[";
         print AuthZPrinter::getAZIcon($asset->getId());
         print "]]></permsHtml>";
         print "\n\t</asset>";
         return ob_get_clean();
     } catch (Exception $e) {
         HarmoniErrorHandler::logException($e, 'Segue');
         $this->error($e->getMessage());
     }
 }
 /**
  * Print links for the various functions that are possible to do with this
  * Asset.
  * 
  * @param object Asset $asset The Asset to print the links for.
  * @return void
  * @access public
  * @date 8/6/04
  * @static
  */
 static function printFunctionLinks($asset, $repositoryId = NULL)
 {
     $harmoni = Harmoni::instance();
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $assetId = $asset->getId();
     if ($repositoryId === NULL) {
         $repository = $asset->getRepository();
         $repositoryId = $repository->getId();
     }
     $links = array();
     $actionString = $harmoni->getCurrentAction();
     // Authorization Icon
     print AuthZPrinter::getAZIcon($assetId);
     print " &nbsp; ";
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $asset->getId())) {
         $viewertheme = 'black';
         ob_start();
         print "<a onclick='Javascript:window.open(";
         print '"' . VIEWER_URL . "?&source=";
         print urlencode($harmoni->request->quickURL("exhibitions", "slideshowOutlineXml", array("slideshow_id" => $assetId->getIdString())));
         print '", ';
         print '"_blank", ';
         print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"';
         print ")'>";
         print _("View") . "</a>";
         $links[] = ob_get_contents();
         ob_end_clean();
         // 			$links[] = "<a href='"
         // 					.$harmoni->request->quickURL("exhibitions", "slideshowxml",
         // 						array("slideshow_id" => $assetId->getIdString()))
         // 					."'>"._("view xml (debug)")."</a>";
         // Add the options panel script to the header
         if (!defined('ASSET_PANEL_LOADED')) {
             $outputHandler = $harmoni->getOutputHandler();
             $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<script type='text/javascript' src='" . MYPATH . "/javascript/AssetOptionsPanel.js'></script>" . "\n\t\t<link rel='stylesheet' type='text/css' href='" . MYPATH . "/javascript/AssetOptionsPanel.css' />");
             define('ASSET_PANEL_LOADED', true);
         }
         if (!defined('SLIDESHOW_PANEL_LOADED')) {
             $outputHandler = $harmoni->getOutputHandler();
             $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<script type='text/javascript' src='" . MYPATH . "/javascript/SlideshowOptionsPanel.js'></script>");
             define('SLIDESHOW_PANEL_LOADED', true);
         }
         ob_start();
         $viewerUrl = VIEWER_URL . "?&amp;source=";
         $viewerUrl .= urlencode($harmoni->request->quickURL("exhibitions", "slideshowOutlineXml", array("slideshow_id" => $assetId->getIdString())));
         // 			$viewerUrl .= '&amp;start='.$xmlStart;
         $parents = $asset->getParents();
         $exhibition = $parents->next();
         $exhibitionId = $exhibition->getId();
         print "<a href='#' onclick=\"Javascript:SlideshowOptionsPanel.run('" . $exhibitionId->getIdString() . "', '" . $assetId->getIdString() . "', this, [";
         $toShow = array();
         if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $assetId)) {
             $toShow[] = "'view'";
         }
         if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $assetId)) {
             $toShow[] = "'edit'";
         }
         if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $exhibitionId)) {
             $toShow[] = "'duplicate'";
         }
         if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $assetId)) {
             $deleteParams = array('exhibition_id' => RequestContext::value('exhibition_id'));
             // If we are viewing the asset and we delete it, we can't return
             // to viewing it.
             if (preg_match("/^slideshow\\..*\$/", $actionString) && $harmoni->request->get("slideshow_id") == $assetId->getIdString()) {
                 $harmoni->history->markReturnURL("concerto/slideshow/delete-return", $harmoni->request->mkURL('exhibition', 'browse', $deleteParams));
             } else {
                 $harmoni->history->markReturnURL("concerto/slideshow/delete-return", $harmoni->request->mkURL(null, null, $deleteParams));
             }
             $toShow[] = "'delete'";
         }
         print implode(", ", $toShow);
         print "], '" . $viewerUrl . "'); return false;\">" . _("Options...") . "</a> ";
         $links[] = ob_get_clean();
     }
     // 		if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $asset->getId())) {
     // 			if ($actionString != "exhibitions.browseSlideshow") {
     // 				$links[] = "<a href='".$harmoni->request->quickURL(
     // 					"exhibitions", "browseSlideshow",
     // 					array("asset_id" => $assetId->getIdString())).
     // 					"'>";
     // 				$links[count($links) - 1] .= _("Browse")."</a>";
     // 			} else {
     // 				$links[] = _("Browse");
     // 			}
     // 		}
     //
     // 		if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $asset->getId())) {
     // 			$harmoni->request->startNamespace('modify_slideshow');
     // 			if ($actionString != "exhibitions.modify_slideshow") {
     // 				$links[] = "<a href='".$harmoni->request->quickURL(
     // 					"exhibitions", "modify_slideshow",
     // 					array("slideshow_id" => $assetId->getIdString())).
     // 					"'>";
     // 				$links[count($links) - 1] .= _("Edit")."</a>";
     // 			} else {
     // 				$links[] = _("Edit");
     // 			}
     // 			$harmoni->request->endNamespace();
     // 		}
     //
     // 		if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $asset->getId())) {
     // 			if ($actionString != "exhibitions.delete") {
     // 				$harmoni->history->markReturnURL("concerto/exhibitions/delete-return");
     // 				ob_start();
     // 				print "<a href='Javascript:deleteSlideShow(\"".$assetId->getIdString()."\", \"".$harmoni->request->quickURL("exhibitions", "delete_slideshow", array("exhibition_id" => RequestContext::value('exhibition_id'), "slideshow_id" => $assetId->getIdString()))."\");'";
     // 				print ">";
     // 				print _("Delete")."</a>";
     //
     // 				$links[] = ob_get_contents();
     // 				ob_end_clean();
     //
     // 				print "\n<script type='text/javascript'>\n//<![CDATA[";
     // 				print "\n	function deleteSlideShow(assetId, url) {";
     // 				print "\n		if (confirm(\""._("Are you sure you want to delete this Slide-Show?")."\")) {";
     // 				print "\n			window.location = url;";
     // 				print "\n		}";
     // 				print "\n	}";
     // 				print "\n//]]>\n</script>\n";
     // 			} else {
     // 				$links[] = _("Delete");
     // 			}
     // 		}
     if ($authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $asset->getId())) {
         if ($actionString != "exhibitions.browse_slideshow") {
             $setManager = Services::getService("Sets");
             $parents = $asset->getParents();
             $exhibition = $parents->next();
             $exhibitionId = $exhibition->getId();
             $exhibitionSet = $setManager->getPersistentSet($exhibitionId);
             $position = $exhibitionSet->getPosition($assetId);
             $url = $harmoni->request->quickURL("exhibitions", "reorder_slideshows", array("exhibition_id" => $exhibitionId->getIdString(), "slideshow_id" => $assetId->getIdString(), "new_position" => "XXXXXX"));
             ob_start();
             print "\n<select name='reorder_" . $assetId->getIdString() . "'";
             print " onchange='";
             print ' var url = "' . str_replace("&amp;", "&", $url) . '"; ';
             print 'window.location = url.replace(/XXXXXX/, this.value);';
             print "'>";
             for ($i = 0; $i < $exhibitionSet->count(); $i++) {
                 print "\n\t<option value='" . $i . "'";
                 if ($i == $position) {
                     print " selected='selected'";
                 }
                 print ">" . ($i + 1) . "</option>";
             }
             print "\n</select>";
             $links[] = ob_get_clean();
         }
     }
     print implode("\n\t | ", $links);
 }
 /**
  * Answer the HTML for the controls top-bar
  * 
  * @param <##>
  * @return <##>
  * @access public
  * @since 4/7/06
  */
 function getControlsHTML(SiteComponent $siteComponent, $title, $controlsHTML, $borderColor, $backgroundColor, $dividerColor, $leftIndentLevel = 0, $borderWidth = '0px', $selectionLinkHtml = null)
 {
     $halfLineWidth = 1;
     $lineWidth = $halfLineWidth * 2 . 'px';
     $halfLineWidth = $halfLineWidth . 'px';
     $opacityStyles = "filter:alpha(opacity=70); " . "-moz-opacity: .70; " . "opacity: .70; ";
     ob_start();
     print "\n<div class='controls_bar' " . "id='controls_bar__" . $siteComponent->getId() . "' " . "style='" . "color: #000; " . "min-width: 150px; " . "border-top: {$borderWidth} solid {$borderColor}; " . "border-left: {$borderWidth} solid {$borderColor}; " . "border-right: {$borderWidth} solid {$borderColor}; " . ($leftIndentLevel ? "margin-left: 10px; " : "");
     if (!$this->controlsAlwaysVisible()) {
         print "visibility: hidden; ";
     }
     // 		print "position: absolute; ";
     // 		print "z-index: 10; ";
     print "left: 0px; ";
     print "'";
     // 		print " onmouseover='showControlsLink(this)'"
     // 			." onmouseout='hideControlsLink(this)'";
     // Any clicks on the page will hide all options panels.
     // Prevent clicks within the panel from hiding it.
     print " onclick='";
     print "if (event.stopPropagation) { ";
     print "event.stopPropagation(); ";
     print "} else if (window.event) { ";
     print "window.event.cancelBubble = true; ";
     print "}";
     print "'";
     print ">";
     print "\n<table border='0' cellpadding='0' cellspacing='0'" . " style='width: 100%; padding: 0px; margin: 0px; " . "background-color: {$backgroundColor}; " . $opacityStyles . "'" . ">";
     print "\n\t<tr>";
     print "\n\t\t<td class='controls_bar_title'>";
     print "\n\t\t" . $title;
     print "\n\t\t</td>";
     print "\n\t\t<td style='text-align: right;'>";
     print AuthZPrinter::getAZIcon($siteComponent->getQualifierId());
     if (!is_null($selectionLinkHtml)) {
         print "\n\t\t\t\t<span class='selection_link'" . " style='" . "cursor: pointer; white-space: nowrap;'" . ">";
         print $selectionLinkHtml;
         print " |</span>";
     }
     print "\n\t\t\t\t<span class='controls_link'" . " style='" . "cursor: pointer; white-space: nowrap;'" . " onclick='toggleControls(this.parentNode.parentNode.parentNode.parentNode.parentNode);'" . ">";
     print "\n\t\t\t" . _("Options");
     print "\n\t\t\t</span>";
     print "\n\t\t</td>";
     print "\n\t</tr>";
     print "\n</table>";
     $opacityStyles = "filter:alpha(opacity=95); " . "-moz-opacity: .95; " . "opacity: .95; ";
     print "\n\t\t\t<div class='controls' style='display: none; border-top: 1px solid {$dividerColor}; background-color: {$backgroundColor}; " . $opacityStyles . " position: absolute; left: 0px; z-index: 10; text-align: left;' ";
     print ">";
     print $controlsHTML;
     print "\n\t\t\t\t</div>";
     print "\n</div>";
     // 		if (!$float) {
     // 			print "\n<div style='display: block;' class='controls_spacer'>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;</div>";
     // 		}
     return ob_get_clean();
 }
 /**
  * Print links for the various functions that are possible to do with this
  * Asset.
  * 
  * @param object Asset $asset The Asset to print the links for.
  * @return void
  * @access public
  * @date 8/6/04
  * @static
  */
 static function printAssetFunctionLinks($harmoni, $asset, $repositoryId = NULL, $assetNum = 0, $includeEditDelete = true)
 {
     $actionString = $harmoni->getCurrentAction();
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $assetId = $asset->getId();
     $repository = $asset->getRepository();
     $repositoryId = $repository->getId();
     $links = array();
     /*********************************************************
      * Parameters to pass on through our links
      *********************************************************/
     $params = self::getUrlParams($asset);
     // Authorization Icon
     print AuthZPrinter::getAZIcon($assetId);
     print " &nbsp; ";
     //===== View Links =====/
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $assetId);
     } catch (UnknownIdException $e) {
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         //===== Viewer Link =====//
         // Add the options panel script to the header
         // Add the options panel script to the header
         if (!defined('ASSET_PANEL_LOADED')) {
             $outputHandler = $harmoni->getOutputHandler();
             $outputHandler->setHead($outputHandler->getHead() . "\n\t\t<script type='text/javascript' src='" . MYPATH . "/javascript/AssetOptionsPanel.js'></script>" . "\n\t\t<link rel='stylesheet' type='text/css' href='" . MYPATH . "/javascript/AssetOptionsPanel.css' />");
             define('ASSET_PANEL_LOADED', true);
         }
         ob_start();
         print "<a href='#' onclick=\"Javascript:AssetOptionsPanel.run('" . $repositoryId->getIdString() . "', '" . $assetId->getIdString() . "', this, [";
         $toShow = array();
         try {
             $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             $toShow[] = "'view'";
         }
         try {
             $isAuthorized = $authZ->isUserAuthorizedBelow($idManager->getId("edu.middlebury.authorization.view"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             try {
                 $children = $asset->getAssets();
                 if ($children->hasNext()) {
                     if ($actionString != "asset.browse" || $assetId->getIdString() != $harmoni->request->get('asset_id')) {
                         $toShow[] = "'browse'";
                     }
                 }
             } catch (Exception $e) {
             }
         }
         try {
             $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             $harmoni->history->markReturnURL("concerto/asset/edit-return");
             $toShow[] = "'edit'";
         }
         try {
             $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             // If we are viewing the asset and we delete it, we can't return
             // to viewing it.
             if (preg_match("/^asset\\..*\$/", $actionString) && $harmoni->request->get("asset_id") == $assetId->getIdString()) {
                 $deleteParams = $params;
                 unset($deleteParams['asset_id']);
                 $harmoni->history->markReturnURL("concerto/asset/delete-return", $harmoni->request->mkURL('collection', 'browse', $deleteParams));
             } else {
                 $harmoni->history->markReturnURL("concerto/asset/delete-return", $harmoni->request->mkURL(null, null, $params));
             }
             $toShow[] = "'delete'";
         }
         try {
             $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $assetId);
         } catch (UnknownIdException $e) {
             $isAuthorized = true;
         }
         if ($isAuthorized) {
             $toShow[] = "'add_children'";
         }
         print implode(", ", $toShow);
         print "], '" . self::getSlideshowLink($asset, $assetNum) . "'); return false;\">" . _("Options...") . "</a> ";
         $links[] = ob_get_clean();
         //===== Details Link =====//
         // 			if ($actionString != "asset.view") {
         // 				$links[] = "<a href='".$harmoni->request->quickURL(
         // 					"asset", "view",
         // 					array("collection_id" => $repositoryId->getIdString(),
         // 					"asset_id" => $assetId->getIdString()))."'>";
         // 				$links[count($links) - 1] .= _("Details")."</a>";
         // 			} else
         // 				$links[] = _("Details");
         //===== Export Link =====//
         // 			if (preg_match("/^asset\..*$/", $actionString) &&
         // 					$harmoni->request->get("asset_id") ==
         // 					$assetId->getIdString()) {
         // 				$harmoni->request->startNamespace('export');
         // 				$links[] = "<a href='".$harmoni->request->quickURL(
         // 					"asset", "export",
         // 					array("collection_id" => $repositoryId->getIdString(),
         // 					"asset_id" => $assetId->getIdString()))."'>";
         // 				$links[count($links) - 1] .= _("Export")."</a>";
         // 				$harmoni->request->endNamespace();
         // 			}
     }
     //===== Browse Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorizedBelow($idManager->getId("edu.middlebury.authorization.view"), $assetId);
     } catch (UnknownIdException $e) {
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         try {
             $children = $asset->getAssets();
             if ($children->hasNext()) {
                 if ($actionString != "asset.browse" || $assetId->getIdString() != $harmoni->request->get('asset_id')) {
                     $links[] = "<a href='" . $harmoni->request->quickURL("asset", "browseAsset", array("collection_id" => $repositoryId->getIdString(), "asset_id" => $assetId->getIdString())) . "'>";
                     $links[count($links) - 1] .= _("Browse") . "</a>";
                 } else {
                     $links[] = _("Browse");
                 }
             }
         } catch (UnimplementedException $e) {
             //
         }
     }
     //===== Edit Link =====//
     // 		$harmoni->history->markReturnURL("concerto/asset/edit-return",
     // 			$harmoni->request->mkURL(null, null, $params));
     //
     // 		if ($includeEditDelete) {
     // 			if ($authZ->isUserAuthorized(
     // 					$idManager->getId("edu.middlebury.authorization.modify"),
     // 					$assetId)) {
     // 				if ($actionString != "asset.edit") {
     // 					$links[] = "<a href='".$harmoni->request->quickURL(
     // 						"asset", "edit",
     // 						array("collection_id" => $repositoryId->getIdString(),
     // 						"assets" => $assetId->getIdString()))."'>";
     // 					$links[count($links) - 1] .= _("Edit")."</a>";
     // 				} else
     // 					$links[] = _("Edit");
     // 			}
     //===== Delete Link =====//
     // 			if ($authZ->isUserAuthorized(
     // 					$idManager->getId("edu.middlebury.authorization.delete"),
     // 					$assetId))
     // 			{
     // 				// If we are viewing the asset and we delete it, we can't return
     // 				// to viewing it.
     // 				if (preg_match("/^asset\..*$/", $actionString) &&
     // 						$harmoni->request->get("asset_id") ==
     // 						$assetId->getIdString())
     // 				{
     // 					$deleteParams = $params;
     // 					unset ($deleteParams['asset_id']);
     // 					$harmoni->history->markReturnURL("concerto/asset/delete-return",
     // 						$harmoni->request->mkURL('collection', 'browse', $deleteParams));
     // 				}
     // 				// otherwise, go bact to where we are.
     // 				else {
     // 					$harmoni->history->markReturnURL("concerto/asset/delete-return",
     // 						$harmoni->request->mkURL(null, null, $params));
     // 				}
     // 				ob_start();
     // 				print "<a href='Javascript:deleteAsset(\"".$assetId->getIdString().
     // 					"\", \"".$repositoryId->getIdString()."\", \"".
     // 					$harmoni->request->quickURL("asset", "delete",
     // 					array("collection_id" => $repositoryId->getIdString(),
     // 					"asset_id" => $assetId->getIdString()))."\");'>";
     // 				print _("Delete")."</a>";
     // 				$links[] = ob_get_contents();
     // 				ob_end_clean();
     //
     // 				print "\n<script type='text/javascript'>\n//<![CDATA[";
     // 				print "\n	function deleteAsset(assetId, repositoryId, url) {";
     // 				print "\n		if (confirm(\""._("Are you sure you want to delete this Asset?")."\")) {";
     // 				print "\n			window.location = url;";
     // 				print "\n		}";
     // 				print "\n	}";
     // 				print "\n//]]>\n</script>\n";
     // 			}
     //===== Add Child Asset Link =====//
     // 			if ($authZ->isUserAuthorized(
     // 					$idManager->getId("edu.middlebury.authorization.add_children"),
     // 					$assetId)) {
     // 				if (preg_match("/^asset\..*$/", $actionString) &&
     // 						$harmoni->request->get("asset_id") ==
     // 						$assetId->getIdString()) {
     // 					$links[] = "<a href='".$harmoni->request->quickURL(
     // 						"asset", "add",
     // 						array("collection_id" => $repositoryId->getIdString(),
     // 						"parent" => $assetId->getIdString()))."'>";
     // 					$links[count($links) - 1] .= _("Add Child <em>Asset</em>").
     // 						"</a>";
     // 		//===== Import Link =====//
     // 	// 				$harmoni->request->startNamespace("import");
     // 	// 				$links[] = "<a href='".$harmoni->request->quickURL(
     // 	// 					"asset", "import",
     // 	// 					array("collection_id" => $repositoryId->getIdString(),
     // 	// 					"asset_id" => $assetId->getIdString()))."'>".
     // 	// 					_("Import Child <em>Asset(s)</em>")."</a>";
     // 	// 				$harmoni->request->endNamespace();
     // 				}
     // 			}
     // 		}
     //===== Basket Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $assetId);
     } catch (UnknownIdException $e) {
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         $basket = Basket::instance();
         $links[] = $basket->getAddLink($assetId);
     }
     print implode("\n\t | ", $links);
 }
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 . "?&amp;source=";
    print urlencode($harmoni->request->quickURL('exhibitions', "slideshowOutlineXml", array('slideshow_id' => $slideshowIdString)));
    print '&amp;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;
}
 /**
  * Print links for the various functions that are possible to do with this
  * Repository.
  * 
  * @param object Repository $repository The Repository to print the links for.
  * @return void
  * @access public
  * @date 8/6/04
  * @static
  */
 static function printRepositoryFunctionLinks($harmoni, $repository)
 {
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     $repositoryId = $repository->getId();
     $links = array();
     $actionString = $harmoni->getCurrentAction();
     $url = $harmoni->request->mkURL();
     $url->setValue("collection_id", $repositoryId->getIdString());
     // Authorization Icon
     print AuthZPrinter::getAZIcon($repositoryId);
     print " &nbsp; ";
     //===== Browse Link =====//
     try {
         // 			$isAuthorized = $authZ->isUserAuthorizedBelow(
         // 				$idManager->getId("edu.middlebury.authorization.view"),
         // 				$repositoryId);
         // Checking down the hierarchy is taking WAY too long for large data sets.
         // Maybe this can be renabled if better authorization implementations come up.
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $repositoryId);
     } catch (UnknownIdException $e) {
         // For non-Harmoni repositories, return true.
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         if ($actionString != "collection.browse") {
             $url->setModuleAction("collection", "browse");
             $links[] = "<a href='" . $url->write() . "'>";
             $links[count($links) - 1] .= _("Browse") . "</a>";
         } else {
             $links[] = _("Browse");
         }
         //===== TypeBrowse Link =====//
         // 			if ($actionString != "collection.typebrowse") {
         // 				$url->setModuleAction("collection", "typebrowse");
         // 				$links[] = "<a href='".$url->write()."'>";
         // 				$links[count($links) - 1] .= _("Browse by Type")."</a>";
         // 			} else {
         // 				$links[] = _("Browse by Type");
         // 			}
         //	//===== Search Link =====//
         // 			if ($actionString != "collection.search") {
         // 				$url->setModuleAction("collection", "search");
         // 				$links[] = "<a href='".$url->write()."'>";
         // 				$links[count($links) - 1] .= _("Search")."</a>";
         // 			} else {
         // 				$links[] = _("search");
         // 			}
     }
     //===== Add Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $repositoryId);
     } catch (UnknownIdException $e) {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.add_children"), $idManager->getId("edu.middlebury.authorization.root"));
     }
     if ($isAuthorized) {
         $url->setModuleAction("asset", "create");
         $links[] = "<a href='" . $url->write() . "'>";
         $links[count($links) - 1] .= _("Add") . "</a>";
         //===== Import Link =====//
         $harmoni->request->startNamespace("import");
         $links[] = "<a href='" . $harmoni->request->quickURL("collection", "import", array("collection_id" => $repositoryId->getIdString())) . "'>";
         $links[count($links) - 1] .= _("Import") . "</a>";
         $harmoni->request->endNamespace();
     }
     //===== Export Link =====//
     try {
         // 			$isAuthorized = $authZ->isUserAuthorizedBelow(
         // 				$idManager->getId("edu.middlebury.authorization.view"),
         // 				$repositoryId);
         // Checking down the hierarchy is taking WAY too long for large data sets.
         // Maybe this can be renabled if better authorization implementations come up.
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view"), $repositoryId);
     } catch (UnknownIdException $e) {
         // For non-Harmoni repositories, return true.
         $isAuthorized = true;
     }
     if ($isAuthorized) {
         $harmoni->request->startNamespace('export');
         $links[] = "<a href='" . $harmoni->request->quickURL("collection", "export", array("collection_id" => $repositoryId->getIdString())) . "'>";
         $links[count($links) - 1] .= _("Export") . "</a>";
         $harmoni->request->endNamespace();
     }
     //===== Edit Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $repositoryId);
     } catch (UnknownIdException $e) {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $idManager->getId("edu.middlebury.authorization.root"));
     }
     if ($isAuthorized) {
         $params = array("collection_id" => $repositoryId->getIdString(), RequestContext::name("starting_number") => RequestContext::value("starting_number"), RequestContext::name("limit_by") => RequestContext::value("limit_by"), RequestContext::name("type") => RequestContext::value("type"), RequestContext::name("searchtype") => RequestContext::value("searchtype"));
         if (RequestContext::value("searchtype")) {
             $searchModuleManager = Services::getService("RepositorySearchModules");
             foreach ($searchModuleManager->getCurrentValues(HarmoniType::fromString(RequestContext::value("searchtype"))) as $key => $value) {
                 $params[$key] = $value;
             }
         }
         $harmoni->history->markReturnURL("concerto/collection/edit-return", $harmoni->request->mkURL(null, null, $params));
         $url->setModuleAction("collection", "edit");
         $links[] = "<a href='" . $url->write() . "'>";
         $links[count($links) - 1] .= _("Edit") . "</a>";
     }
     //===== Edit Schemas =====//
     // Check that the user can modify Schemas for this collection
     $recStructFunctions = $authZ->getFunctions(new Type("Authorization", "edu.middlebury.harmoni", "RecordStructures"));
     $canEditStructures = false;
     while ($recStructFunctions->hasNext()) {
         $function = $recStructFunctions->next();
         try {
             if ($authZ->isUserAuthorized($function->getId(), $repositoryId)) {
                 $canEditStructures = true;
             }
         } catch (UnknownIdException $e) {
             // do nothing;
         }
         if ($authZ->isUserAuthorized($function->getId(), $idManager->getId("edu.middlebury.authorization.root"))) {
             $canEditStructures = true;
         }
     }
     if ($canEditStructures) {
         // Schema Editing
         ob_start();
         print "\n<select";
         print " onchange=\"var url = '";
         print $harmoni->request->quickURL("schema", "edit", array("collection_id" => $repositoryId->getIdString(), "recordstructure_id" => "XXXXXXXX"));
         print "'; ";
         print "url = url.replace(/XXXXXXXX/, this.value); ";
         print "url = url.urlDecodeAmpersands(); ";
         print "if (this.value) { ";
         print "window.location = url; ";
         print "} ";
         print "\">";
         print "\n\t<option value=''>" . _("Edit Schema...") . "</option>";
         $localStructures = '';
         $globalStructures = '';
         $fileId = $idManager->getId("FILE");
         $remoteFileId = $idManager->getId("REMOTE_FILE");
         $setManager = Services::getService("Sets");
         $set = $setManager->getPersistentSet($repositoryId);
         $set->reset();
         while ($set->hasNext()) {
             $recStructId = $set->next();
             if (!$recStructId->isEqual($fileId) && !$recStructId->isEqual($remoteFileId)) {
                 ob_start();
                 $recStruct = $repository->getRecordStructure($recStructId);
                 $harmoni->history->markReturnURL("concerto/schema/edit-return/" . $recStructId->getIdString());
                 print "\n\t\t<option value='" . $recStructId->getIdString() . "'";
                 print ">";
                 print $recStruct->getDisplayName();
                 print "</option>";
                 if (preg_match("/^Repository::.+\$/i", $recStructId->getIdString())) {
                     $localStructures .= ob_get_clean();
                 } else {
                     $globalStructures .= ob_get_clean();
                 }
             }
         }
         print "\n\t<optgroup label='" . _("Local Schemas") . "'>";
         print $localStructures;
         print "\n\t</optgroup>";
         print "\n\t<optgroup label='" . _("Global Schemas") . "'>";
         print $globalStructures;
         print "\n\t</optgroup>";
         print "\n</select>";
         $links[] = ob_get_clean();
     }
     //===== Delete Link =====//
     try {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $repositoryId);
     } catch (UnknownIdException $e) {
         $isAuthorized = $authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete"), $idManager->getId("edu.middlebury.authorization.root"));
     }
     if ($isAuthorized) {
         ob_start();
         print "<a href='Javascript:deleteRepository(\"" . $repositoryId->getIdString() . "\", \"" . $harmoni->request->quickURL("collection", "delete", array("collection_id" => $repositoryId->getIdString())) . "\");'>";
         print _("Delete") . "</a>";
         $links[] = ob_get_contents();
         ob_end_clean();
         print "\n<script type='text/javascript'>\n//<![CDATA[";
         print "\n\tfunction deleteRepository(repositoryId, url) {";
         print "\n\t\tif (confirm(\"" . _("Are you sure you want to delete this Collection and all of its Assets?") . "\") && confirm(\"" . _("Clicking OK will permenantly delete this Collection and all of the Assets in it.\\nAre you REALLY sure you want to delete this Collection and all of its Assets?") . "\")) {";
         print "\n\t\t\twindow.location = url;";
         print "\n\t\t}";
         print "\n\t}";
         print "\n//]]>\n</script>\n";
     }
     print implode("\n\t | ", $links);
 }
 /**
  * Answer controls for NavBlock SiteComponents
  * 
  * @param SiteComponent $siteComponent
  * @return string
  * @access public
  * @since 4/17/06
  */
 public function visitNavBlock(NavBlockSiteComponent $siteComponent)
 {
     $this->controlsStart($siteComponent);
     $controls = array();
     if ($control = $this->getSelectionAdd($siteComponent)) {
         $controls[] = $control;
     }
     if ($control = $this->getReorder($siteComponent)) {
         $controls[] = $control;
     }
     if ($control = $this->getMove($siteComponent)) {
         $controls[] = $control;
     }
     if ($control = $this->getEdit($siteComponent, 'editNav')) {
         $controls[] = $control;
     }
     if ($siteComponent->isSection()) {
         if ($control = $this->getDelete($siteComponent, _("Section"))) {
             $controls[] = $control;
         }
     } else {
         if ($control = $this->getDelete($siteComponent, _("Page"))) {
             $controls[] = $control;
         }
     }
     // 		if ($control = $this->getHistory($siteComponent))
     // 			$controls[] = $control;
     // 		if ($control = $this->getAddSubMenu($siteComponent))
     // 			$controls[] = $control;
     if ($control = AuthZPrinter::getAZIcon($siteComponent->getQualifierId())) {
         $controls[] = $control;
     }
     print implode($this->getDelimiter($siteComponent), $controls);
     return $this->controlsEnd($siteComponent);
 }