Beispiel #1
0
 /**
  * Answer the comment body.
  * 
  * @param optional boolean $showControls Defaults to true.
  * @return string
  * @access public
  * @since 7/3/07
  */
 function getBody($showControls = true)
 {
     // Only return a body if we are authorized to view the comment
     if ($this->canView()) {
         $pluginManager = Services::getService('PluginManager');
         $plugin = $pluginManager->getPlugin($this->_asset);
         // Attach the owning Site component
         $owningAsset = CommentManager::getCommentParentAsset($this);
         $director = SiteDispatcher::getSiteDirector();
         $owningComponent = $director->getSiteComponentFromAsset($owningAsset);
         $plugin->setRelatedSiteComponent($owningComponent);
         try {
             $plugin->setUpdateAction('comments', 'update_plugin_ajax');
         } catch (UnimplementedException $e) {
         }
         // We've just checked our view permission, so use true
         $plugin->setCanViewFunction(create_function('$plugin', 'return true;'));
         if ($this->canModify() && $showControls) {
             $plugin->setCanModifyFunction(create_function('$plugin', 'return true;'));
             return $plugin->executeAndGetMarkup(true);
         } else {
             $plugin->setCanModifyFunction('$plugin', 'return false;');
             return $plugin->executeAndGetMarkup(false);
         }
     } else {
         return _("You are not authorized to view this comment.");
     }
 }