original_string: protected static function fetch_subtypes($ownerdir) {
          global $CFG;
  
          $types = array();
          if (file_exists("$ownerdir/db/subplugins.php")) {
              $subplugins = array();
              include("$ownerdir/db/subplugins.php");
              foreach ($subplugins as $subtype => $dir) {
                  if (!preg_match('/^[a-z][a-z0-9]*$/', $subtype)) {
                      error_log("Invalid subtype '$subtype'' detected in '$ownerdir', invalid characters present.");
                      continue;
                  }
                  if (isset(self::$subsystems[$subtype])) {
                      error_log("Invalid subtype '$subtype'' detected in '$ownerdir', duplicates core subsystem.");
                      continue;
                  }
                  if ($CFG->admin !== 'admin' and strpos($dir, 'admin/') === 0) {
                      $dir = preg_replace('|^admin/|', "$CFG->admin/", $dir);
                  }
                  if (!is_dir("$CFG->dirroot/$dir")) {
                      error_log("Invalid subtype directory '$dir' detected in '$ownerdir'.");
                      continue;
                  }
                  $types[$subtype] = "$CFG->dirroot/$dir";
              }
          }
          return $types;
      }
code: protected static function fetch_subtypes($ownerdir) {
          global $CFG;
  
          $types = array();
          if (file_exists("$ownerdir/db/subplugins.php")) {
              $subplugins = array();
              include("$ownerdir/db/subplugins.php");
              foreach ($subplugins as $subtype => $dir) {
                  if (!preg_match('/^[a-z][a-z0-9]*$/', $subtype)) {
                      error_log("Invalid subtype '$subtype'' detected in '$ownerdir', invalid characters present.");
                      continue;
                  }
                  if (isset(self::$subsystems[$subtype])) {
                      error_log("Invalid subtype '$subtype'' detected in '$ownerdir', duplicates core subsystem.");
                      continue;
                  }
                  if ($CFG->admin !== 'admin' and strpos($dir, 'admin/') === 0) {
                      $dir = preg_replace('|^admin/|', "$CFG->admin/", $dir);
                  }
                  if (!is_dir("$CFG->dirroot/$dir")) {
                      error_log("Invalid subtype directory '$dir' detected in '$ownerdir'.");
                      continue;
                  }
                  $types[$subtype] = "$CFG->dirroot/$dir";
              }
          }
          return $types;
      }
code_tokens: protected static function fetch_subtypes ( $ ownerdir ) { global $ CFG ; $ types = array ( ) ; if ( file_exists ( "$ownerdir/db/subplugins.php" ) ) { $ subplugins = array ( ) ; include ( "$ownerdir/db/subplugins.php" ) ; foreach ( $ subplugins as $ subtype => $ dir ) { if ( ! preg_match ( '/^[a-z][a-z0-9]*$/' , $ subtype ) ) { error_log ( "Invalid subtype '$subtype'' detected in '$ownerdir', invalid characters present." ) ; continue ; } if ( isset ( self :: $ subsystems [ $ subtype ] ) ) { error_log ( "Invalid subtype '$subtype'' detected in '$ownerdir', duplicates core subsystem." ) ; continue ; } if ( $ CFG -> admin !== 'admin' and strpos ( $ dir , 'admin/' ) === 0 ) { $ dir = preg_replace ( '|^admin/|' , "$CFG->admin/" , $ dir ) ; } if ( ! is_dir ( "$CFG->dirroot/$dir" ) ) { error_log ( "Invalid subtype directory '$dir' detected in '$ownerdir'." ) ; continue ; } $ types [ $ subtype ] = "$CFG->dirroot/$dir" ; } } return $ types ; }
docstring: Returns list of subtypes.
  @param string $ownerdir
  @return array
docstring_tokens: Returns list of subtypes .