function printRepositoryShort($repository)
{
    $harmoni = Harmoni::instance();
    ob_start();
    $repositoryId = $repository->getId();
    print "\n\t<div style='font-weight: bold' title='" . _("ID#") . ": " . $repositoryId->getIdString() . "'>" . $repository->getDisplayName() . "</div>";
    $description = HtmlString::withValue($repository->getDescription());
    $description->trim(500);
    print "\n\t<div style='font-size: smaller;'>" . $description->asString() . "</div>";
    RepositoryPrinter::printRepositoryFunctionLinks($harmoni, $repository);
    $xLayout = new XLayout();
    $layout = new Container($xLayout, BLANK, 1);
    $layout2 = new Block(ob_get_contents(), EMPHASIZED_BLOCK);
    $layout->add($layout2, null, null, CENTER, CENTER);
    ob_end_clean();
    return $layout;
}
Exemple #2
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) {
     }
 }
 /**
  * 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);
 }
 /**
  * Answer a string trimmed to the specified word length. Strips html tags
  * as well
  * 
  * @param string $htmlString
  * @param integer $maxWords
  * @param optional boolean $addElipses Add elipses when trimming.
  * @return string
  * @access public
  * @since 1/26/06
  */
 public final function stripTagsAndTrim($htmlString, $maxWords, $addElipses = true)
 {
     $htmlStringObj = HtmlString::withValue($htmlString);
     $htmlStringObj->stripTagsAndTrim($maxWords, $addElipses);
     return $htmlStringObj->asString();
 }
 function test_select()
 {
     $string = "<option>Hello world.";
     $string2 = "<select><option>Hello world.</option></select>";
     $htmlString = HtmlString::withValue($string);
     $htmlString->clean();
     $this->assertEqual($htmlString->asString(), $string2);
     $string = "<optgroup><option>Hello world.</optgroup></option>";
     $string2 = "<select><optgroup><option>Hello world.</option></optgroup></select>";
     $htmlString = HtmlString::withValue($string);
     $htmlString->clean();
     $this->assertEqual($htmlString->asString(), $string2);
     $string = "<optgroup><option>Hello world.</optgroup></option></select>";
     $string2 = "<select><optgroup><option>Hello world.</option></optgroup></select>";
     $htmlString = HtmlString::withValue($string);
     $htmlString->clean();
     $this->assertEqual($htmlString->asString(), $string2);
 }
