/**
  * Tells the wizard component to update itself - this may include getting
  * form post data or validation - whatever this particular component wants to
  * do every pageload. 
  * @param string $fieldName The field name to use when outputting form data or
  * similar parameters/information.
  * @access public
  * @return boolean - TRUE if everything is OK
  */
 function update($fieldName)
 {
     $val = RequestContext::value($fieldName);
     if ($val !== null && (!$this->_startingDisplay || $val != $this->_startingDisplay)) {
         $string = HtmlString::fromString($val);
         $string->cleanXSS();
         $this->_value = $string->asString();
         if (trim($this->_value) != trim($val)) {
             $this->_origErrorText = $this->getErrorText();
             $this->setErrorText(dgettext('polyphony', "The value you entered has been reformatted to meet XHTML validity standards."));
             // Add both error text if validation failed as well.
             if (!$this->validate()) {
                 $this->setErrorText($this->getErrorText() . " " . $this->_origErrorText);
             }
             $this->_showError = true;
             // Add a dummy rule if needed.
             if (!$this->getErrorRule()) {
                 $this->setErrorRule(new WECRegex('.*'));
             }
         } else {
             // Reset the original error text.
             if (isset($this->_origErrorText)) {
                 $this->setErrorText($this->_origErrorText);
             }
         }
     }
     return $this->validate();
 }
 /**
  * Answer the displayName
  * 
  * @return string
  * @access public
  * @since 3/31/06
  */
 function getDisplayName()
 {
     $child = $this->_element->firstChild;
     while ($child) {
         if ($child->nodeName == 'displayName') {
             return HtmlString::getSafeHtml($child->getText());
         }
         $child = $child->nextSibling;
     }
     return _('Default Name');
 }
Beispiel #3
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;
 }
 /**
  * Required: Set the description
  * 
  * @param string $description
  * @return void
  * @access public
  * @since 8/7/06
  */
 function setDescription($description)
 {
     ArgumentValidator::validate($description, StringValidatorRule::getRule());
     $this->_description = HtmlString::fromString(str_replace("&nbsp;", "&#160;", $description));
     $this->_description->makeUtf8();
     $this->_description->clean();
 }
