Beispiel #1
0
 /**
  * Answer the comment object
  * 
  * @return object
  * @access public
  * @since 7/11/07
  */
 function getComment()
 {
     $idManager = Services::getService("Id");
     $commentId = $idManager->getId(RequestContext::value('comment_id'));
     $commentManager = CommentManager::instance();
     return $commentManager->getComment($commentId);
 }
 /**
  * Visit a Block
  * 
  * @param object BlockSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 1/26/09
  */
 public function visitBlock(BlockSiteComponent $siteComponent)
 {
     $view = new Participation_View($siteComponent);
     $idMgr = Services::getService('Id');
     $azMgr = Services::getService('AuthZ');
     // get create actions
     if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $siteComponent->getQualifierId()) == TRUE) {
         $this->_actions[] = new Participation_CreateAction($view, $siteComponent);
     }
     // get comment actions
     $commentsManager = CommentManager::instance();
     $comments = $commentsManager->getAllComments($siteComponent->getAsset(), DESC);
     while ($comments->hasNext()) {
         $comment = $comments->next();
         if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.comment'), $siteComponent->getQualifierId()) == TRUE) {
             $this->_actions[] = new Participation_CommentAction($view, $comment);
         }
     }
     // get history actions
     $pluginManager = Services::getService('PluginManager');
     $plugin = $pluginManager->getPlugin($siteComponent->getAsset());
     if ($plugin->supportsVersioning()) {
         $versions = $plugin->getVersions();
         $firstVersion = 0;
         foreach ($versions as $version) {
             if ($version->getNumber() != 1) {
                 if ($azMgr->isUserAuthorized($idMgr->getId('edu.middlebury.authorization.modify'), $siteComponent->getQualifierId()) == TRUE) {
                     $this->_actions[] = new Participation_HistoryAction($view, $siteComponent, $version);
                 }
             }
         }
     }
 }
Beispiel #3
0
 /**
  * Visit a Block
  * 
  * @param object BlockSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 8/31/07
  */
 public function visitBlock(BlockSiteComponent $siteComponent)
 {
     // check to see if user is authorized to view block
     $authZ = Services::getService("AuthZ");
     $idManager = Services::getService("Id");
     if (!$authZ->isUserAuthorized($idManager->getId("edu.middlebury.authorization.view_comments"), $idManager->getId($siteComponent->getId()))) {
         return;
     }
     $harmoni = Harmoni::instance();
     //get all comments for site component
     $commentsManager = CommentManager::instance();
     $comments = $commentsManager->getAllComments($siteComponent->getAsset());
     while ($comments->hasNext()) {
         $comment = $comments->next();
         $item = $this->addItem(new RSSItem());
         $item->setTitle($comment->getSubject());
         $item->setLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId())) . "#comment_" . $comment->getIdString(), true);
         $item->setPubDate($comment->getModificationDate());
         $agentMgr = Services::getService("Agent");
         $agent = $comment->getAuthor();
         $item->setAuthor($agent->getDisplayName());
         $item->setCommentsLink(SiteDispatcher::quickURL("view", "html", array("node" => $siteComponent->getId())));
         $pluginMgr = Services::getService("PluginManager");
         $plugin = $pluginMgr->getPlugin($comment->getAsset());
         $item->setDescription($plugin->executeAndGetMarkup());
         // MediaFile eclosures.
         try {
             foreach ($plugin->getRelatedMediaFiles() as $file) {
                 $item->addEnclosure($file->getUrl(), $file->getSize()->value(), $file->getMimeType());
             }
         } catch (UnimplementedException $e) {
         }
     }
 }
 /**
  * Visit a Block
  * 
  * @param object BlockSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 8/31/07
  */
 public function visitBlock(BlockSiteComponent $siteComponent)
 {
     $cm = CommentManager::instance();
     if ($cm->getNumComments($siteComponent->getAsset())) {
         return 1;
     } else {
         return 0;
     }
 }
 /**
  * Visit a block and return the resulting GUI component.
  * 
  * @param object BlockSiteComponent $block
  * @return object Component 
  * @access public
  * @since 4/3/06
  */
 function visitTargetBlock()
 {
     $block = $this->_node;
     $guiContainer = parent::visitBlock($block);
     if ($guiContainer && $block->showComments()) {
         $commentManager = CommentManager::instance();
         $guiContainer->add(new Heading($commentManager->getHeadingMarkup($block->getAsset()), 3), $block->getWidth(), null, null, TOP);
         $guiContainer->add(new Block($commentManager->getMarkup($block->getAsset()), STANDARD_BLOCK), $block->getWidth(), null, null, TOP);
     }
     return $guiContainer;
 }
 /**
  * Build the content for this action
  * 
  * @return boolean
  * @access public
  * @since 4/26/05
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     // Get the plugin asset id
     $harmoni->request->startNamespace('plugin_manager');
     $id = RequestContext::value('plugin_id');
     if (RequestContext::value('extended') == 'true') {
         $showExtended = true;
     } else {
         $showExtended = false;
     }
     $harmoni->request->endNamespace();
     // Get the plugin asset object
     $repositoryManager = Services::getService("Repository");
     $idManager = Services::getService("Id");
     // 		$repository = $repositoryManager->getRepository(
     // 			$idManager->getId("edu.middlebury.segue.sites_repository"));
     //
     // 		$asset = $repository->getAsset($idManager->getId($id));
     //
     // // 		$pluginManager = Services::getService("Plugs");
     // // 		$plugin = $pluginManager->getPlugin($asset);
     // //
     // // 		$plugin->setUpdateAction('comments', 'update_ajax');
     $commentManager = CommentManager::instance();
     $comment = $commentManager->getComment($idManager->getId($id));
     header("Content-type: text/xml");
     print "<plugin>\n";
     if (!is_object($comment)) {
         print "\t<markup>\n\t\t<![CDATA[";
         print $comment;
         print "]]>\n\t</markup>\n";
     } else {
         $markup = $comment->getBody();
         print "\t<markup>\n\t\t<![CDATA[";
         // CDATA sections cannot contain ']]>' and therefor cannot be nested
         // get around this by replacing the ']]>' tags in the markup.
         print preg_replace('/\\]\\]>/', '}}>', $markup);
         print "]]>\n\t</markup>\n";
     }
     print "</plugin>";
     exit;
 }
 /**
  * Answer an element that represents the comments attached to a block.
  * 
  * @param BlockSiteComponent $siteComponent
  * @return DOMElement
  * @access protected
  */
 protected function addComments(BlockSiteComponent $siteComponent)
 {
     if ($this->isAuthorizedToExportComments($siteComponent)) {
         $commentMgr = CommentManager::instance();
         $idMgr = Services::getService("Id");
         $comments = $commentMgr->getAllComments($idMgr->getId($siteComponent->getId()));
         while ($comments->hasNext()) {
             $this->addCommentAttachedMedia($comments->next());
         }
     }
 }
 /**
  * Visit a Block
  * 
  * @param object BlockSiteComponent $siteComponent
  * @return mixed
  * @access public
  * @since 8/5/08
  */
 public function visitBlock(BlockSiteComponent $siteComponent)
 {
     if (!$this->firstSeen) {
         $this->firstSeen = true;
     } else {
         $this->blocks++;
     }
     // Discussions
     $cm = CommentManager::instance();
     $this->posts += $cm->getNumComments($siteComponent->getAsset());
     // Media
     $mediaAssets = $this->getAllMediaAssets($siteComponent->getAsset());
     $this->media += $mediaAssets->count();
 }
