/**
  * Returns a block of XHTML-valid code that contains markup for this specific
  * component. 
  * @param string $fieldName The field name to use when outputting form data or
  * similar parameters/information.
  * @access public
  * @return string
  */
 function getMarkup($fieldName)
 {
     ob_start();
     if (is_object($this->_id)) {
         $repositoryManager = Services::getService('Repository');
         try {
             $asset = $repositoryManager->getAsset($this->_id);
             print "\n<table border='0'>";
             print "\n\t<tr>\n\t\t<td>";
             $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($this->_id);
             if ($thumbnailURL !== FALSE) {
                 //				print "\n\t<br /><a href='".$assetViewUrl."'>";
                 print "\n\t\t<img src='{$thumbnailURL}' alt='Thumbnail Image' class='thumbnail_image' />";
                 //				print "\n\t</a>";
             }
             print "\n\t\t</td>\n\t\t</tr>";
             print "\n\t<tr>\n\t\t<td>";
             print _("Id: ") . $this->_id->getIdString();
             print "\n\t\t</td>\n\t\t</tr>";
             print "\n\t<tr>\n\t\t<td>";
             print _("Name: ") . $asset->getDisplayName();
             print "\n\t\t</td>\n\t\t</tr>";
             print "\n</table>";
         } catch (UnknownIdException $e) {
             print "\n<div style='margin: 10px; padding: 10px; border: 1px dotted;'>";
             print _("The target Asset has been deleted or is no longer available.");
             print "</div>";
         }
     }
     $m = ob_get_contents();
     ob_end_clean();
     return $m;
 }
示例#2
0
 /**
  * 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;
 }
function printAssetShort($asset, $harmoni)
{
    $idManager = Services::getService("Id");
    $harmoni = Harmoni::instance();
    /*********************************************************
     * 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 = browse_exhibitionAction::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);
                }
            }
        }
    }
    $assetId = $asset->getId();
    ob_start();
    if (isset($firstMediaUrl) && $firstMediaUrl) {
        print "<a href='#' onclick='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 "); return false;'>";
        print "\n<img src='" . $firstMediaUrl . "' style='float: right; max-height: 200px; max-width: 200px;' class='thumbnail_image'/>";
        print "</a>";
    }
    print "\n\t<div style='font-weight: bold' title='" . _("ID#") . ": " . $assetId->getIdString() . "'>" . $asset->getDisplayName() . "</div>";
    print "\n\t<div style='font-size: smaller; margin-bottom: 10px; margin-left: 20px; margin-right: 20px; white-space: nowrap;'>(" . $count . " " . _("slides") . ")</div>";
    $description = HtmlString::withValue($asset->getDescription());
    $description->clean();
    print "\n\t<div style='font-size: smaller;'>" . $description->asString() . "</div>";
    print "\n<div style='clear: both; white-space: nowrap;'>";
    SlideShowPrinter::printFunctionLinks($asset);
    print "</div>";
    $layout = new Block(ob_get_contents(), EMPHASIZED_BLOCK);
    ob_end_clean();
    return $layout;
}
示例#4
0
 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 4/26/05
  */
 function outputContent()
 {
     $defaultTextDomain = textdomain("polyphony");
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $harmoni->request->startNamespace("polyphony-repository");
     $size = RequestContext::value("size");
     $websafe = RequestContext::value("websafe");
     // See if we are passed a size
     if (is_numeric($size)) {
         $size = intval($size);
     } else {
         $size = FALSE;
     }
     if ($websafe) {
         $websafe = TRUE;
     } else {
         $websafe = FALSE;
     }
     if (RequestContext::value('attachment')) {
         $attachment = true;
     } else {
         $attachment = false;
     }
     // Get the requested record.
     try {
         $asset = $this->getAsset();
         try {
             $recordId = $idManager->getId(RequestContext::value("record_id"));
             $record = $asset->getRecord($recordId);
         } catch (InvalidArgumentException $e) {
             // If no record id is specified, use the first file record available
             $record = RepositoryInputOutputModuleManager::getFirstImageOrFileRecordForAsset($asset);
             if (!$record) {
                 throw $e;
             }
         } catch (UnknownIdException $e) {
             // If no record id is specified, use the first file record available
             $record = RepositoryInputOutputModuleManager::getFirstImageOrFileRecordForAsset($asset);
             if (!$record) {
                 throw $e;
             }
         }
     } catch (UnknownIdException $e) {
         HarmoniErrorHandler::logException($e);
         $this->getUnknownIdMessage();
     }
     // Make sure that the structure is the right one.
     $structure = $record->getRecordStructure();
     $remoteFileId = $idManager->getId('REMOTE_FILE');
     $fileId = $idManager->getId('FILE');
     if ($remoteFileId->isEqual($structure->getId())) {
         $urlParts = $record->getPartsByPartStructure($idManager->getId("FILE_URL"));
         $urlPart = $urlParts->next();
         header("Location: " . $urlPart->getValue());
     } else {
         if (!$fileId->isEqual($structure->getId())) {
             try {
                 throw new Exception("The requested record is not of the FILE structure, and therefore cannot be displayed.");
             } catch (Exception $e) {
                 HarmoniErrorHandler::logException($e);
                 $this->getUnknownIdMessage();
             }
         } else {
             // Get the parts for the record.
             $partIterator = $record->getParts();
             $parts = array();
             while ($partIterator->hasNext()) {
                 $part = $partIterator->next();
                 $partStructure = $part->getPartStructure();
                 $partStructureId = $partStructure->getId();
                 $parts[$partStructureId->getIdString()] = $part;
             }
             $imgProcessor = Services::getService("ImageProcessor");
             // If we want to (and can) resize the file, do so
             if (($size || $websafe) && $imgProcessor->isFormatSupported($parts['MIME_TYPE']->getValue())) {
                 $imageCache = new RepositoryImageCache($record->getId(), $size, $websafe, $parts);
                 header("Content-Type: " . $imageCache->getCachedMimeType());
                 if ($attachment) {
                     header('Content-Disposition: attachment; filename="' . $imageCache->getCachedFileName() . '"');
                 } else {
                     header('Content-Disposition: filename="' . $imageCache->getCachedFileName() . '"');
                 }
                 $data = $imageCache->getCachedImageData();
                 header('Content-Length: ' . strlen($data));
                 print $data;
             } else {
                 header("Content-Type: " . $parts['MIME_TYPE']->getValue());
                 $filename = $parts['FILE_NAME']->getValue();
                 if (!preg_match("/[^\\w]/", $filename)) {
                     $mime = Services::getService("MIME");
                     $extension = $mime->getExtensionForMIMEType($parts['MIME_TYPE']->getValue());
                     $filename = _("Untitled") . "." . $extension;
                 }
                 if ($attachment) {
                     header('Content-Disposition: attachment; filename="' . $filename . '"');
                 } else {
                     header('Content-Disposition: filename="' . $filename . '"');
                 }
                 $data = $parts['FILE_DATA']->getValue();
                 header('Content-Length: ' . strlen($data));
                 print $data;
             }
         }
     }
     $harmoni->request->endNamespace();
     textdomain($defaultTextDomain);
     exit;
 }
