original_string: public function print_comment($cmt, $nonjs = true) {
          global $OUTPUT;
          $patterns = array();
          $replacements = array();
  
          if (!empty($cmt->delete) && empty($nonjs)) {
              $strdelete = get_string('deletecommentbyon', 'moodle', (object)['user' => $cmt->fullname, 'time' => $cmt->time]);
              $deletelink  = html_writer::start_tag('div', array('class'=>'comment-delete'));
              $deletelink .= html_writer::start_tag('a', array('href' => '#', 'id' => 'comment-delete-'.$this->cid.'-'.$cmt->id,
                                                               'title' => $strdelete));
  
              $deletelink .= $OUTPUT->pix_icon('t/delete', get_string('delete'));
              $deletelink .= html_writer::end_tag('a');
              $deletelink .= html_writer::end_tag('div');
              $cmt->content = $deletelink . $cmt->content;
          }
          $patterns[] = '___picture___';
          $patterns[] = '___name___';
          $patterns[] = '___content___';
          $patterns[] = '___time___';
          $replacements[] = $cmt->avatar;
          $replacements[] = html_writer::link($cmt->profileurl, $cmt->fullname);
          $replacements[] = $cmt->content;
          $replacements[] = $cmt->time;
  
          // use html template to format a single comment.
          return str_replace($patterns, $replacements, $this->template);
      }
code: public function print_comment($cmt, $nonjs = true) {
          global $OUTPUT;
          $patterns = array();
          $replacements = array();
  
          if (!empty($cmt->delete) && empty($nonjs)) {
              $strdelete = get_string('deletecommentbyon', 'moodle', (object)['user' => $cmt->fullname, 'time' => $cmt->time]);
              $deletelink  = html_writer::start_tag('div', array('class'=>'comment-delete'));
              $deletelink .= html_writer::start_tag('a', array('href' => '#', 'id' => 'comment-delete-'.$this->cid.'-'.$cmt->id,
                                                               'title' => $strdelete));
  
              $deletelink .= $OUTPUT->pix_icon('t/delete', get_string('delete'));
              $deletelink .= html_writer::end_tag('a');
              $deletelink .= html_writer::end_tag('div');
              $cmt->content = $deletelink . $cmt->content;
          }
          $patterns[] = '___picture___';
          $patterns[] = '___name___';
          $patterns[] = '___content___';
          $patterns[] = '___time___';
          $replacements[] = $cmt->avatar;
          $replacements[] = html_writer::link($cmt->profileurl, $cmt->fullname);
          $replacements[] = $cmt->content;
          $replacements[] = $cmt->time;
  
          // use html template to format a single comment.
          return str_replace($patterns, $replacements, $this->template);
      }
code_tokens: public function print_comment ( $ cmt , $ nonjs = true ) { global $ OUTPUT ; $ patterns = array ( ) ; $ replacements = array ( ) ; if ( ! empty ( $ cmt -> delete ) && empty ( $ nonjs ) ) { $ strdelete = get_string ( 'deletecommentbyon' , 'moodle' , ( object ) [ 'user' => $ cmt -> fullname , 'time' => $ cmt -> time ] ) ; $ deletelink = html_writer :: start_tag ( 'div' , array ( 'class' => 'comment-delete' ) ) ; $ deletelink .= html_writer :: start_tag ( 'a' , array ( 'href' => '#' , 'id' => 'comment-delete-' . $ this -> cid . '-' . $ cmt -> id , 'title' => $ strdelete ) ) ; $ deletelink .= $ OUTPUT -> pix_icon ( 't/delete' , get_string ( 'delete' ) ) ; $ deletelink .= html_writer :: end_tag ( 'a' ) ; $ deletelink .= html_writer :: end_tag ( 'div' ) ; $ cmt -> content = $ deletelink . $ cmt -> content ; } $ patterns [ ] = '___picture___' ; $ patterns [ ] = '___name___' ; $ patterns [ ] = '___content___' ; $ patterns [ ] = '___time___' ; $ replacements [ ] = $ cmt -> avatar ; $ replacements [ ] = html_writer :: link ( $ cmt -> profileurl , $ cmt -> fullname ) ; $ replacements [ ] = $ cmt -> content ; $ replacements [ ] = $ cmt -> time ; // use html template to format a single comment. return str_replace ( $ patterns , $ replacements , $ this -> template ) ; }
docstring: Returns an array containing comments in HTML format.
  
  @global core_renderer $OUTPUT
  @param stdClass $cmt {
  id => int comment id
  content => string comment content
  format  => int comment text format
  timecreated => int comment's timecreated
  profileurl  => string link to user profile
  fullname    => comment author's full name
  avatar      => string user's avatar
  delete      => boolean does user have permission to delete comment?
  }
  @param bool $nonjs
  @return array
docstring_tokens: Returns an array containing comments in HTML format .