Beispiel #5
0
 /**
  * Load feed data, convert and clean it, and return its string value.
  * 
  * @param string $url
  * @return string RSS xml
  * @access protected
  * @since 7/8/08
  */
 protected function loadFeedXml($url)
 {
     $feedData = @file_get_contents($url);
     if (!strlen($feedData)) {
         throw new OperationFailedException("Could not access feed, '" . $url . "'.");
     }
     $feed = new DOMDocument();
     // If the encoding is not UTF-8, convert the document
     if (preg_match('/^<\\?xml .*encoding=[\'"]([a-zA-Z0-9-]+)[\'"].*\\?>/m', $feedData, $matches)) {
         $encoding = $matches[1];
         if (strtoupper($encoding) != 'UTF8' && strtoupper($encoding) != 'UTF-8') {
             $feedData = mb_convert_encoding($feedData, 'UTF-8', strtoupper($encoding));
             $feedData = preg_replace('/^(<\\?xml .*encoding=[\'"])([a-zA-Z0-9-]+)([\'"].*\\?>)/m', '\\1UTF-8\\3', $feedData);
         }
     }
     // Convert any non-UTF-8 characters
     $string = String::withValue($feedData);
     $string->makeUtf8();
     $feedData = $string->asString();
     if (!@$feed->loadXML($feedData)) {
         throw new OperationFailedException("Invalid feed data: \"" . $feedData . "\" for URL: " . $url);
     }
     // Handle any format conversions
     $feed = $this->convertToRss($feed);
     // Validate Feed.
     // 		$tmpFeed = $feed;
     // 		$feed = new Harmoni_DOMDocument;
     // 		$feed->loadXML($tmpFeed->saveXML());
     // 		unset($tmpFeed);
     // 		$feed->schemaValidateWithException(dirname(__FILE__).'/rss-2_0-lax.xsd');
     // Run through the titles, authors, and descriptions and clean out any unsafe HTML
     foreach ($feed->getElementsByTagName('title') as $element) {
         $element->nodeValue = strip_tags(htmlspecialchars_decode($element->nodeValue));
     }
     foreach ($feed->getElementsByTagName('author') as $element) {
         $element->nodeValue = strip_tags(htmlspecialchars_decode($element->nodeValue));
     }
     foreach ($feed->getElementsByTagName('comments') as $element) {
         $element->nodeValue = htmlentities(strip_tags(html_entity_decode($element->nodeValue)));
     }
     foreach ($feed->getElementsByTagName('link') as $element) {
         $element->nodeValue = htmlentities(strip_tags(html_entity_decode($element->nodeValue)));
     }
     foreach ($feed->getElementsByTagName('description') as $description) {
         $html = HtmlString::fromString(htmlspecialchars_decode($description->nodeValue));
         $html->cleanXSS();
         $description->nodeValue = htmlspecialchars($html->asString());
     }
     // Move the feed into a dom document.
     $tmpFeed = $feed;
     $feed = new Harmoni_DOMDocument();
     $feed->loadXML($tmpFeed->saveXML());
     unset($tmpFeed);
     // Validate the feed again
     // 		$feed->schemaValidateWithException(dirname(__FILE__).'/rss-2_0-lax.xsd');
     // Just ensure a few basic things:
     if (!$feed->documentElement->nodeName == 'rss') {
         throw new DOMDocumentException("Feed root must be an rss element");
     }
     // Check for channels
     foreach ($feed->documentElement->childNodes as $element) {
         if ($element->nodeType == 1 && $element->nodeName != 'channel') {
             throw new DOMDocumentException("'" . $node->nodeName . "' is not expected, expecting 'channel'.");
         }
     }
     // Check dates
     foreach ($feed->getElementsByTagName('pubdate') as $element) {
         if (!preg_match('/(((Mon)|(Tue)|(Wed)|(Thu)|(Fri)|(Sat)|(Sun)), *)?\\d\\d? +((Jan)|(Feb)|(Mar)|(Apr)|(May)|(Jun)|(Jul)|(Aug)|(Sep)|(Oct)|(Nov)|(Dec)) +\\d\\d(\\d\\d)? +\\d\\d:\\d\\d(:\\d\\d)? +(([+\\-]?\\d\\d\\d\\d)|(UT)|(GMT)|(EST)|(EDT)|(CST)|(CDT)|(MST)|(MDT)|(PST)|(PDT)|\\w)/', $element->nodeValue)) {
             throw new DOMDocumentException("'" . $element->nodeValue . "' is not a valid date.");
         }
     }
     return $feed->saveXMLWithWhitespace();
 }
 /**
  * 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);
 }
Beispiel #7
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) {
     }
 }
Beispiel #8
0
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;
}
Beispiel #9
0
 /**
  * Process the changes and build the output
  * 
  * @return void
  * @access public
  * @since 1/26/07
  */
 public function buildContent()
 {
     try {
         ob_start();
         $idManager = Services::getService("Id");
         $fileAsset = $this->getFileAsset();
         // Update the files
         $oldFilename = null;
         $newFilename = null;
         foreach (array_keys($_FILES) as $fieldName) {
             if (preg_match('/^file___(.+)$/', $fieldName, $matches)) {
                 $fileRecord = $fileAsset->getRecord($idManager->getId($matches[1]));
                 $filenameParts = $fileRecord->getPartsByPartStructure($idManager->getId("FILE_NAME"));
                 $oldFilename = $filenameParts->next()->getValue();
                 $newFilename = $_FILES[$fieldName]['name'];
                 $this->updateFileRecord($fileAsset, $fileRecord, $fieldName);
             } else {
                 if ($fieldName == 'media_file') {
                     $oldFilename = null;
                     $newFilename = $_FILES[$fieldName]['name'];
                     $this->addFileRecord($fileAsset);
                 }
             }
         }
         // Update the displayname
         //
         // If the displayname in the form is the old filename, update it to the
         // new filename
         if (RequestContext::value('displayName') && RequestContext::value('displayName') == $oldFilename && $newFilename) {
             $fileAsset->updateDisplayName($newFilename);
         } else {
             if (RequestContext::value('displayName') && RequestContext::value('displayName') != $fileAsset->getDisplayName()) {
                 $fileAsset->updateDisplayName(HtmlString::getSafeHtml(RequestContext::value('displayName')));
             }
         }
         // Update the description if needed.
         if (!RequestContext::value('description')) {
             $fileAsset->updateDescription('');
         } else {
             if (RequestContext::value('description') != $fileAsset->getDescription()) {
                 $fileAsset->updateDescription(HtmlString::getSafeHtml(RequestContext::value('description')));
             }
         }
         // Update the other metadata.
         $dublinCoreRecords = $fileAsset->getRecordsByRecordStructure($idManager->getId('dc'));
         if ($dublinCoreRecords->hasNext()) {
             $this->updateDublinCoreRecord($fileAsset, $dublinCoreRecords->next());
         } else {
             $this->addDublinCoreRecord($fileAsset);
         }
         // Log the success or failure
         if (Services::serviceRunning("Logging")) {
             $loggingManager = Services::getService("Logging");
             $log = $loggingManager->getLogForWriting("Segue");
             $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
             $priorityType = new Type("logging", "edu.middlebury", "Event_Notice", "Normal events.");
             $message = "File updated with id '" . $fileAsset->getId()->getIdString() . "'";
             if (isset($newFilename)) {
                 $message .= " and new filename '" . $newFilename . "'";
             }
             $item = new AgentNodeEntryItem("Media Library", $message);
             $item->addNodeId($fileAsset->getId());
             $item->addNodeId($this->getContentAsset()->getId());
             $contentAsset = $this->getContentAsset();
             $idManager = Services::getService("Id");
             $director = AssetSiteDirector::forAsset($contentAsset);
             $site = $director->getRootSiteComponent($contentAsset->getId()->getIdString());
             $item->addNodeId($idManager->getId($site->getId()));
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         }
         // 		printpre($_FILES);
         if ($error = ob_get_clean()) {
             $this->error($error);
         }
         $this->start();
         // 		print "\n<![CDATA[";
         // 		print_r($_REQUEST);
         // 		print_r($_FILES);
         // 		print "\n]]>";
         print $this->getAssetXml($fileAsset);
         print $this->getQuota();
         $this->end();
     } catch (Exception $e) {
         $this->error($e->getMessage(), get_class($e));
     }
 }
 /**
  * Log an error or exception with the Logging OSID implemenation
  * 
  * @param string $type The type of error or exception that occurred
  * @param string $message A message.
  * @param array $backtrace
  * @param optional string $logName The name of the log to write to.
  * @param optional string $category A category for the error or exception.
  * @return void
  * @access public
  * @since 10/10/07
  * @static
  */
 public static function logMessage($type, $message, array $backtrace, $logName = 'Harmoni', $category = null)
 {
     /*********************************************************
      * Log the error in the default system log if the log_errors
      * directive is on.
      *********************************************************/
     if (ini_get('log_errors') === true || ini_get('log_errors') === 'On' || ini_get('log_errors') === '1') {
         error_log("PHP " . $type . ":  " . strip_tags($message));
     }
     /*********************************************************
      * Log the error using the Logging OSID if available.
      *********************************************************/
     // If we have an error in the error handler or the logging system,
     // don't infinitely loop trying to log the error of the error....
     $testBacktrace = debug_backtrace();
     for ($i = 1; $i < count($testBacktrace); $i++) {
         if (isset($testBacktrace[$i]['function']) && strtolower($testBacktrace[$i]['function']) == 'logMessage') {
             return;
         }
     }
     if (class_exists('Services') && Services::serviceRunning("Logging")) {
         $logName = preg_replace('/[^a-z0-9_\\s-.]/i', '', $logName);
         try {
             $loggingManager = Services::getService("Logging");
             $log = $loggingManager->getLogForWriting($logName);
             $formatType = new Type("logging", "edu.middlebury", "AgentsAndNodes", "A format in which the acting Agent[s] and the target nodes affected are specified.");
             $priorityType = new Type("logging", "edu.middlebury", strip_tags($type), "Events involving critical system errors.");
             $item = new AgentNodeEntryItem(strip_tags($category), HtmlString::getSafeHtml($message));
             $item->setBacktrace($backtrace);
             if (isset($_SERVER['REQUEST_URI'])) {
                 $item->addTextToBactrace("\n<div><strong>REQUEST_URI: </strong>" . $_SERVER['REQUEST_URI'] . "</div>");
             }
             if (isset($_SERVER['HTTP_REFERER'])) {
                 $item->addTextToBactrace("\n<div><strong>HTTP_REFERER: </strong>" . htmlspecialchars($_SERVER['HTTP_REFERER']) . "</div>");
             }
             if (isset($_SERVER['HTTP_USER_AGENT'])) {
                 $item->addTextToBactrace("\n<div><strong>HTTP_USER_AGENT: </strong><pre>" . htmlspecialchars(print_r($_SERVER['HTTP_USER_AGENT'], true)) . "</pre></div>");
             }
             // Log IP addresses of unauthenticated users for help in tracing
             // anonymous intrusion attempts. Currently not logging IP addresses
             // of logged-in users for privacy, even though visitor accounts
             // mean that logged-in users may be just as dangerous as anonymous ones.
             if (Services::serviceRunning("AuthN")) {
                 $authN = Services::getService("AuthN");
                 if (!$authN->isUserAuthenticatedWithAnyType()) {
                     if (isset($_SERVER['REMOTE_ADDR'])) {
                         $item->addTextToBactrace("\n<div><strong>REMOTE_ADDR: </strong><pre>" . htmlspecialchars($_SERVER['REMOTE_ADDR']) . "</pre></div>");
                     }
                     if (isset($_SERVER['REMOTE_HOST'])) {
                         $item->addTextToBactrace("\n<div><strong>REMOTE_HOST: </strong><pre>" . htmlspecialchars($_SERVER['REMOTE_HOST']) . "</pre></div>");
                     }
                 }
             }
             $item->addTextToBactrace("\n<div><strong>GET: </strong><pre>" . htmlspecialchars(print_r(self::stripPrivate($_GET), true)) . "</pre></div>");
             $item->addTextToBactrace("\n<div><strong>POST: </strong><pre>" . htmlspecialchars(print_r(self::stripPrivate($_POST), true)) . "</pre></div>");
             $log->appendLogWithTypes($item, $formatType, $priorityType);
         } catch (Exception $e) {
             // Just continue if we can't log the exception.
         }
     }
 }