示例#5
0
    /**
     * Answer the XHTML string of the small version of the basket contents
     * 
     * @param <##>
     * @return <##>
     * @access public
     * @since 5/2/06
     */
    function getSmallBasketHtml()
    {
        $this->addHeadJavascript();
        $harmoni = Harmoni::instance();
        $harmoni->request->startNamespace("basket");
        $this->clean();
        ob_start();
        print "\n\t<a href='";
        print $harmoni->request->quickURL("basket", "view");
        print "'>";
        print _("Selection: ");
        print "(" . $this->count() . " " . _("items") . ")";
        print "</a>";
        print "\n\t<div id='basket_small_contents' style='text-align: left; min-width: 200px;'>";
        $this->reset();
        $i = 0;
        if ($this->hasNext()) {
            while ($this->hasNext()) {
                $id = $this->next();
                $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($id);
                if ($thumbnailURL !== FALSE) {
                    print "\n\t<div style='border: 1px solid; height: 60px; width: 60px; float: left; text-align: center; vertical-align: middle; padding: 0px; margin: 2px;'>";
                    //  The image
                    print "\n\t\t<img class='thumbnail_image' \n\t\t\tsrc='{$thumbnailURL}' \n\t\t\talt='Thumbnail Image'";
                    print " \n\t\t\tstyle='max-height: 50px; max-width: 50px; vertical-align: middle; margin: 5px; cursor: pointer;'";
                    // border removal
                    print " \n\t\t\tonload=\"if (this.parentNode) { this.parentNode.style.border='0px'; this.parentNode.style.margin='3px'; } /* Resize images for IE */ if (this.height > 50 || this.width > 50) {this.width = 50;}\" ";
                    // Viewer Link
                    print " \n\t\t\tonclick='window.open(";
                    print '"' . VIEWER_URL . "?&amp;source=";
                    print urlencode($harmoni->request->quickURL("basket", "browse_xml"));
                    print '&amp;start=' . $i . '", ';
                    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/>";
                    print "\n\t</div>";
                    $i++;
                }
            }
        }
        print "\n\t</div>";
        print <<<END
\t
\t<script type='text/javascript'>
\t// <![CDATA[
\t
\t\tBasket.removeBorders();
\t
\t// ]]>
\t</script>
\t\t
END;
        if ($this->count()) {
            print "\n\t<div style='text-align: right; font-size: small; clear: both;'>";
            print "<a onclick='Basket.empty()'>" . _("Empty") . "</a>";
            print "\n\t</div>";
        }
        $harmoni->request->endNamespace();
        return ob_get_clean();
    }
 /**
  * Answer true if the Asset or AssetId has a thumbnail rather than a default Icon
  * 
  * @param mixed object Asset Id $assetOrID
  * @return boolean
  * @access public
  * @since 12/4/06
  * @static
  */
 static function hasThumbnailNotIcon($assetOrId)
 {
     $idManager = Services::getService("IdManager");
     $record = RepositoryInputOutputModuleManager::getFirstImageOrFileRecordForAsset($assetOrId);
     if (!$record) {
         return FALSE;
     }
     // Make sure that the structure is the right one.
     $structure = $record->getRecordStructure();
     $fileId = $idManager->getId('FILE');
     $remoteFileId = $idManager->getId('REMOTE_FILE');
     if (!$fileId->isEqual($structure->getId()) && !$remoteFileId->isEqual($structure->getId())) {
         return FALSE;
     } else {
         // Get the parts for the record.
         $partIterator = $record->getParts();
         $parts = array();
         while ($partIterator->hasNext()) {
             $part = $partIterator->next();
             $partStructure = $part->getPartStructure();
             $partStructureId = $partStructure->getId();
             $parts[$partStructureId->getIdString()] = $part;
         }
         // If we have a thumbnail, print that.
         if ($parts['THUMBNAIL_MIME_TYPE']->getValue()) {
             return TRUE;
         } else {
             return FALSE;
         }
     }
 }
