original_string: public function definition() {
          global $CFG;
          // type of plugin, string
          $this->plugin = $this->_customdata['plugin'];
          $this->typeid = $this->_customdata['typeid'];
          $this->contextid = $this->_customdata['contextid'];
          $this->instance = (isset($this->_customdata['instance'])
                  && is_subclass_of($this->_customdata['instance'], 'repository'))
              ? $this->_customdata['instance'] : null;
  
          $mform =& $this->_form;
  
          $this->add_defaults();
  
          // Add instance config options.
          $result = repository::static_function($this->plugin, 'instance_config_form', $mform);
          if ($result === false) {
              // Remove the name element if no other config options.
              $mform->removeElement('name');
          }
          if ($this->instance) {
              $data = array();
              $data['name'] = $this->instance->name;
              if (!$this->instance->readonly) {
                  // and set the data if we have some.
                  foreach ($this->instance->get_instance_option_names() as $config) {
                      if (!empty($this->instance->options[$config])) {
                          $data[$config] = $this->instance->options[$config];
                       } else {
                          $data[$config] = '';
                       }
                  }
              }
              $this->set_data($data);
          }
  
          if ($result === false) {
              $mform->addElement('cancel');
          } else {
              $this->add_action_buttons(true, get_string('save','repository'));
          }
      }
code: public function definition() {
          global $CFG;
          // type of plugin, string
          $this->plugin = $this->_customdata['plugin'];
          $this->typeid = $this->_customdata['typeid'];
          $this->contextid = $this->_customdata['contextid'];
          $this->instance = (isset($this->_customdata['instance'])
                  && is_subclass_of($this->_customdata['instance'], 'repository'))
              ? $this->_customdata['instance'] : null;
  
          $mform =& $this->_form;
  
          $this->add_defaults();
  
          // Add instance config options.
          $result = repository::static_function($this->plugin, 'instance_config_form', $mform);
          if ($result === false) {
              // Remove the name element if no other config options.
              $mform->removeElement('name');
          }
          if ($this->instance) {
              $data = array();
              $data['name'] = $this->instance->name;
              if (!$this->instance->readonly) {
                  // and set the data if we have some.
                  foreach ($this->instance->get_instance_option_names() as $config) {
                      if (!empty($this->instance->options[$config])) {
                          $data[$config] = $this->instance->options[$config];
                       } else {
                          $data[$config] = '';
                       }
                  }
              }
              $this->set_data($data);
          }
  
          if ($result === false) {
              $mform->addElement('cancel');
          } else {
              $this->add_action_buttons(true, get_string('save','repository'));
          }
      }
code_tokens: public function definition ( ) { global $ CFG ; // type of plugin, string $ this -> plugin = $ this -> _customdata [ 'plugin' ] ; $ this -> typeid = $ this -> _customdata [ 'typeid' ] ; $ this -> contextid = $ this -> _customdata [ 'contextid' ] ; $ this -> instance = ( isset ( $ this -> _customdata [ 'instance' ] ) && is_subclass_of ( $ this -> _customdata [ 'instance' ] , 'repository' ) ) ? $ this -> _customdata [ 'instance' ] : null ; $ mform = & $ this -> _form ; $ this -> add_defaults ( ) ; // Add instance config options. $ result = repository :: static_function ( $ this -> plugin , 'instance_config_form' , $ mform ) ; if ( $ result === false ) { // Remove the name element if no other config options. $ mform -> removeElement ( 'name' ) ; } if ( $ this -> instance ) { $ data = array ( ) ; $ data [ 'name' ] = $ this -> instance -> name ; if ( ! $ this -> instance -> readonly ) { // and set the data if we have some. foreach ( $ this -> instance -> get_instance_option_names ( ) as $ config ) { if ( ! empty ( $ this -> instance -> options [ $ config ] ) ) { $ data [ $ config ] = $ this -> instance -> options [ $ config ] ; } else { $ data [ $ config ] = '' ; } } } $ this -> set_data ( $ data ) ; } if ( $ result === false ) { $ mform -> addElement ( 'cancel' ) ; } else { $ this -> add_action_buttons ( true , get_string ( 'save' , 'repository' ) ) ; } }
docstring: Define moodle form elements
docstring_tokens: Define moodle form elements