original_string: public static function detect_backup_format($tempdir) {
          global $CFG;
          require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php');
  
          if (convert_helper::detect_moodle2_format($tempdir)) {
              return backup::FORMAT_MOODLE;
          }
  
          // see if a converter can identify the format
          $converters = convert_helper::available_converters();
          foreach ($converters as $name) {
              $classname = "{$name}_converter";
              if (!class_exists($classname)) {
                  throw new coding_exception("available_converters() is supposed to load
                      converter classes but class $classname not found");
              }
  
              $detected = call_user_func($classname .'::detect_format', $tempdir);
              if (!empty($detected)) {
                  return $detected;
              }
          }
  
          return backup::FORMAT_UNKNOWN;
      }
code: public static function detect_backup_format($tempdir) {
          global $CFG;
          require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php');
  
          if (convert_helper::detect_moodle2_format($tempdir)) {
              return backup::FORMAT_MOODLE;
          }
  
          // see if a converter can identify the format
          $converters = convert_helper::available_converters();
          foreach ($converters as $name) {
              $classname = "{$name}_converter";
              if (!class_exists($classname)) {
                  throw new coding_exception("available_converters() is supposed to load
                      converter classes but class $classname not found");
              }
  
              $detected = call_user_func($classname .'::detect_format', $tempdir);
              if (!empty($detected)) {
                  return $detected;
              }
          }
  
          return backup::FORMAT_UNKNOWN;
      }
code_tokens: public static function detect_backup_format ( $ tempdir ) { global $ CFG ; require_once ( $ CFG -> dirroot . '/backup/util/helper/convert_helper.class.php' ) ; if ( convert_helper :: detect_moodle2_format ( $ tempdir ) ) { return backup :: FORMAT_MOODLE ; } // see if a converter can identify the format $ converters = convert_helper :: available_converters ( ) ; foreach ( $ converters as $ name ) { $ classname = "{$name}_converter" ; if ( ! class_exists ( $ classname ) ) { throw new coding_exception ( "available_converters() is supposed to load
                      converter classes but class $classname not found" ) ; } $ detected = call_user_func ( $ classname . '::detect_format' , $ tempdir ) ; if ( ! empty ( $ detected ) ) { return $ detected ; } } return backup :: FORMAT_UNKNOWN ; }
docstring: Detects the format of the given unpacked backup directory
  
  @param string $tempdir the name of the backup directory
  @return string one of backup::FORMAT_xxx constants
docstring_tokens: Detects the format of the given unpacked backup directory