示例#7
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());
     }
 }
示例#8
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);
 }
 /**
  * Create a new Wizard for this action. Caching of this Wizard is handled by
  * {@link getWizard()} and does not need to be implemented here.
  * 
  * @return object Wizard
  * @access public
  * @since 4/28/05
  */
 function createWizard()
 {
     $harmoni = Harmoni::instance();
     // Instantiate the wizard, then add our steps.
     $wizard = SimpleStepWizard::withDefaultLayout();
     /*********************************************************
      * Asset thumbnails: Generate a text string and attach to
      * the wizard for later retrieval.
      *********************************************************/
     ob_start();
     $assetIds = array();
     for ($i = 0; $i < count($this->_assets); $i++) {
         $asset = $this->_assets[$i];
         $assetId = $asset->getId();
         $assetIds[] = $assetId->getIdString();
     }
     $params = array();
     $params["assetIds"] = implode(",", $assetIds);
     for ($i = 0; $i < count($this->_assets) && $i < 10; $i++) {
         $asset = $this->_assets[$i];
         $assetId = $asset->getId();
         $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($asset);
         if ($thumbnailURL !== FALSE) {
             $thumbSize = "100px";
             print "\n<div style='height: {$thumbSize}; width: {$thumbSize}; margin: auto; float: left; text-align: center;'>";
             print "\n\t\t<img src='{$thumbnailURL}' class='thumbnail thumbnail_image' alt='Thumbnail Image' border='0'";
             print " onclick='Javascript:window.open(";
             print '"' . VIEWER_URL . "?&amp;source=";
             print urlencode($harmoni->request->quickURL('asset', "viewAssetsXml", $params));
             print '&amp;start=' . $i . '", ';
             print '"_blank", ';
             print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"';
             print ")'";
             print " style='max-height: {$thumbSize}; max-width: {$thumbSize}; vertical-align: middle; cursor: pointer;'";
             print " />";
             print "\n</div>";
         }
     }
     if ($i < count($this->_assets)) {
         print "\n<div style='height: {$thumbSize}; width: {$thumbSize}; margin: auto; float: left; text-align: center; vertical-align: middle;'>";
         print _(" (and ") . (count($this->_assets) - $i) . _(" more) ");
         print "\n</div>";
     }
     $wizard->assetThumbnails = ob_get_clean();
     /*********************************************************
      * :: Asset Properties ::
      *********************************************************/
     $wizard->addStep("assetproperties", $this->getAssetPropertiesStep());
     /*********************************************************
      *  :: Record Structures ::
      *********************************************************/
     $repository = $this->getRepository();
     $repositoryId = $this->getRepositoryId();
     if (!$repository) {
         throw new Exception("Repository not found");
     }
     // Get the set of RecordStructures so that we can print them in order.
     $setManager = Services::getService("Sets");
     $recStructSet = $setManager->getPersistentSet($repositoryId);
     // File Record Id
     $idManager = Services::getService("Id");
     $fileRecStructId = $idManager->getId('FILE');
     $remoteFileRecStructId = $idManager->getId('REMOTE_FILE');
     // First, lets go through the info structures listed in the set and print out
     // the info records for those structures in order.
     while ($recStructSet->hasNext()) {
         $recStructId = $recStructSet->next();
         if (in_array($recStructId->getIdString(), $this->_recStructsToIgnore)) {
             continue;
         }
         if ($recStructId->isEqual($fileRecStructId)) {
             if ($fileRecordStep = $this->getFileRecordsStep()) {
                 $wizard->addStep("filestep", $fileRecordStep);
             }
         } else {
             if ($recStructId->isEqual($remoteFileRecStructId)) {
                 if ($fileRecordStep = $this->getRemoteFileRecordsStep()) {
                     $wizard->addStep("remotefilestep", $fileRecordStep);
                 }
             } else {
                 $recStruct = $repository->getRecordStructure($recStructId);
                 $wizard->addStep($recStructId->getIdString(), $this->getRecordStructureStep($recStruct));
             }
         }
     }
     /*********************************************************
      *  :: Content ::
      *********************************************************/
     $step = $this->getAssetContentStep();
     if (!is_null($step)) {
         $wizard->addStep("contentstep", $step);
     }
     /*********************************************************
      *  :: Content ::
      *********************************************************/
     $step = $this->getParentStep();
     if (!is_null($step)) {
         $wizard->addStep("parentstep", $step);
     }
     $wizard->initialState = $wizard->getAllValues();
     return $wizard;
 }
