original_string: public function set_fields($fields, $output) {
          $this->fields = $fields;
          $this->head = array();
          $this->colclasses = array();
          $this->align = array();
          $url = $this->manager->get_moodlepage()->url;
  
          if (!empty($this->bulkoperations)) {
              // If there are bulk operations add a column for checkboxes.
              $this->head[] = '';
              $this->colclasses[] = 'field col_bulkops';
          }
  
          foreach ($fields as $name => $label) {
              $newlabel = '';
              if (is_array($label)) {
                  $bits = array();
                  foreach ($label as $n => $l) {
                      if ($l === false) {
                          continue;
                      }
                      if (!in_array($n, self::$sortablefields)) {
                          $bits[] = $l;
                      } else {
                          $sorturl = new moodle_url($url, array(self::SORTVAR => $n, self::SORTDIRECTIONVAR => $this->get_field_sort_direction($n)));
                          $link = html_writer::link($sorturl, $fields[$name][$n]);
                          if ($this->sort == $n) {
                              $link .= $this->get_direction_icon($output, $n);
                          }
                          $bits[] = html_writer::tag('span', $link, array('class'=>'subheading_'.$n));
  
                      }
                  }
                  $newlabel = join(' / ', $bits);
              } else {
                  if (!in_array($name, self::$sortablefields)) {
                      $newlabel = $label;
                  } else {
                      $sorturl = new moodle_url($url, array(self::SORTVAR => $name, self::SORTDIRECTIONVAR => $this->get_field_sort_direction($name)));
                      $newlabel  = html_writer::link($sorturl, $fields[$name]);
                      if ($this->sort == $name) {
                          $newlabel .= $this->get_direction_icon($output, $name);
                      }
                  }
              }
              $this->head[] = $newlabel;
              $this->colclasses[] = 'field col_'.$name;
          }
      }
code: public function set_fields($fields, $output) {
          $this->fields = $fields;
          $this->head = array();
          $this->colclasses = array();
          $this->align = array();
          $url = $this->manager->get_moodlepage()->url;
  
          if (!empty($this->bulkoperations)) {
              // If there are bulk operations add a column for checkboxes.
              $this->head[] = '';
              $this->colclasses[] = 'field col_bulkops';
          }
  
          foreach ($fields as $name => $label) {
              $newlabel = '';
              if (is_array($label)) {
                  $bits = array();
                  foreach ($label as $n => $l) {
                      if ($l === false) {
                          continue;
                      }
                      if (!in_array($n, self::$sortablefields)) {
                          $bits[] = $l;
                      } else {
                          $sorturl = new moodle_url($url, array(self::SORTVAR => $n, self::SORTDIRECTIONVAR => $this->get_field_sort_direction($n)));
                          $link = html_writer::link($sorturl, $fields[$name][$n]);
                          if ($this->sort == $n) {
                              $link .= $this->get_direction_icon($output, $n);
                          }
                          $bits[] = html_writer::tag('span', $link, array('class'=>'subheading_'.$n));
  
                      }
                  }
                  $newlabel = join(' / ', $bits);
              } else {
                  if (!in_array($name, self::$sortablefields)) {
                      $newlabel = $label;
                  } else {
                      $sorturl = new moodle_url($url, array(self::SORTVAR => $name, self::SORTDIRECTIONVAR => $this->get_field_sort_direction($name)));
                      $newlabel  = html_writer::link($sorturl, $fields[$name]);
                      if ($this->sort == $name) {
                          $newlabel .= $this->get_direction_icon($output, $name);
                      }
                  }
              }
              $this->head[] = $newlabel;
              $this->colclasses[] = 'field col_'.$name;
          }
      }
code_tokens: public function set_fields ( $ fields , $ output ) { $ this -> fields = $ fields ; $ this -> head = array ( ) ; $ this -> colclasses = array ( ) ; $ this -> align = array ( ) ; $ url = $ this -> manager -> get_moodlepage ( ) -> url ; if ( ! empty ( $ this -> bulkoperations ) ) { // If there are bulk operations add a column for checkboxes. $ this -> head [ ] = '' ; $ this -> colclasses [ ] = 'field col_bulkops' ; } foreach ( $ fields as $ name => $ label ) { $ newlabel = '' ; if ( is_array ( $ label ) ) { $ bits = array ( ) ; foreach ( $ label as $ n => $ l ) { if ( $ l === false ) { continue ; } if ( ! in_array ( $ n , self :: $ sortablefields ) ) { $ bits [ ] = $ l ; } else { $ sorturl = new moodle_url ( $ url , array ( self :: SORTVAR => $ n , self :: SORTDIRECTIONVAR => $ this -> get_field_sort_direction ( $ n ) ) ) ; $ link = html_writer :: link ( $ sorturl , $ fields [ $ name ] [ $ n ] ) ; if ( $ this -> sort == $ n ) { $ link .= $ this -> get_direction_icon ( $ output , $ n ) ; } $ bits [ ] = html_writer :: tag ( 'span' , $ link , array ( 'class' => 'subheading_' . $ n ) ) ; } } $ newlabel = join ( ' / ' , $ bits ) ; } else { if ( ! in_array ( $ name , self :: $ sortablefields ) ) { $ newlabel = $ label ; } else { $ sorturl = new moodle_url ( $ url , array ( self :: SORTVAR => $ name , self :: SORTDIRECTIONVAR => $ this -> get_field_sort_direction ( $ name ) ) ) ; $ newlabel = html_writer :: link ( $ sorturl , $ fields [ $ name ] ) ; if ( $ this -> sort == $ name ) { $ newlabel .= $ this -> get_direction_icon ( $ output , $ name ) ; } } } $ this -> head [ ] = $ newlabel ; $ this -> colclasses [ ] = 'field col_' . $ name ; } }
docstring: Sets the fields for this table. These get added to the tables head as well.
  
  You can also use a multi dimensional array for this to have multiple fields
  in a single column
  
  @param array $fields An array of fields to set
  @param string $output
docstring_tokens: Sets the fields for this table . These get added to the tables head as well .