original_string: public function tree_block_contents($items, $attrs = array()) {
          // exit if empty, we don't want an empty ul element
          if (empty($items)) {
              return '';
          }
          // array of nested li elements
          $lis = array();
          foreach ($items as $item) {
              // this applies to the li item which contains all child lists too
              $content = $item->content($this);
              $liclasses = array($item->get_css_type());
              if (!$item->forceopen || (!$item->forceopen && $item->collapse) || ($item->children->count()==0  && $item->nodetype==navigation_node::NODETYPE_BRANCH)) {
                  $liclasses[] = 'collapsed';
              }
              if ($item->isactive === true) {
                  $liclasses[] = 'current_branch';
              }
              $liattr = array('class'=>join(' ',$liclasses));
              // class attribute on the div item which only contains the item content
              $divclasses = array('tree_item');
              if ($item->children->count()>0  || $item->nodetype==navigation_node::NODETYPE_BRANCH) {
                  $divclasses[] = 'branch';
              } else {
                  $divclasses[] = 'leaf';
              }
              if (!empty($item->classes) && count($item->classes)>0) {
                  $divclasses[] = join(' ', $item->classes);
              }
              $divattr = array('class'=>join(' ', $divclasses));
              if (!empty($item->id)) {
                  $divattr['id'] = $item->id;
              }
              $content = html_writer::tag('p', $content, $divattr) . $this->tree_block_contents($item->children);
              if (!empty($item->preceedwithhr) && $item->preceedwithhr===true) {
                  $content = html_writer::empty_tag('hr') . $content;
              }
              $content = html_writer::tag('li', $content, $liattr);
              $lis[] = $content;
          }
          return html_writer::tag('ul', implode("\n", $lis), $attrs);
      }
code: public function tree_block_contents($items, $attrs = array()) {
          // exit if empty, we don't want an empty ul element
          if (empty($items)) {
              return '';
          }
          // array of nested li elements
          $lis = array();
          foreach ($items as $item) {
              // this applies to the li item which contains all child lists too
              $content = $item->content($this);
              $liclasses = array($item->get_css_type());
              if (!$item->forceopen || (!$item->forceopen && $item->collapse) || ($item->children->count()==0  && $item->nodetype==navigation_node::NODETYPE_BRANCH)) {
                  $liclasses[] = 'collapsed';
              }
              if ($item->isactive === true) {
                  $liclasses[] = 'current_branch';
              }
              $liattr = array('class'=>join(' ',$liclasses));
              // class attribute on the div item which only contains the item content
              $divclasses = array('tree_item');
              if ($item->children->count()>0  || $item->nodetype==navigation_node::NODETYPE_BRANCH) {
                  $divclasses[] = 'branch';
              } else {
                  $divclasses[] = 'leaf';
              }
              if (!empty($item->classes) && count($item->classes)>0) {
                  $divclasses[] = join(' ', $item->classes);
              }
              $divattr = array('class'=>join(' ', $divclasses));
              if (!empty($item->id)) {
                  $divattr['id'] = $item->id;
              }
              $content = html_writer::tag('p', $content, $divattr) . $this->tree_block_contents($item->children);
              if (!empty($item->preceedwithhr) && $item->preceedwithhr===true) {
                  $content = html_writer::empty_tag('hr') . $content;
              }
              $content = html_writer::tag('li', $content, $liattr);
              $lis[] = $content;
          }
          return html_writer::tag('ul', implode("\n", $lis), $attrs);
      }
code_tokens: public function tree_block_contents ( $ items , $ attrs = array ( ) ) { // exit if empty, we don't want an empty ul element if ( empty ( $ items ) ) { return '' ; } // array of nested li elements $ lis = array ( ) ; foreach ( $ items as $ item ) { // this applies to the li item which contains all child lists too $ content = $ item -> content ( $ this ) ; $ liclasses = array ( $ item -> get_css_type ( ) ) ; if ( ! $ item -> forceopen || ( ! $ item -> forceopen && $ item -> collapse ) || ( $ item -> children -> count ( ) == 0 && $ item -> nodetype == navigation_node :: NODETYPE_BRANCH ) ) { $ liclasses [ ] = 'collapsed' ; } if ( $ item -> isactive === true ) { $ liclasses [ ] = 'current_branch' ; } $ liattr = array ( 'class' => join ( ' ' , $ liclasses ) ) ; // class attribute on the div item which only contains the item content $ divclasses = array ( 'tree_item' ) ; if ( $ item -> children -> count ( ) > 0 || $ item -> nodetype == navigation_node :: NODETYPE_BRANCH ) { $ divclasses [ ] = 'branch' ; } else { $ divclasses [ ] = 'leaf' ; } if ( ! empty ( $ item -> classes ) && count ( $ item -> classes ) > 0 ) { $ divclasses [ ] = join ( ' ' , $ item -> classes ) ; } $ divattr = array ( 'class' => join ( ' ' , $ divclasses ) ) ; if ( ! empty ( $ item -> id ) ) { $ divattr [ 'id' ] = $ item -> id ; } $ content = html_writer :: tag ( 'p' , $ content , $ divattr ) . $ this -> tree_block_contents ( $ item -> children ) ; if ( ! empty ( $ item -> preceedwithhr ) && $ item -> preceedwithhr === true ) { $ content = html_writer :: empty_tag ( 'hr' ) . $ content ; } $ content = html_writer :: tag ( 'li' , $ content , $ liattr ) ; $ lis [ ] = $ content ; } return html_writer :: tag ( 'ul' , implode ( "\n" , $ lis ) , $ attrs ) ; }
docstring: Make nested HTML lists out of the items
  
  The resulting list will look something like this:
  
  <pre>
  <<ul>>
  <<li>><div class='tree_item parent'>(item contents)</div>
  <<ul>
  <<li>><div class='tree_item'>(item contents)</div><</li>>
  <</ul>>
  <</li>>
  <</ul>>
  </pre>
  
  @param array $items
  @param array $attrs html attributes passed to the top ofs the list
  @return string HTML
docstring_tokens: Make nested HTML lists out of the items