function printAssetShort($asset, $harmoni)
{
    ob_start();
    $assetId = $asset->getId();
    print "\n\t<strong>" . $asset->getDisplayName() . "</strong> - " . _("ID#") . ": " . $assetId->getIdString();
    $description = HtmlString::withValue($asset->getDescription());
    $description->trim(25);
    print "\n\t<div style='font-size: smaller;'>" . $description->asString() . "</div>";
    AssetPrinter::printAssetFunctionLinks($harmoni, $asset);
    $layout = new Block(ob_get_contents(), 3);
    ob_end_clean();
    return $layout;
}
function printAssetShort($asset, $harmoni)
{
    ob_start();
    $assetId = $asset->getId();
    print "\n\t<strong>" . $asset->getDisplayName() . "</strong> - " . _("ID#") . ": " . $assetId->getIdString();
    print "\n\t<br /><em>" . $asset->getDescription() . "</em>";
    print "\n\t<br />";
    AssetPrinter::printAssetFunctionLinks($harmoni, $asset);
    $layout = new Block(ob_get_contents(), 4);
    ob_end_clean();
    return $layout;
}
Example #3
0
 /**
  * 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);
 }
Example #4
0
 /**
  * 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) {
     }
 }
Example #5
0
 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;
 }