Beispiel #11
0
 /**
  * Load the DC values for this asset
  * 
  * @return void
  * @access private
  * @since 4/27/07
  */
 function _loadDC()
 {
     if (!isset($this->_dcValues)) {
         $this->_dcValues = array('dc.title' => array(), 'dc.creator' => array(), 'dc.contributor' => array(), 'dc.description' => array(), 'dc.subject' => array(), 'dc.format' => array(), 'dc.publisher' => array(), 'dc.source' => array(), 'dc.rights' => array());
         $idManager = Services::getService("Id");
         $dcRecords = $this->_asset->getRecordsByRecordStructure($idManager->getId("dc"));
         if ($dcRecords->hasNext()) {
             $record = $dcRecords->next();
             foreach (array_keys($this->_dcValues) as $partIdString) {
                 $parts = $record->getPartsByPartStructure($idManager->getId($partIdString));
                 while ($parts->hasNext()) {
                     $part = $parts->next();
                     $value = $part->getValue();
                     $this->_dcValues[$partIdString][] = HtmlString::getSafeHtml($value->asString());
                 }
             }
             // Add on date objects
             $this->_dcValues['dc.date'] = array();
             $partIdString = 'dc.date';
             $parts = $record->getPartsByPartStructure($idManager->getId($partIdString));
             while ($parts->hasNext()) {
                 $part = $parts->next();
                 $this->_dcValues[$partIdString][] = $part->getValue();
             }
         } else {
             $this->_dcValues['dc.date'] = array();
         }
     }
 }
 /**
  * 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);
 }
    /**
     * Print out a custom error page for an exception with the HTTP status code
     * specified
     * 
     * @param object Exception $e
     * @param int $code
     * @return void
     * @access private
     * @since 2/21/08
     */
    private function printException(Exception $e, $code)
    {
        // Debugging mode for development, rethrow the exception
        if (defined('DISPLAY_ERROR_BACKTRACE') && DISPLAY_ERROR_BACKTRACE) {
            throw $e;
        } else {
            $message = HtmlString::getSafeHtml($e->getMessage());
            $codeString = self::getCodeString($code);
            $errorString = _('Error');
            if ($this->shouldLogException($e, $code)) {
                $logMessage = _('This error has been logged.');
            } else {
                $logMessage = '';
            }
            print <<<END
<html>\t
\t<head>
\t\t<title>{$code} {$codeString}</title>
\t\t<style>
\t\t\tbody {
\t\t\t\tbackground-color: #FFF8C6;
\t\t\t\tfont-family: Verdana, sans-serif;
\t\t\t}
\t\t\t
\t\t\t.header {
\t\t\t\theight: 65px;
\t\t\t\tborder-bottom: 1px dotted #333;
\t\t\t}
\t\t\t.concerto_name {
\t\t\t\tfont-family: Tahoma, sans-serif; 
\t\t\t\tfont-variant: small-caps; 
\t\t\t\tfont-weight: bold;
\t\t\t\tfont-size: 60px;
\t\t\t\tcolor: #333333;
\t\t\t\t
\t\t\t\tfloat: left;
\t\t\t}
\t\t\t
\t\t\t.error {
\t\t\t\tfont-size: 20px;
\t\t\t\tfont-weight: bold;
\t\t\t\tfloat: left;
\t\t\t\tmargin-top: 40px;
\t\t\t\tmargin-left: 20px;
\t\t\t}
\t\t\t
\t\t\tblockquote {
 \t\t\t\tmargin-bottom: 50px;
\t\t\t\tclear: both;
\t\t\t}
\t\t</style>
\t</head>
\t<body>
\t\t<div class='header'>
\t\t\t<div class='concerto_name'>Concerto</div> 
\t\t\t<div class='error'>{$errorString}</div>
\t\t</div>
\t\t<blockquote>
\t\t\t<h1>{$codeString}</h1>
\t\t\t<p>{$message}</p>
\t\t</blockquote>
\t\t<p>{$logMessage}</p>
\t</body>
</html>

END;
        }
    }