示例#10
0
function printAssetShort($asset, $harmoni)
{
    ob_start();
    $assetId = $asset->getId();
    print "\n\t<div style='font-weight: bold' title='" . _("ID#") . ": " . $assetId->getIdString() . "'>" . $asset->getDisplayName() . "</div>";
    $description = HtmlString::withValue($asset->getDescription());
    $description->trim(100);
    print "\n\t<div style='font-size: smaller;'>" . $description->asString() . "</div>";
    ExhibitionPrinter::printFunctionLinks($asset);
    $thumbnailURL = RepositoryInputOutputModuleManager::getThumbnailUrlForAsset($assetId);
    if ($thumbnailURL !== FALSE) {
        print "\n\t<br /><a href='";
        print $harmoni->request->quickURL("asset", "view", array('asset_id' => $assetId->getIdString()));
        print "'>";
        print "\n\t\t<img src='{$thumbnailURL}' alt='Thumbnail Image' class='thumbnail_image' />";
        print "\n\t</a>";
    }
    $layout = new Block(ob_get_contents(), EMPHASIZED_BLOCK);
    ob_end_clean();
    return $layout;
}
示例#11
0
 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 4/26/05
  */
 function outputContent()
 {
     $defaultTextDomain = textdomain("polyphony");
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $harmoni->request->startNamespace("polyphony-repository");
     // Get the requested record.
     try {
         $asset = $this->getAsset();
         if (RequestContext::value("record_id")) {
             $recordId = $idManager->getId(RequestContext::value("record_id"));
             $record = $asset->getRecord($recordId);
         } else {
             $record = RepositoryInputOutputModuleManager::getFirstImageOrFileRecordForAsset($asset);
         }
     } catch (UnknownIdException $e) {
         HarmoniErrorHandler::logException($e);
         $this->getUnknownIdMessage();
     }
     // Make sure that the structure is the right one.
     $structure = $record->getRecordStructure();
     $fileId = $idManager->getId('FILE');
     $remoteFileId = $idManager->getId('REMOTE_FILE');
     if (!$fileId->isEqual($structure->getId()) && !$remoteFileId->isEqual($structure->getId())) {
         try {
             throw new Exception("The requested record is not of the FILE structure, and therefore cannot be displayed.");
         } catch (Exception $e) {
             HarmoniErrorHandler::logException($e);
             $this->getUnknownIdMessage();
         }
     } else {
         // Get the parts for the record.
         $partIterator = $record->getParts();
         $parts = array();
         while ($partIterator->hasNext()) {
             $part = $partIterator->next();
             $partStructure = $part->getPartStructure();
             $partStructureId = $partStructure->getId();
             $parts[$partStructureId->getIdString()] = $part;
         }
         // If we have a thumbnail, print that.
         if ($parts['THUMBNAIL_MIME_TYPE']->getValue()) {
             header("Content-Type: " . $parts['THUMBNAIL_MIME_TYPE']->getValue());
             $mime = Services::getService("MIME");
             $extension = $mime->getExtensionForMIMEType($parts['THUMBNAIL_MIME_TYPE']->getValue());
             $filename = $parts['FILE_NAME']->getValue();
             if (!$filename) {
                 $filename = _("Untitled");
             }
             header('Content-Disposition: filename="' . $filename . "." . $extension . '"');
             print $parts['THUMBNAIL_DATA']->getValue();
         } else {
             header("Content-Type: image/png");
             $mimeType = $parts['MIME_TYPE']->getValue();
             if (!$mimeType || $mimeType == 'application/octet-stream') {
                 $mime = Services::getService("MIME");
                 $mimeType = $mime->getMIMETypeForFileName($parts['FILE_NAME']->getValue());
             }
             // These are mappings to file names in the KDE icon set.
             $subTypeImages = array("text/plain" => "txt.png", "text/css" => "css.png", "text/html" => "html.png", "text/x-lyx" => "mime_lyx.png", "text/xml" => "xml.png", "audio/midi" => "midi.png", "video/quicktime" => "quicktime.png", "application/vnd.rn-realmedia" => "real.png", "application/x-pn-realaudio" => "real.png", "application/x-pn-realaudio" => "real.png", "application/msword" => "wordprocessing.png", "application/vnd.ms-word" => "wordprocessing.png", "application/vnd.ms-excel" => "spreadsheet.png", "application/msword" => "wordprocessing.png", "application/vnd.ms-powerpoint" => "kpresenter_kpr.png", "application/mspowerpoint" => "kpresenter_kpr.png", "application/pdf" => "pdf.png", "application/x-tar" => "tar.png", "application/x-gtar" => "gtar.png", "application/x-ustar" => "tar.png", "application/x-gzip" => "tar.png", "application/x-bzip" => "tar.png", "application/x-bzip2" => "tar.png", "application/x-bcpio" => "tar.png", "application/x-cpio" => "tar.png", "application/x-shar" => "tar.png", "application/mac-binhex40" => "tar.png", "application/x-stuffit" => "tar.png", "application/zip" => "tar.png");
             $typeImages = array("text" => "txt.png", "application" => "binary.png", "audio" => "sound.png", "video" => "video.png", "image" => "image.png");
             if (isset($subTypeImages[$mimeType])) {
                 $imageName = $subTypeImages[$mimeType];
             } else {
                 $typeParts = explode("/", $mimeType);
                 $imageName = $typeImages[$typeParts[0]];
             }
             header('Content-Disposition: filename="' . $imageName . '"');
             print file_get_contents(POLYPHONY_DIR . "/icons/filetypes/" . $imageName);
         }
     }
     $harmoni->request->endNamespace();
     textdomain($defaultTextDomain);
     exit;
 }
