original_string: protected function build_action_menu_from_navigation(action_menu $menu,
              navigation_node $node,
              $indent = false,
              $onlytopleafnodes = false) {
          $skipped = false;
          // Build an action menu based on the visible nodes from this navigation tree.
          foreach ($node->children as $menuitem) {
              if ($menuitem->display) {
                  if ($onlytopleafnodes && $menuitem->children->count()) {
                      $skipped = true;
                      continue;
                  }
                  if ($menuitem->action) {
                      if ($menuitem->action instanceof action_link) {
                          $link = $menuitem->action;
                          // Give preference to setting icon over action icon.
                          if (!empty($menuitem->icon)) {
                              $link->icon = $menuitem->icon;
                          }
                      } else {
                          $link = new action_link($menuitem->action, $menuitem->text, null, null, $menuitem->icon);
                      }
                  } else {
                      if ($onlytopleafnodes) {
                          $skipped = true;
                          continue;
                      }
                      $link = new action_link(new moodle_url('#'), $menuitem->text, null, ['disabled' => true], $menuitem->icon);
                  }
                  if ($indent) {
                      $link->add_class('ml-4');
                  }
                  if (!empty($menuitem->classes)) {
                      $link->add_class(implode(" ", $menuitem->classes));
                  }
  
                  $menu->add_secondary_action($link);
                  $skipped = $skipped || $this->build_action_menu_from_navigation($menu, $menuitem, true);
              }
          }
          return $skipped;
      }
code: protected function build_action_menu_from_navigation(action_menu $menu,
              navigation_node $node,
              $indent = false,
              $onlytopleafnodes = false) {
          $skipped = false;
          // Build an action menu based on the visible nodes from this navigation tree.
          foreach ($node->children as $menuitem) {
              if ($menuitem->display) {
                  if ($onlytopleafnodes && $menuitem->children->count()) {
                      $skipped = true;
                      continue;
                  }
                  if ($menuitem->action) {
                      if ($menuitem->action instanceof action_link) {
                          $link = $menuitem->action;
                          // Give preference to setting icon over action icon.
                          if (!empty($menuitem->icon)) {
                              $link->icon = $menuitem->icon;
                          }
                      } else {
                          $link = new action_link($menuitem->action, $menuitem->text, null, null, $menuitem->icon);
                      }
                  } else {
                      if ($onlytopleafnodes) {
                          $skipped = true;
                          continue;
                      }
                      $link = new action_link(new moodle_url('#'), $menuitem->text, null, ['disabled' => true], $menuitem->icon);
                  }
                  if ($indent) {
                      $link->add_class('ml-4');
                  }
                  if (!empty($menuitem->classes)) {
                      $link->add_class(implode(" ", $menuitem->classes));
                  }
  
                  $menu->add_secondary_action($link);
                  $skipped = $skipped || $this->build_action_menu_from_navigation($menu, $menuitem, true);
              }
          }
          return $skipped;
      }
code_tokens: protected function build_action_menu_from_navigation ( action_menu $ menu , navigation_node $ node , $ indent = false , $ onlytopleafnodes = false ) { $ skipped = false ; // Build an action menu based on the visible nodes from this navigation tree. foreach ( $ node -> children as $ menuitem ) { if ( $ menuitem -> display ) { if ( $ onlytopleafnodes && $ menuitem -> children -> count ( ) ) { $ skipped = true ; continue ; } if ( $ menuitem -> action ) { if ( $ menuitem -> action instanceof action_link ) { $ link = $ menuitem -> action ; // Give preference to setting icon over action icon. if ( ! empty ( $ menuitem -> icon ) ) { $ link -> icon = $ menuitem -> icon ; } } else { $ link = new action_link ( $ menuitem -> action , $ menuitem -> text , null , null , $ menuitem -> icon ) ; } } else { if ( $ onlytopleafnodes ) { $ skipped = true ; continue ; } $ link = new action_link ( new moodle_url ( '#' ) , $ menuitem -> text , null , [ 'disabled' => true ] , $ menuitem -> icon ) ; } if ( $ indent ) { $ link -> add_class ( 'ml-4' ) ; } if ( ! empty ( $ menuitem -> classes ) ) { $ link -> add_class ( implode ( " " , $ menuitem -> classes ) ) ; } $ menu -> add_secondary_action ( $ link ) ; $ skipped = $ skipped || $ this -> build_action_menu_from_navigation ( $ menu , $ menuitem , true ) ; } } return $ skipped ; }
docstring: Take a node in the nav tree and make an action menu out of it.
  The links are injected in the action menu.
  
  @param action_menu $menu
  @param navigation_node $node
  @param boolean $indent
  @param boolean $onlytopleafnodes
  @return boolean nodesskipped - True if nodes were skipped in building the menu
docstring_tokens: Take a node in the nav tree and make an action menu out of it . The links are injected in the action menu .