original_string: public static function guess_field_type(NodeElement $fieldnode, Session $session) {
  
          // Textareas are considered text based elements.
          $tagname = strtolower($fieldnode->getTagName());
          if ($tagname == 'textarea') {
  
              // If there is an iframe with $id + _ifr there a TinyMCE editor loaded.
              $xpath = '//div[@id="' . $fieldnode->getAttribute('id') . 'editable"]';
              if ($session->getPage()->find('xpath', $xpath)) {
                  return 'editor';
              }
              return 'textarea';
  
          } else if ($tagname == 'input') {
              $type = $fieldnode->getAttribute('type');
              switch ($type) {
                  case 'text':
                  case 'password':
                  case 'email':
                  case 'file':
                      return 'text';
                  case 'checkbox':
                      return 'checkbox';
                      break;
                  case 'radio':
                      return 'radio';
                      break;
                  default:
                      // Here we return false because all text-based
                      // fields should be included in the first switch case.
                      return false;
              }
  
          } else if ($tagname == 'select') {
              // Select tag.
              return 'select';
          }
  
          // We can not provide a closer field type.
          return false;
      }
code: public static function guess_field_type(NodeElement $fieldnode, Session $session) {
  
          // Textareas are considered text based elements.
          $tagname = strtolower($fieldnode->getTagName());
          if ($tagname == 'textarea') {
  
              // If there is an iframe with $id + _ifr there a TinyMCE editor loaded.
              $xpath = '//div[@id="' . $fieldnode->getAttribute('id') . 'editable"]';
              if ($session->getPage()->find('xpath', $xpath)) {
                  return 'editor';
              }
              return 'textarea';
  
          } else if ($tagname == 'input') {
              $type = $fieldnode->getAttribute('type');
              switch ($type) {
                  case 'text':
                  case 'password':
                  case 'email':
                  case 'file':
                      return 'text';
                  case 'checkbox':
                      return 'checkbox';
                      break;
                  case 'radio':
                      return 'radio';
                      break;
                  default:
                      // Here we return false because all text-based
                      // fields should be included in the first switch case.
                      return false;
              }
  
          } else if ($tagname == 'select') {
              // Select tag.
              return 'select';
          }
  
          // We can not provide a closer field type.
          return false;
      }
code_tokens: public static function guess_field_type ( NodeElement $ fieldnode , Session $ session ) { // Textareas are considered text based elements. $ tagname = strtolower ( $ fieldnode -> getTagName ( ) ) ; if ( $ tagname == 'textarea' ) { // If there is an iframe with $id + _ifr there a TinyMCE editor loaded. $ xpath = '//div[@id="' . $ fieldnode -> getAttribute ( 'id' ) . 'editable"]' ; if ( $ session -> getPage ( ) -> find ( 'xpath' , $ xpath ) ) { return 'editor' ; } return 'textarea' ; } else if ( $ tagname == 'input' ) { $ type = $ fieldnode -> getAttribute ( 'type' ) ; switch ( $ type ) { case 'text' : case 'password' : case 'email' : case 'file' : return 'text' ; case 'checkbox' : return 'checkbox' ; break ; case 'radio' : return 'radio' ; break ; default : // Here we return false because all text-based // fields should be included in the first switch case. return false ; } } else if ( $ tagname == 'select' ) { // Select tag. return 'select' ; } // We can not provide a closer field type. return false ; }
docstring: Guesses a basic field type and returns it.
  
  This method is intended to detect HTML form fields when no
  moodleform-specific elements have been detected.
  
  @param NodeElement $fieldnode
  @param Session $session
  @return string|bool The field type or false.
docstring_tokens: Guesses a basic field type and returns it .