示例#12
0
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;
}
 /**
  * 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 . "?&amp;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;
 }
示例#14
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;
 }
 /**
  * Generate HTML for displaying particular parts of the Record 
  * 
  * @param object $record The record to print.
  * @param array $partStructures An array of particular partStructures to print. 
  * @return string
  * @access public
  * @since 10/19/04
  */
 function generateDisplayForPartStructures(Id $repositoryId, Id $assetId, Record $record, array $partStructures)
 {
     ArgumentValidator::validate($partStructures, new ArrayValidatorRuleWithRule(new ExtendsValidatorRule("PartStructure")));
     $partIterator = $record->getParts();
     $parts = array();
     while ($partIterator->hasNext()) {
         $part = $partIterator->next();
         $partStructure = $part->getPartStructure();
         $partStructureId = $partStructure->getId();
         if (!isset($parts[$partStructureId->getIdString()]) || !is_array($parts[$partStructureId->getIdString()])) {
             $parts[$partStructureId->getIdString()] = array();
         }
         $parts[$partStructureId->getIdString()][] = $part;
     }
     // print out the parts;
     ob_start();
     $partStructuresToSkip = array('FILE_DATA', 'THUMBNAIL_DATA', 'THUMBNAIL_MIME_TYPE', 'THUMBNAIL_DIMENSIONS');
     $printThumbnail = FALSE;
     foreach (array_keys($partStructures) as $key) {
         $partStructure = $partStructures[$key];
         $partStructureId = $partStructure->getId();
         if (!in_array($partStructureId->getIdString(), $partStructuresToSkip)) {
             print "\n<strong>" . $partStructure->getDisplayName() . ":</strong> \n";
             switch ($partStructureId->getIdString()) {
                 case 'FILE_SIZE':
                     $size = ByteSize::withValue($parts[$partStructureId->getIdString()][0]->getValue());
                     print $size->asString();
                     break;
                 case 'DIMENSIONS':
                     $dimensionArray = $parts[$partStructureId->getIdString()][0]->getValue();
                     print "<em>" . _('width: ') . "</em>" . $dimensionArray[0] . 'px<em>;</em> ';
                     print "<em>" . _('height: ') . "</em>" . $dimensionArray[1] . 'px';
                     break;
                 default:
                     print $parts[$partStructureId->getIdString()][0]->getValue();
             }
             print "\n<br />";
         } else {
             $printThumbnail = TRUE;
         }
     }
     $html = ob_get_clean();
     $harmoni = Harmoni::instance();
     $harmoni->request->startNamespace("polyphony-repository");
     if ($printThumbnail) {
         ob_start();
         $recordId = $record->getId();
         $ns = $harmoni->request->endNamespace();
         // ======= VIEWER LINK ======== //
         $xmlAssetIdString = $harmoni->request->get("asset_id");
         print "<a href='#' onclick='Javascript:window.open(";
         print '"' . VIEWER_URL . "?&amp;source=";
         print urlencode($harmoni->request->quickURL("asset", "browserecordxml", array("collection_id" => $repositoryId->getIdString(), "asset_id" => $xmlAssetIdString, "record_id" => $recordId->getIdString(), RequestContext::name("limit_by") => RequestContext::value("limit_by"), RequestContext::name("type") => RequestContext::value("type"), RequestContext::name("searchtype") => RequestContext::value("searchtype"), RequestContext::name("searchstring") => RequestContext::value("searchstring"))));
         print '&amp;start=0", ';
         print '"' . preg_replace("/[^a-z0-9]/i", '_', $assetId->getIdString()) . '", ';
         print '"toolbar=no,location=no,directories=no,status=yes,scrollbars=yes,resizable=yes,copyhistory=no,width=600,height=500"';
         print ")'>";
         $harmoni->request->startNamespace($ns);
         // If we have a thumbnail with a valid mime type, print a link to that.
         $thumbnailName = preg_replace("/\\.[^\\.]+\$/", "", $parts['FILE_NAME'][0]->getValue());
         if ($thumbnailMimeType = $parts['THUMBNAIL_MIME_TYPE'][0]->getValue()) {
             $mime = Services::getService("MIME");
             $thumbnailName .= "." . $mime->getExtensionForMIMEType($thumbnailMimeType);
         }
         print "\n<img src='";
         print RepositoryInputOutputModuleManager::getThumbnailUrlForRecord($assetId, $record);
         print "'";
         print " style='border: 0px;'";
         print " alt='Thumbnail image.'";
         print " align='left'";
         print " />";
         print "</a> <br />";
         $html2 = ob_get_clean();
         ob_start();
         print "\n<a href='";
         print RepositoryInputOutputModuleManager::getFileUrlForRecord($assetId, $record);
         print "' target='_blank'>";
         print "Download This File</a>\n";
         $downloadlink = ob_get_clean();
         $html = "<table border=0><tr><td>" . $html2 . "</td><td>" . $html . $downloadlink . "</td></tr></table>";
     }
     $harmoni->request->endNamespace();
     return $html;
 }
示例#16
0
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 . "?&amp;source=";
            print urlencode($harmoni->request->quickURL("basket", "browse_xml"));
            print '&amp;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 "&lt;--";
    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 "--&gt;";
    print "</a>";
    $container->add(new UnstyledBlock(ob_get_clean()), "100%", null, RIGHT, BOTTOM);
    return $container;
}