Beispiel #14
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;
 }
 /**
  * Add a Dublin Core Record to a media Asset.
  * 
  * @param object Asset $asset
  * @param object DOMElement $element
  * @return void
  * @access protected
  * @since 1/24/08
  */
 protected function addDublinCoreRecord(Asset $asset, DOMElement $element)
 {
     $idManager = Services::getService("Id");
     $record = $asset->createRecord($idManager->getId("dc"));
     $element->setAttribute('new_id', $record->getId()->getIdString());
     try {
         $value = String::fromString(HtmlString::getSafeHtml($asset->getDisplayName()));
         $id = $idManager->getId("dc.title");
         $this->updateSingleValuedPart($record, $id, $value);
     } catch (MissingNodeException $e) {
     }
     try {
         $value = String::fromString(HtmlString::getSafeHtml($asset->getDescription()));
         $id = $idManager->getId("dc.description");
         $this->updateSingleValuedPart($record, $id, $value);
     } catch (MissingNodeException $e) {
     }
     try {
         $valueElement = $this->getSingleElement('./creator', $element);
         if ($valueElement) {
             $value = String::fromString(HtmlString::getSafeHtml($this->getStringValue($valueElement)));
             $id = $idManager->getId("dc.creator");
             $this->updateSingleValuedPart($record, $id, $value);
         }
     } catch (MissingNodeException $e) {
     }
     try {
         $valueElement = $this->getSingleElement('./source', $element);
         if ($valueElement) {
             $value = String::fromString(HtmlString::getSafeHtml($this->getStringValue($valueElement)));
             $id = $idManager->getId("dc.source");
             $this->updateSingleValuedPart($record, $id, $value);
         }
     } catch (MissingNodeException $e) {
     }
     try {
         $valueElement = $this->getSingleElement('./publisher', $element);
         if ($valueElement) {
             $value = String::fromString(HtmlString::getSafeHtml($this->getStringValue($valueElement)));
             $id = $idManager->getId("dc.publisher");
             $this->updateSingleValuedPart($record, $id, $value);
         }
     } catch (MissingNodeException $e) {
     }
     try {
         $valueElement = $this->getSingleElement('./date', $element);
         if ($valueElement) {
             $value = DateAndTime::fromString($this->getStringValue($valueElement));
             $id = $idManager->getId("dc.date");
             $this->updateSingleValuedPart($record, $id, $value);
         }
     } catch (MissingNodeException $e) {
     }
 }
 /**
  * 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();
 }
 /**
  * Update the dublin core record with info from the form.
  * 
  * @param object Asset $asset
  * @param object Record $record
  * @return void
  * @access public
  * @since 1/30/07
  */
 function updateDublinCoreRecord($asset, $record)
 {
     $idManager = Services::getService("Id");
     $value = String::fromString(HtmlString::getSafeHtml($asset->getDisplayName()));
     $id = $idManager->getId("dc.title");
     $this->updateSingleValuedPart($record, $id, $value);
     $value = String::fromString(HtmlString::getSafeHtml($asset->getDescription()));
     $id = $idManager->getId("dc.description");
     $this->updateSingleValuedPart($record, $id, $value);
     $value = String::fromString(HtmlString::getSafeHtml(RequestContext::value('creator')));
     $id = $idManager->getId("dc.creator");
     $this->updateSingleValuedPart($record, $id, $value);
     $value = String::fromString(HtmlString::getSafeHtml(RequestContext::value('source')));
     $id = $idManager->getId("dc.source");
     $this->updateSingleValuedPart($record, $id, $value);
     $value = String::fromString(HtmlString::getSafeHtml(RequestContext::value('publisher')));
     $id = $idManager->getId("dc.publisher");
     $this->updateSingleValuedPart($record, $id, $value);
     $value = DateAndTime::fromString(RequestContext::value('date'));
     $id = $idManager->getId("dc.date");
     $this->updateSingleValuedPart($record, $id, $value);
 }
