original_string: protected function initialise_stage_form() {
          global $PAGE;
          if ($this->stageform === null) {
              $form = new backup_initial_form($this, $PAGE->url);
              // Store as a variable so we can iterate by reference.
              $tasks = $this->ui->get_tasks();
              // Iterate all tasks by reference.
              $add_settings = array();
              $dependencies = array();
              foreach ($tasks as &$task) {
                  // For the initial stage we are only interested in the root settings.
                  if ($task instanceof backup_root_task) {
                      if ($this->ui instanceof import_ui) {
                          $form->add_heading('rootsettings', get_string('importrootsettings', 'backup'));
                      } else {
                          $form->add_heading('rootsettings', get_string('rootsettings', 'backup'));
                      }
                      $settings = $task->get_settings();
                      // First add all settings except the filename setting.
                      foreach ($settings as &$setting) {
                          if ($setting->get_name() == 'filename') {
                              continue;
                          }
                          $add_settings[] = array($setting, $task);
                      }
                      // Then add all dependencies.
                      foreach ($settings as &$setting) {
                          if ($setting->get_name() == 'filename') {
                              continue;
                          }
                          $dependencies[] = $setting;
                      }
                  }
              }
              // Add all settings at once.
              $form->add_settings($add_settings);
              // Add dependencies.
              foreach ($dependencies as $depsetting) {
                  $form->add_dependencies($depsetting);
              }
              $this->stageform = $form;
          }
          // Return the form.
          return $this->stageform;
      }
code: protected function initialise_stage_form() {
          global $PAGE;
          if ($this->stageform === null) {
              $form = new backup_initial_form($this, $PAGE->url);
              // Store as a variable so we can iterate by reference.
              $tasks = $this->ui->get_tasks();
              // Iterate all tasks by reference.
              $add_settings = array();
              $dependencies = array();
              foreach ($tasks as &$task) {
                  // For the initial stage we are only interested in the root settings.
                  if ($task instanceof backup_root_task) {
                      if ($this->ui instanceof import_ui) {
                          $form->add_heading('rootsettings', get_string('importrootsettings', 'backup'));
                      } else {
                          $form->add_heading('rootsettings', get_string('rootsettings', 'backup'));
                      }
                      $settings = $task->get_settings();
                      // First add all settings except the filename setting.
                      foreach ($settings as &$setting) {
                          if ($setting->get_name() == 'filename') {
                              continue;
                          }
                          $add_settings[] = array($setting, $task);
                      }
                      // Then add all dependencies.
                      foreach ($settings as &$setting) {
                          if ($setting->get_name() == 'filename') {
                              continue;
                          }
                          $dependencies[] = $setting;
                      }
                  }
              }
              // Add all settings at once.
              $form->add_settings($add_settings);
              // Add dependencies.
              foreach ($dependencies as $depsetting) {
                  $form->add_dependencies($depsetting);
              }
              $this->stageform = $form;
          }
          // Return the form.
          return $this->stageform;
      }
code_tokens: protected function initialise_stage_form ( ) { global $ PAGE ; if ( $ this -> stageform === null ) { $ form = new backup_initial_form ( $ this , $ PAGE -> url ) ; // Store as a variable so we can iterate by reference. $ tasks = $ this -> ui -> get_tasks ( ) ; // Iterate all tasks by reference. $ add_settings = array ( ) ; $ dependencies = array ( ) ; foreach ( $ tasks as & $ task ) { // For the initial stage we are only interested in the root settings. if ( $ task instanceof backup_root_task ) { if ( $ this -> ui instanceof import_ui ) { $ form -> add_heading ( 'rootsettings' , get_string ( 'importrootsettings' , 'backup' ) ) ; } else { $ form -> add_heading ( 'rootsettings' , get_string ( 'rootsettings' , 'backup' ) ) ; } $ settings = $ task -> get_settings ( ) ; // First add all settings except the filename setting. foreach ( $ settings as & $ setting ) { if ( $ setting -> get_name ( ) == 'filename' ) { continue ; } $ add_settings [ ] = array ( $ setting , $ task ) ; } // Then add all dependencies. foreach ( $ settings as & $ setting ) { if ( $ setting -> get_name ( ) == 'filename' ) { continue ; } $ dependencies [ ] = $ setting ; } } } // Add all settings at once. $ form -> add_settings ( $ add_settings ) ; // Add dependencies. foreach ( $ dependencies as $ depsetting ) { $ form -> add_dependencies ( $ depsetting ) ; } $ this -> stageform = $ form ; } // Return the form. return $ this -> stageform ; }
docstring: Initialises the backup_moodleform instance for this stage
  
  @return backup_initial_form
docstring_tokens: Initialises the backup_moodleform instance for this stage