Beispiel #9
0
 /**
  * Answer the Content asset that a comment is attached to
  * 
  * @param object Id $commentId
  * @return object Asset
  * @access public
  * @static
  * @since 11/9/07
  */
 public function getParentComment()
 {
     $commentManager = CommentManager::instance();
     $commentContainerType = new Type('segue', 'edu.middlebury', 'comment_container', 'A container for Segue Comments');
     $parent = $this->_asset->getParents()->next();
     if ($commentContainerType->isEqual($parent->getAssetType())) {
         return null;
     } else {
         return $commentManager->getComment($parent);
     }
 }
 /**
  * add an elements that represents the comments attached to a block.
  * 
  * @param BlockSiteComponent $siteComponent
  * @access protected
  */
 protected function addComments(BlockSiteComponent $siteComponent, DOMElement $item)
 {
     if ($this->isAuthorizedToExport($siteComponent)) {
         $commentMgr = CommentManager::instance();
         $idMgr = Services::getService("Id");
         $comments = $commentMgr->getAllComments($idMgr->getId($siteComponent->getId()));
         while ($comments->hasNext()) {
             $item->appendChild($this->getComment($comments->next()));
         }
     }
 }
Beispiel #11
0
 /**
  * Execute the Action
  * 
  * @param object Harmoni $harmoni
  * @return mixed
  * @access public
  */
 function execute()
 {
     $harmoni = Harmoni::instance();
     /*********************************************************
      * Split sites based on their location-category
      *********************************************************/
     $rootSiteComponent = SiteDispatcher::getCurrentRootNode();
     try {
         $slot = $rootSiteComponent->getSlot();
         // Mark the site as viewed
         Segue_AccessLog::instance()->touch($slot->getShortname());
     } catch (UnknownIdException $e) {
         // No slot for the site....
     }
     $authZ = Services::getService("AuthZ");
     $recordManager = Services::getService("RecordManager");
     //
     // Begin Optimizations
     //
     // The code below queues up authorizations for all visible nodes,
     // as well as pre-fetches all of the RecordSets that have data
     // specific to the visible nodes.
     $visibleComponents = SiteDispatcher::getSiteDirector()->getVisibleComponents(SiteDispatcher::getCurrentNodeId());
     $preCacheIds = array();
     foreach ($visibleComponents as $component) {
         $id = $component->getQualifierId();
         $authZ->getIsAuthorizedCache()->queueId($id);
         $preCacheIds[] = $id->getIdString();
     }
     $recordManager->preCacheRecordsFromRecordSetIDs($preCacheIds);
     //
     // End Optimizations
     //
     $this->mainScreen = new Container(new YLayout(), BLOCK, BACKGROUND_BLOCK);
     $this->addHead($this->mainScreen);
     CommentManager::instance()->disableCommenting();
     CommentManager::instance()->disableSorting();
     $this->addSiteContent($this->mainScreen);
     return $this->mainScreen;
 }
 /**
  * Apply data to a comment
  * 
  * @param object CommentNode $comment
  * @param object DOMElement $element
  * @return void
  * @access protected
  * @since 1/24/08
  */
 protected function applyCommentData(CommentNode $comment, DOMElement $element)
 {
     $element->setAttribute('new_id', $comment->getId()->getIdString());
     $comment->updateSubject($this->getStringValue($this->getSingleChild('subject', $element)));
     $this->applyPluginContent($comment->getAsset(), $element);
     $this->applyMedia($comment->getAsset(), $element);
     $this->setAssetAuthorship($comment->getAsset(), $element);
     $this->setAssetDates($comment->getAsset(), $element);
     if (isset($this->status)) {
         $this->status->updateStatistics();
     }
     // Replies
     $commentMgr = CommentManager::instance();
     $replyElements = $this->xpath->query('./replies/Comment', $element);
     foreach ($replyElements as $replyElement) {
         $reply = $commentMgr->createReply($comment->getId(), new Type($this->getSingleNode("./type/domain/text()", $replyElement)->nodeValue, $this->getSingleNode("./type/authority/text()", $replyElement)->nodeValue, $this->getSingleNode("./type/keyword/text()", $replyElement)->nodeValue));
         $this->applyCommentData($reply, $replyElement);
     }
 }
 /**
  * Answer the Content asset that a comment is attached to
  * 
  * @param object Id $commentId
  * @return object Asset
  * @access public
  * @static
  * @since 11/9/07
  */
 public static function getCommentParentAsset(CommentNode $comment)
 {
     $manager = CommentManager::instance();
     $commentContainerType = new Type('segue', 'edu.middlebury', 'comment_container', 'A container for Segue Comments');
     $parent = $comment->_asset->getParents()->next();
     while (!$commentContainerType->isEqual($parent->getAssetType())) {
         $parent = $parent->getParents()->next();
     }
     return $parent->getParents()->next();
 }
 /**
  * Answer the plugin content for a block
  * 
  * @param object BlockSiteComponent $block
  * @return string
  * @access public
  * @since 5/23/07
  */
 function getPluginContent($block, $inMenu = false)
 {
     ob_start();
     $harmoni = Harmoni::instance();
     $pluginManager = Services::getService('PluginManager');
     $plugin = $pluginManager->getPlugin($block->getAsset());
     print "\n<div class='plugin_content'>";
     print $plugin->executeAndGetMarkup($this->showPluginControls());
     print "\n</div>";
     if ($block->showComments() && !$inMenu) {
         $cm = CommentManager::instance();
         print "\n<div class='comments'>";
         print "\n\t<a href='" . $this->getDetailUrl($block->getId()) . "#";
         $harmoni->request->startNamespace("comments");
         print RequestContext::name('top') . "'>";
         $harmoni->request->endNamespace();
         print str_replace("%1", $cm->getNumComments($block->getAsset()), _("Discuss (%1 posts) &raquo;"));
         print "</a>";
         print "\n</div>";
     }
     // print out attribution based on block settings
     $attribution = new AttributionPrinter($block);
     $attributionDisplay = $attribution->getAttributionMarkUp();
     if (!is_null($attributionDisplay) && strlen($attributionDisplay)) {
         print $attributionDisplay;
     }
     if (!$inMenu) {
         print "\n<div class='extended_content_link' id='extended_content_link:" . $block->getId() . "' ";
         print " style='text-align: right;";
         if (!$plugin->hasExtendedMarkup()) {
             print " display: none;";
         }
         print "'>";
         print "\n\t<a href='" . $this->getDetailUrl($block->getId()) . "'>";
         print $plugin->getExtendedLinkLabel();
         print "</a>";
         print "\n</div>";
     }
     print $this->getHistoryLink($block, $plugin);
     print "\n<div class='no_float_spacer'></div>";
     return ob_get_clean();
 }
 /**
  * get url of node that action is applied to
  * 
  * @return string
  * @access public
  * @since 1/23/09
  */
 public function getTargetUrl()
 {
     $commentsManager = CommentManager::instance();
     $nodeId = $commentsManager->getCommentParentAsset($this->_comment)->getId()->getIdString();
     $commentId = $this->_comment->getId()->getIdString();
     return SiteDispatcher::quickURL('view', 'html', array('node' => $nodeId)) . '#' . $commentId;
 }