Beispiel #18
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>";
 }
 /**
  * Add HTML text to the bactrace, usefull for storing source URLs, etc
  * 
  * @param string $additionalText
  * @return void
  * @access public
  * @since 8/1/06
  */
 function addTextToBactrace($additionalText)
 {
     $this->_additionalBactraceText .= HtmlString::getSafeHtml($additionalText);
 }
Beispiel #20
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;
}
Beispiel #21
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;
 }
Beispiel #22
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;
}
 /**
  * Setup values
  * values of Answer
  *
  * @param Answer $o
  *
  * @return object $this
  */
 protected function makeAnswerPost(Answer $o)
 {
     d('cp');
     $qlink = $o->getUrl();
     /**
      * @todo Translate string
      *
      * @var string
      */
     $tpl = '<p>This is my answer to a <a href="%s"><strong>Question</strong></a> on %s</p><br>';
     $body = sprintf($tpl, $qlink, $this->Registry->Ini->SITE_NAME);
     $body .= $o->getBody();
     d('body: ' . $body);
     $body = HtmlString::stringFactory($body);
     $title = 'My answer to "' . $o->getTitle() . '"';
     $this->oEntry->setBody($body)->setTitle($title);
     return $this;
 }
Beispiel #24
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;
 }
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;
}
Beispiel #26
0
 /**
  * Print out a log entry
  * 
  * @param object Entry $entry
  * @return void
  * @access public
  * @since 8/7/06
  */
 function addEntry($entry)
 {
     $rssItem = $this->addItem(new RSSItem());
     $harmoni = Harmoni::instance();
     $agentManager = Services::getService("Agent");
     $hierarchyManager = Services::getService("Hierarchy");
     $timestamp = $entry->getTimestamp();
     $timestamp = $timestamp->asTimestamp();
     $item = $entry->getItem();
     $desc = HtmlString::fromString($item->getDescription());
     // a title
     $rssItem->setTitle($desc->stripTagsAndTrim(5));
     // Date of occurance
     $rssItem->setPubDate($timestamp);
     // A unique id...
     $rssItem->setGUID(md5($timestamp->asUnixTimeStamp() . $item->getDescription() . $item->getBacktrace()), false);
     // Category
     $rssItem->addCategory($item->getCategory());
     // Agent / 'author'
     $agentList = '';
     $agentIds = $item->getAgentIds(true);
     while ($agentIds->hasNext()) {
         $agentId = $agentIds->next();
         if ($agentManager->isAgent($agentId) || $agentManager->isGroup($agentId)) {
             $agent = $agentManager->getAgent($agentId);
             $agentList .= $agent->getDisplayName();
         } else {
             $agentList .= _("Id: ") . $agentId->getIdString();
         }
         if ($agentIds->hasNext()) {
             $agentList .= ", ";
         }
     }
     $rssItem->setAuthor($agentList);
     // Agents with links
     ob_start();
     $agentIds = $item->getAgentIds(true);
     $authorList = '';
     while ($agentIds->hasNext()) {
         $agentId = $agentIds->next();
         if ($agentManager->isAgent($agentId) || $agentManager->isGroup($agentId)) {
             $agent = $agentManager->getAgent($agentId);
             print "<a href='";
             print $harmoni->request->quickURL("logs", "browse", array("agent_id" => $agentId->getIdString()));
             print "'>";
             print $agent->getDisplayName();
             print "</a>";
             $authorList .= $agent->getDisplayName();
         } else {
             print _("Id: ") . $agentId->getIdString();
             $authorList .= _("Id: ") . $agentId->getIdString();
         }
         if ($agentIds->hasNext()) {
             print ", <br/>";
             $authorList .= ", ";
         }
     }
     $agentList = ob_get_clean();
     // Nodes
     ob_start();
     $nodeIds = $item->getNodeIds(true);
     while ($nodeIds->hasNext()) {
         $nodeId = $nodeIds->next();
         print "<a href='";
         print $harmoni->request->quickURL("logs", "browse", array("node_id" => $nodeId->getIdString()));
         print "'>";
         if ($hierarchyManager->nodeExists($nodeId)) {
             $node = $hierarchyManager->getNode($nodeId);
             if ($node->getDisplayName()) {
                 print $node->getDisplayName();
             } else {
                 print _("Id: ") . $nodeId->getIdString();
             }
         } else {
             print _("Id: ") . $nodeId->getIdString();
         }
         print "</a>";
         if ($nodeIds->hasNext()) {
             print ", <br/>";
         }
     }
     $nodeList = ob_get_clean();
     // Description text
     ob_start();
     print "\n\t\t\t\t<dl>";
     print "\n\t\t\t\t\t<dt style='font-weight: bold;'>" . _("Date: ") . "</dt>";
     print "\n\t\t\t\t\t<dd style='margin-bottom: 20px;'>";
     print $timestamp->monthName() . " ";
     print $timestamp->dayOfMonth() . ", ";
     print $timestamp->year() . " ";
     print $timestamp->hmsString();
     print "</dd>";
     print "\n\t\t\t\t\t<dt style='font-weight: bold;'>" . _("Category: ") . "</dt>";
     print "\n\t\t\t\t\t<dd style='margin-bottom: 20px;'>" . $item->getCategory() . "</dd>";
     print "\n\t\t\t\t\t<dt style='font-weight: bold;'>" . _("Description: ") . "</dt>";
     $desc->clean();
     print "\n\t\t\t\t\t<dd style='margin-bottom: 20px;'>" . $desc->asString() . "</dd>";
     print "\n\t\t\t\t\t<dt style='font-weight: bold;'>" . _("Agents: ") . "</dt>";
     print "\n\t\t\t\t\t<dd style='margin-bottom: 20px;'>" . $agentList . "</dd>";
     print "\n\t\t\t\t\t<dt style='font-weight: bold;'>" . _("Nodes: ") . "</dt>";
     print "\n\t\t\t\t\t<dd style='margin-bottom: 20px;'>" . $nodeList . "</dd>";
     print "\n\t\t\t\t\t<dt style='font-weight: bold;'>" . _("Backtrace: ") . "</dt>";
     print "\n\t\t\t\t\t<dd style='margin-bottom: 20px;'>" . $item->getBacktrace() . "</dd>";
     print "\n\t\t\t\t</dl>";
     $rssItem->setDescription(ob_get_clean());
 }
Beispiel #27
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);
 }
Beispiel #28
0
 /**
  * Update the subject
  * 
  * @param string $subject
  * @return void
  * @access public
  * @since 7/11/07
  */
 function updateSubject($subject)
 {
     // Check Authorizations
     $authZ = Services::getService('AuthZ');
     if (!$this->canModify()) {
         throw new PermissionDeniedException("You are not authorized to change this comment.");
     }
     if ($subject) {
         $this->_asset->updateDisplayName(HtmlString::getSafeHtml($subject));
     } else {
         $this->_asset->updateDisplayName(_("(untitled)"));
     }
     CommentManager::logMessage('Comment Subject Updated', CommentManager::getCommentParentAsset($this), array($this->getId()));
 }
Beispiel #29
0
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;
}
Beispiel #30
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>";
 }