protected function isDrupalRoot($directory) {
    if (!empty($directory) && is_dir($directory) && file_exists($directory . DIRECTORY_SEPARATOR . '/index.php')) {
      // Drupal 7 root.
      // We check for the presence of 'modules/field/field.module' to differentiate this from a D6 site
      return (file_exists($directory . DIRECTORY_SEPARATOR . 'includes/common.inc')
        && file_exists($directory . DIRECTORY_SEPARATOR . 'misc/drupal.js')
        && file_exists($directory . DIRECTORY_SEPARATOR . 'modules/field/field.module'));
    }
    return FALSE;
  }