Exemple #6
0
 /**
  * 
  * 
  * @param <##>
  * @return <##>
  * @access public
  * @since 1/18/06
  */
 public function printSiteShort(Asset $asset, $action, $num, Slot $otherSlot = null)
 {
     $harmoni = Harmoni::instance();
     $assetId = $asset->getId();
     $authZ = Services::getService('AuthZ');
     $idMgr = Services::getService('Id');
     if (!$authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId) && !$otherSlot->isUserOwner()) {
         return new UnstyledBlock('', BLANK);
     }
     $container = new Container(new YLayout(), BLOCK, STANDARD_BLOCK);
     $fillContainerSC = new StyleCollection("*.fillcontainer", "fillcontainer", "Fill Container", "Elements with this style will fill their container.");
     $fillContainerSC->addSP(new MinHeightSP("88%"));
     // 	$fillContainerSC->addSP(new WidthSP("100%"));
     // 	$fillContainerSC->addSP(new BorderSP("3px", "solid", "#F00"));
     $container->addStyle($fillContainerSC);
     $centered = new StyleCollection("*.centered", "centered", "Centered", "Centered Text");
     $centered->addSP(new TextAlignSP("center"));
     // Use the alias instead of the Id if it is available.
     $viewUrl = SiteDispatcher::getSitesUrlForSiteId($assetId->getIdString());
     $slotManager = SlotManager::instance();
     try {
         $sitesTrueSlot = $slotManager->getSlotBySiteId($assetId);
     } catch (Exception $e) {
     }
     // Print out the content
     ob_start();
     print "\n\t<div class='portal_list_slotname'>";
     if (isset($sitesTrueSlot)) {
         if (is_null($otherSlot) || $sitesTrueSlot->getShortname() == $otherSlot->getShortname()) {
             print $sitesTrueSlot->getShortname();
         } else {
             print $otherSlot->getShortname();
             $targets = array();
             $target = $otherSlot->getAliasTarget();
             while ($target) {
                 $targets[] = $target->getShortname();
                 if ($target->isAlias()) {
                     $target = $target->getAliasTarget();
                 } else {
                     $target = null;
                 }
             }
             print "\n<br/>";
             print str_replace('%1', implode(' &raquo; ', $targets), _("(an alias of %1)"));
             // Add Alias info.
             // 				if ($otherSlot->isAlias()) {
             // 					ob_start();
             //
             // 					print _("This slot is an alias of ").$slot->getAliasTarget()->getShortname();
             //
             // 					$container->add(new UnstyledBlock(ob_get_clean()), "100%", null, LEFT, TOP);
             // 				}
         }
     } else {
         print _("ID#") . ": " . $assetId->getIdString();
     }
     print "\n\t</div>";
     print "\n\t<div class='portal_list_site_title'>";
     if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
         print "\n\t\t<a href='" . $viewUrl . "'>";
         print "\n\t\t\t<strong>" . HtmlString::getSafeHtml($asset->getDisplayName()) . "</strong>";
         print "\n\t\t</a>";
         print "\n\t\t<br/>";
         print "\n\t\t<a href='" . $viewUrl . "' style='font-size: smaller;'>";
         print "\n\t\t\t" . $viewUrl;
         print "\n\t\t</a>";
     }
     print "\n\t</div>";
     print "\n\t<div class='portal_list_controls'>\n\t\t";
     $controls = array();
     if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
         $controls[] = "<a href='" . $viewUrl . "'>" . _("view") . "</a>";
     }
     // Hide all edit links if not authenticated to prevent web spiders from traversing them
     if ($this->isAuthenticated) {
         // While it is more correct to check modify permission permission, doing
         // so forces us to check AZs on the entire site until finding a node with
         // authorization or running out of nodes to check. Since edit-mode actions
         // devolve into view-mode if no authorization is had by the user, just
         // show the links all the time to cut page loads from 4-6 seconds to
         // less than 1 second.
         if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
             $controls[] = "<a href='" . SiteDispatcher::quickURL($action->getUiModule(), 'editview', array('node' => $assetId->getIdString())) . "'>" . _("edit") . "</a>";
         }
         // 		if ($action->getUiModule() == 'ui2') {
         // 			$controls[] = "<a href='".SiteDispatcher::quickURL($action->getUiModule(), 'arrangeview', array('node' => $assetId->getIdString()))."'>"._("arrange")."</a>";
         // 		}
         // add link to tracking
         if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
             $trackUrl = $harmoni->request->quickURL("participation", "actions", array('node' => $assetId->getIdString()));
             ob_start();
             print " <a target='_blank' href='" . $trackUrl . "'";
             print ' onclick="';
             print "var url = '" . $trackUrl . "'; ";
             print "window.open(url, 'site_map', 'width=600,height=600,resizable=yes,scrollbars=yes'); ";
             print "return false;";
             print '"';
             print ">" . _("track") . "</a>";
             $controls[] = ob_get_clean();
         }
         if (!is_null($otherSlot) && $otherSlot->isAlias() && $otherSlot->isUserOwner()) {
             $controls[] = "<a href='" . $harmoni->request->quickURL('slots', 'remove_alias', array('slot' => $otherSlot->getShortname())) . "' onclick=\"if (!confirm('" . str_replace("%1", $otherSlot->getShortname(), str_replace("%2", $otherSlot->getAliasTarget()->getShortname(), _("Are you sure that you want \\'%1\\' to no longer be an alias of \\'%2\\'?"))) . "')) { return false; }\">" . _("remove alias") . "</a>";
         } else {
             if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.delete'), $assetId)) {
                 $controls[] = "<a href='" . $harmoni->request->quickURL($action->getUiModule(), 'deleteComponent', array('node' => $assetId->getIdString())) . "' onclick=\"if (!confirm('" . _("Are you sure that you want to permenantly delete this site?") . "')) { return false; }\">" . _("delete") . "</a>";
             }
         }
         // Add a control to select this site for copying. This should probably
         // have its own authorization, but we'll use add_children/modify for now.
         if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $assetId)) {
             if (isset($sitesTrueSlot) && (is_null($otherSlot) || $sitesTrueSlot->getShortname() == $otherSlot->getShortname())) {
                 $controls[] = Segue_Selection::instance()->getAddLink(SiteDispatcher::getSiteDirector()->getSiteComponentFromAsset($asset));
             }
         }
     }
     print implode("\n\t\t | ", $controls);
     print "\n\t</div>";
     if ($authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $assetId)) {
         $description = HtmlString::withValue($asset->getDescription());
         $description->trim(25);
         print "\n\t<div class='portal_list_site_description'>" . $description->asString() . "</div>";
     }
     print "\n\t<div style='clear: both;'></div>";
     print $this->getExportControls($assetId, $otherSlot, $sitesTrueSlot);
     $component = new UnstyledBlock(ob_get_clean());
     $container->add($component, "100%", null, LEFT, TOP);
     return $container;
 }
