original_string: public static function get_comments($contextlevel, $instanceid, $component, $itemid, $area = '', $page = 0) {
  
          $warnings = array();
          $arrayparams = array(
              'contextlevel' => $contextlevel,
              'instanceid'   => $instanceid,
              'component'    => $component,
              'itemid'       => $itemid,
              'area'         => $area,
              'page'         => $page
          );
          $params = self::validate_parameters(self::get_comments_parameters(), $arrayparams);
  
          $context = self::get_context_from_params($params);
          self::validate_context($context);
  
          require_capability('moodle/comment:view', $context);
  
          $args = new stdClass;
          $args->context   = $context;
          $args->area      = $params['area'];
          $args->itemid    = $params['itemid'];
          $args->component = $params['component'];
  
          $commentobject = new comment($args);
          $comments = $commentobject->get_comments($params['page']);
  
          // False means no permissions to see comments.
          if ($comments === false) {
              throw new moodle_exception('nopermissions', 'error', '', 'view comments');
          }
          $options = array('blanktarget' => true);
  
          foreach ($comments as $key => $comment) {
  
                  list($comments[$key]->content, $comments[$key]->format) = external_format_text($comment->content,
                                                                                                   $comment->format,
                                                                                                   $context->id,
                                                                                                   $params['component'],
                                                                                                   '',
                                                                                                   0,
                                                                                                   $options);
          }
  
          $results = array(
              'comments' => $comments,
              'warnings' => $warnings
          );
          return $results;
      }
code: public static function get_comments($contextlevel, $instanceid, $component, $itemid, $area = '', $page = 0) {
  
          $warnings = array();
          $arrayparams = array(
              'contextlevel' => $contextlevel,
              'instanceid'   => $instanceid,
              'component'    => $component,
              'itemid'       => $itemid,
              'area'         => $area,
              'page'         => $page
          );
          $params = self::validate_parameters(self::get_comments_parameters(), $arrayparams);
  
          $context = self::get_context_from_params($params);
          self::validate_context($context);
  
          require_capability('moodle/comment:view', $context);
  
          $args = new stdClass;
          $args->context   = $context;
          $args->area      = $params['area'];
          $args->itemid    = $params['itemid'];
          $args->component = $params['component'];
  
          $commentobject = new comment($args);
          $comments = $commentobject->get_comments($params['page']);
  
          // False means no permissions to see comments.
          if ($comments === false) {
              throw new moodle_exception('nopermissions', 'error', '', 'view comments');
          }
          $options = array('blanktarget' => true);
  
          foreach ($comments as $key => $comment) {
  
                  list($comments[$key]->content, $comments[$key]->format) = external_format_text($comment->content,
                                                                                                   $comment->format,
                                                                                                   $context->id,
                                                                                                   $params['component'],
                                                                                                   '',
                                                                                                   0,
                                                                                                   $options);
          }
  
          $results = array(
              'comments' => $comments,
              'warnings' => $warnings
          );
          return $results;
      }
code_tokens: public static function get_comments ( $ contextlevel , $ instanceid , $ component , $ itemid , $ area = '' , $ page = 0 ) { $ warnings = array ( ) ; $ arrayparams = array ( 'contextlevel' => $ contextlevel , 'instanceid' => $ instanceid , 'component' => $ component , 'itemid' => $ itemid , 'area' => $ area , 'page' => $ page ) ; $ params = self :: validate_parameters ( self :: get_comments_parameters ( ) , $ arrayparams ) ; $ context = self :: get_context_from_params ( $ params ) ; self :: validate_context ( $ context ) ; require_capability ( 'moodle/comment:view' , $ context ) ; $ args = new stdClass ; $ args -> context = $ context ; $ args -> area = $ params [ 'area' ] ; $ args -> itemid = $ params [ 'itemid' ] ; $ args -> component = $ params [ 'component' ] ; $ commentobject = new comment ( $ args ) ; $ comments = $ commentobject -> get_comments ( $ params [ 'page' ] ) ; // False means no permissions to see comments. if ( $ comments === false ) { throw new moodle_exception ( 'nopermissions' , 'error' , '' , 'view comments' ) ; } $ options = array ( 'blanktarget' => true ) ; foreach ( $ comments as $ key => $ comment ) { list ( $ comments [ $ key ] -> content , $ comments [ $ key ] -> format ) = external_format_text ( $ comment -> content , $ comment -> format , $ context -> id , $ params [ 'component' ] , '' , 0 , $ options ) ; } $ results = array ( 'comments' => $ comments , 'warnings' => $ warnings ) ; return $ results ; }
docstring: Return a list of comments
  
  @param string $contextlevel ('system, course, user', etc..)
  @param int $instanceid
  @param string $component the name of the component
  @param int $itemid the item id
  @param string $area comment area
  @param int $page page number
  @return array of comments and warnings
  @since Moodle 2.9
docstring_tokens: Return a list of comments