Exemple #7
0
 /**
  * Print Node info html
  * 
  * @param object SiteComponent $siteComponent
  * @return void
  * @access protected
  * @since 3/17/08
  */
 protected function printNodeInfo(SiteComponent $siteComponent, $inMenu = false)
 {
     $harmoni = Harmoni::instance();
     print $this->getTabs() . "\t";
     if ($siteComponent->getId() == SiteDispatcher::getCurrentNodeId()) {
         print "<div class='info current'>";
     } else {
         print "<div class='info'>";
     }
     print $this->getTabs() . "\t\t";
     print "<div class='title'>";
     $nodeUrl = SiteDispatcher::quickURL('view', 'html', array('node' => $siteComponent->getId()));
     if (!$inMenu) {
         print "<a href='" . $nodeUrl . "' ";
         print ' onclick="';
         print "if (window.opener) { ";
         print "window.opener.location = this.href; ";
         print "return false; ";
         print '}" ';
         print " title='" . _("View this node") . "'>";
     }
     print $siteComponent->getDisplayName();
     if (!$inMenu) {
         print "</a>";
     }
     print "</div>";
     $nodeDescription = HtmlString::withValue($siteComponent->getDescription());
     $nodeDescription->stripTagsAndTrim(5);
     print $this->getTabs() . "\t\t";
     print "<div class='description'>" . $nodeDescription->stripTagsAndTrim(20) . "</div>";
     print $this->getTabs() . "\t";
     print "</div>";
 }
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;
}
Exemple #9
0
 /**
  * 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()
 {
     $repository = $this->getRepository();
     $repositoryId = $this->getRepositoryId();
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $authZManager = Services::getService("AuthZ");
     $returnUrl = $harmoni->request->mkURLWithPassthrough();
     $returnUrl->setValue("wizardSkipToStep", "schema");
     // Instantiate the wizard, then add our steps.
     $wizard = SimpleStepWizard::withDefaultLayout();
     // :: Step One ::
     $stepOne = $wizard->addStep("namedesc", new WizardStep());
     $stepOne->setDisplayName(_("Name &amp; Description"));
     // Create the step text
     ob_start();
     $displayNameProp = $stepOne->addComponent("display_name", new WTextField());
     $displayNameProp->setValue($repository->getDisplayName());
     $displayNameProp->setErrorText(_("A value for this field is required."));
     $displayNameProp->setErrorRule(new WECNonZeroRegex("[\\w]+"));
     print "\n<h2>" . _("Name") . "</h2>";
     print "\n" . _("The Name for this <em>Collection</em>: ");
     print "\n<br />[[display_name]]";
     $fieldname = RequestContext::name('description');
     $descriptionProp = $stepOne->addComponent("description", WTextArea::withRowsAndColumns(10, 80));
     $descriptionProp->setValue($repository->getDescription());
     print "\n<h2>" . _("Description") . "</h2>";
     print "\n" . _("The Description for this <em>Collection</em>: ");
     print "\n<br />[[description]]";
     print "\n<div style='width: 400px'> &nbsp; </div>";
     $stepOne->setContent(ob_get_contents());
     ob_end_clean();
     // :: Schema Selection ::
     $selectStep = $wizard->addStep("schema", new WizardStep());
     $selectStep->setDisplayName(_("Schema Selection"));
     // get an iterator of all RecordStructures
     $recordStructures = $repository->getRecordStructures();
     $setManager = Services::getService("Sets");
     $set = $setManager->getPersistentSet($repositoryId);
     ob_start();
     print "<h2>" . _("Select Cataloging Schemas") . "</h2>";
     print "\n<p>" . _("Select which cataloging schemas you wish to appear during <em>Asset</em> creation and editing. <em>Assets</em> can hold data in any of the schemas, but only the ones selected here will be available when adding new data.") . "</p>";
     if ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_rec_struct"), $repositoryId)) {
         $fieldname = RequestContext::name('create_schema');
         $button = $selectStep->addComponent("_create_schema", WSaveButton::withLabel(_("Save Changes and Create a New Schema")));
         print "\n<p>" . _("If none of the schemas listed below fit your needs, please click the button below to save your changes and create a new schema.") . "</p>";
         print "\n[[_create_schema]]";
     }
     print "\n<br /><table border='1'>";
     print "\n\t<tr>";
     print "\n\t<th>" . _("Display Name") . "</th>";
     print "\n\t<th>" . _("Description") . "</th>";
     print "\n\t<th>" . _("Order/Position") . "</th>";
     print "\n\t</tr>";
     // Get the number of info structures
     $numRecordStructures = 0;
     while ($recordStructures->hasNext()) {
         $recordStructure = $recordStructures->next();
         $numRecordStructures++;
     }
     $assetContentStructureId = $idManager->getId("edu.middlebury.harmoni.repository.asset_content");
     $recordStructures = $repository->getRecordStructures();
     while ($recordStructures->hasNext()) {
         $recordStructure = $recordStructures->next();
         $recordStructureId = $recordStructure->getId();
         // Don't list the asset Content structure.
         if ($recordStructureId->isEqual($assetContentStructureId)) {
             continue;
         }
         // Create the properties.
         // 'in set' property
         $fieldname = "schema_" . str_replace(".", "__", $recordStructureId->getIdString());
         $property = $selectStep->addComponent($fieldname, new WCheckBox());
         if ($set->isInSet($recordStructureId)) {
             $property->setChecked(true);
         } else {
             $property->setChecked(false);
         }
         $property->setLabel($recordStructure->getDisplayName());
         $property->setStyle("font-weight: 900;");
         // Order property
         $orderFieldName = $fieldname . "_position";
         $property = $selectStep->addComponent($orderFieldName, new WSelectList());
         if ($set->isInSet($recordStructureId)) {
             $property->setValue(strval($set->getPosition($recordStructureId) + 1));
         } else {
             $property->setValue(0);
         }
         print "\n<tr><td valign='top'>";
         print "\n\t[[{$fieldname}]]";
         //			print "\n\t<strong>".a."</strong>";
         $description = HtmlString::withValue($recordStructure->getDescription());
         $description->trim(100);
         // trim to 100 words
         print "\n</td><td valign='top'>\n\t<div style='font-style: italic'>" . $description->asString() . "</div>";
         $harmoni->history->markReturnURL("concerto/collection/edit/" . $repositoryId->getIdString(), $returnUrl);
         $links = array();
         // Schema Details
         ob_start();
         print " <a href='";
         print $harmoni->request->quickURL("schema", "view", array("collection_id" => $repositoryId->getIdString(), "recordstructure_id" => $recordStructureId->getIdString(), "__skip_to_step" => 2));
         print "'>" . _("Details") . "</a>";
         $links[] = ob_get_clean();
         // Schema Edit
         if (method_exists($recordStructure, 'createPartStructure') && (preg_match("/^Repository::.+\$/i", $recordStructureId->getIdString()) && ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_rec_struct"), $repositoryId) || $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_authority_list"), $repositoryId)) || ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_rec_struct"), $idManager->getId("edu.middlebury.authorization.root")) || $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify_authority_list"), $repositoryId)))) {
             $harmoni->history->markReturnURL("concerto/schema/edit-return/" . $recordStructureId->getIdString(), $returnUrl);
             ob_start();
             print "<a href='";
             print $harmoni->request->quickURL("schema", "edit", array("collection_id" => $repositoryId->getIdString(), "recordstructure_id" => $recordStructureId->getIdString()));
             print "'>" . _("Edit") . "</a>";
             $links[] = ob_get_clean();
         }
         // Schema Copy
         $authZManager = Services::getService("AuthZ");
         $idManager = Services::getService("Id");
         if (method_exists($recordStructure, 'createPartStructure') && (preg_match("/^Repository::.+\$/i", $recordStructureId->getIdString()) && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.convert_rec_struct"), $repositoryId) || $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.convert_rec_struct"), $idManager->getId("edu.middlebury.authorization.root")))) {
             $button = $selectStep->addComponent("duplicate_schema__" . str_replace('.', '_', $recordStructureId->getIdString()), WSaveButton::withLabel(_("Duplicate Schema Only")));
             $button->addConfirm(_("Are you sure that you wish to duplicate this Schema?"));
             $links[] = "[[duplicate_schema__" . str_replace('.', '_', $recordStructureId->getIdString()) . "]]";
             if ($authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.modify"), $repositoryId)) {
                 $button = $selectStep->addComponent("duplicate_copy_records__" . str_replace('.', '_', $recordStructureId->getIdString()), WSaveButton::withLabel(_("Duplicate Schema and Records")));
                 $button->addConfirm(_("Are you sure that you wish to duplicate this Schema\\nand all Records that use it?"));
                 $links[] = "[[duplicate_copy_records__" . str_replace('.', '_', $recordStructureId->getIdString()) . "]]";
             }
             $harmoni->history->markReturnURL("concerto/schema/duplicate-return/" . $recordStructureId->getIdString(), $returnUrl);
         }
         // Schema Delete
         $authZManager = Services::getService("AuthZ");
         $idManager = Services::getService("Id");
         if (method_exists($recordStructure, 'createPartStructure') && (preg_match("/^Repository::.+\$/i", $recordStructureId->getIdString()) && $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete_rec_struct"), $repositoryId) || $authZManager->isUserAuthorized($idManager->getId("edu.middlebury.authorization.delete_rec_struct"), $idManager->getId("edu.middlebury.authorization.root")))) {
             $button = $selectStep->addComponent("_delete_schema__" . str_replace('.', '_', $recordStructureId->getIdString()), WSaveButton::withLabel(_("Delete")));
             $button->addConfirm(_("Are you sure that you wish to delete this Schema\\nand Records in all Assets in this Collection that use it?"));
             $button->addConfirm(_("This Schema can only be deleted if there are no Records\\nin any other Collection that use it.\\n\\nAre you sure that there are no Records that use this Schema?\\n\\nContinue to delete?"));
             $harmoni->history->markReturnURL("concerto/schema/delete-return/" . $recordStructureId->getIdString(), $returnUrl);
             $links[] = "[[_delete_schema__" . str_replace('.', '_', $recordStructureId->getIdString()) . "]]";
         }
         print implode(" | ", $links);
         print "\n</td><td valign='top'>";
         print "\n\t[[{$orderFieldName}]]";
         for ($i = 0; $i <= $numRecordStructures; $i++) {
             //				print "\n\t\t<option value='$i' [['$orderFieldname' == '$i'|selected='selected'|]]>".(($i)?$i:"")."</option>";
             $property->addOption($i, $i ? $i : "");
         }
         print "\n</td></tr>";
     }
     print "\n</table>";
     $selectStep->setContent(ob_get_clean());
     return $wizard;
 }
 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $this->registerDisplayProperties();
     $this->registerState();
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $harmoni->request->passthrough("collection_id");
     $harmoni->request->passthrough("asset_id");
     $asset = $this->getAsset();
     $assetId = $asset->getId();
     // function links
     ob_start();
     SlideShowPrinter::printFunctionLinks($asset);
     $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), null, null, CENTER, CENTER);
     ob_start();
     $description = HtmlString::withValue($asset->getDescription());
     $description->clean();
     print "\n\t<div style='font-size: smaller;'>" . $description->asString() . "</div>";
     $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), "100%", null, LEFT, CENTER);
     $searchBar = new Container(new YLayout(), BLOCK, STANDARD_BLOCK);
     $actionRows->add($searchBar, "100%", null, CENTER, CENTER);
     //***********************************
     // Get the assets to display
     //***********************************
     $setManager = Services::getService("Sets");
     $slideshowSet = $setManager->getPersistentSet($asset->getId());
     $slideIterator = $asset->getAssets();
     $orderedSlides = array();
     $unorderedSlides = array();
     while ($slideIterator->hasNext()) {
         $slideAsset = $slideIterator->next();
         $slideAssetId = $slideAsset->getId();
         if ($slideshowSet->isInSet($slideAssetId)) {
             $orderedSlides[$slideshowSet->getPosition($slideAssetId)] = $slideAsset;
         } else {
             $unorderedSlides[] = $slideAsset;
         }
     }
     ksort($orderedSlides);
     $slides = array_merge($orderedSlides, $unorderedSlides);
     unset($orderedSlides, $unorderedSlides);
     //***********************************
     // print the results
     //***********************************
     $resultPrinter = new ArrayResultPrinter($slides, $_SESSION["asset_columns"], $_SESSION["assets_per_page"], "printSlideShort", $this->getParams(), $assetId->getIdString());
     $resultPrinter->setStartingNumber($this->_state['startingNumber']);
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout("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();
     $searchBar->add(new UnstyledBlock(ob_get_clean()), null, null, LEFT, TOP);
     $searchBar->add($this->getDisplayOptions($resultPrinter, false), null, null, LEFT, TOP);
 }
Exemple #11
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;
 }
Exemple #12
0
 /**
  * Print info about a Slot
  * 
  * @param object Slot $slot
  * @return void
  * @access private
  * @since 3/13/08
  */
 private function printSlotInfo(Slot $slot)
 {
     $harmoni = Harmoni::instance();
     if ($slot->siteExists()) {
         $asset = $slot->getSiteAsset();
         try {
             $authZ = Services::getService('AuthZ');
             $idMgr = Services::getService('Id');
             if (!$authZ->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.view'), $slot->getSiteId())) {
                 print "\n<div class='site_info'>";
                 print "\n\t<div class='site_description'>";
                 print _("A site has been created for this placeholder, but you do not have authorization to view it.");
                 print "</div>";
                 print "\n</div>";
                 return;
             }
         } catch (UnknownIdException $e) {
         }
         $viewUrl = SiteDispatcher::quickURL('view', 'html', array('site' => $slot->getShortname()));
         print "\n<div class='site_info'>";
         print "\n\t<div class='site_title'>";
         print "\n\t\t<a href='" . $viewUrl . "' target='_blank'>";
         print "\n\t\t\t<strong>" . HtmlString::getSafeHtml($asset->getDisplayName()) . "</strong>";
         print "\n\t\t</a>";
         print "\n\t</div>";
         $description = HtmlString::withValue($asset->getDescription());
         $description->trim(25);
         print "\n\t<div class='site_description'>" . $description->asString() . "</div>";
         print "\n</div>";
     }
     print "\n\t<div class='slotname'>";
     print $slot->getShortname();
     print "\n\t</div>";
 }
 /**
  * Clean and trim an HTML String.
  * 
  * @param string $html
  * @param optional int $numWords The maximum number of words.
  * @return string
  * @access protected
  * @since 2/14/08
  */
 protected function trimHtml($html, $numWords = null)
 {
     $string = HtmlString::withValue($html);
     // SafeHTML looks for the first colon to determine if something is a
     // a protocal.
     $string->addSafeProtocal('[[fileurl');
     $string->addSafeProtocal('[[localurl');
     $string->cleanXSS();
     if (!is_null($numWords)) {
         $string->trim($numWords);
     }
     return $string->asString();
 }
 /**
  * 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;
 }
Exemple #15
0
function find_abstract($content, $search, $numwords = 25)
{
    $content = eregi_replace("<br>", "..", $content);
    $content = eregi_replace("<br \\/>", "..", $content);
    //	$content = eregi_replace("\[\[linkpath\]\]", "...", $content);
    $search = " " . $search;
    $htmlstring =& HtmlString::withValue($content);
    $content = $htmlstring->stripTagsAndTrim(500);
    $lowercontent = strtolower($content);
    $searchstart = strpos($lowercontent, $search);
    if ($searchstart < 60) {
        $searchbegin = 0;
        $searchend = 150;
    } else {
        if ($searchstart == 0) {
            $searchbegin = 0;
            $searchend = 150;
        } else {
            $searchbegin = $searchstart - 50;
            $searchend = $searchstart + 150;
        }
    }
    $content = substr($content, $searchbegin, 500);
    $htmlstring =& HtmlString::withValue($content);
    $content = $htmlstring->stripTagsAndTrim(25);
    $clean = explode(" ", $content);
    $clean_content = "";
    foreach ($clean as $word) {
        if (strlen($word) > 50) {
            $word = substr($word, 0, 50) . "...";
        }
        $clean_content .= $word . " ";
    }
    $search_term = "<span class='foundtext'>" . $search . "</span>";
    $clean_content = eregi_replace($search, $search_term, $clean_content);
    if ($searchstart < 40) {
        $clean_content = $clean_content . "...";
    } else {
        $clean_content = "..." . $clean_content . "...";
    }
    return $clean_content;
}
 /**
  * Build the content for this action
  * 
  * @return void
  * @access public
  * @since 4/26/05
  */
 function buildContent()
 {
     $actionRows = $this->getActionRows();
     $harmoni = Harmoni::instance();
     $idManager = Services::getService("Id");
     $repositoryManager = Services::getService("Repository");
     $repository = $repositoryManager->getRepository($idManager->getId("edu.middlebury.concerto.exhibition_repository"));
     $asset = $repository->getAsset($idManager->getId(RequestContext::value('exhibition_id')));
     // function links
     ob_start();
     ExhibitionPrinter::printFunctionLinks($asset);
     $actionRows->add(new Block(ob_get_clean(), STANDARD_BLOCK), null, null, CENTER, CENTER);
     /*********************************************************
      * Description
      *********************************************************/
     $description = HtmlString::withValue($asset->getDescription());
     $description->clean();
     if (strlen($description->asString())) {
         $actionRows->add(new Block($description->asString(), STANDARD_BLOCK), "100%", null, LEFT, CENTER);
     }
     //***********************************
     // Get the assets to display
     //***********************************
     $setManager = Services::getService("Sets");
     $exhibitionSet = $setManager->getPersistentSet($asset->getId());
     $slideshowIterator = $asset->getAssets();
     $orderedSlideshows = array();
     $unorderedSlideshows = array();
     while ($slideshowIterator->hasNext()) {
         $slideshowAsset = $slideshowIterator->next();
         $slideshowAssetId = $slideshowAsset->getId();
         if ($exhibitionSet->isInSet($slideshowAssetId)) {
             $orderedSlideshows[$exhibitionSet->getPosition($slideshowAssetId)] = $slideshowAsset;
         } else {
             $exhibitionSet->addItem($slideshowAssetId);
             $unorderedSlideshows[] = $slideshowAsset;
         }
     }
     ksort($orderedSlideshows);
     $assets = array_merge($orderedSlideshows, $unorderedSlideshows);
     unset($orderedSlideshows, $unorderedSlideshows);
     //***********************************
     // print the results
     //***********************************
     $resultPrinter = new ArrayResultPrinter($assets, 2, 6, "printAssetShort", $harmoni);
     $resultPrinter->addLinksStyleProperty(new MarginTopSP("10px"));
     $resultLayout = $resultPrinter->getLayout();
     $actionRows->add($resultLayout, "100%", null, LEFT, CENTER);
 }
Exemple #17
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;
}
function printrepositoryShort($repository, $harmoni)
{
    ob_start();
    $repositoryId = $repository->getId();
    print "\n\t<strong>" . $repository->getDisplayName() . "</strong> - " . _("ID#") . ": " . $repositoryId->getIdString();
    $description = HtmlString::withValue($repository->getDescription());
    $description->trim(100);
    print "\n\t<div style='font-size: smaller;'>" . $description->asString() . "</div>";
    RepositoryPrinter::printRepositoryFunctionLinks($harmoni, $repository);
    $layout = new Block(ob_get_contents(), EMPHASIZED_BLOCK);
    ob_end_clean();
    return $layout;
}
Exemple #19
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;
}