You are here

function hackedProject::locate_local_project in Hacked! 6.2

Same name and namespace in other branches
  1. 7.2 includes/hackedProject.inc \hackedProject::locate_local_project()

Locate the base directory of the local project.

1 call to hackedProject::locate_local_project()
hackedProject::hash_local_project in includes/hacked_project.inc
Hash the local version of the project.

File

includes/hacked_project.inc, line 135

Class

hackedProject
Ensapsulates a Hacked! project.

Code

function locate_local_project() {

  // we need a remote project to do this :(
  $this
    ->hash_remote_project();

  // Do we have at least some modules to check for:
  if (!is_array($this->project_info['includes']) || !count($this->project_info['includes'])) {
    return FALSE;
  }

  // If this project is drupal it, we need to handle it specially
  if ($this->project_type != 'core') {
    $includes = array_keys($this->project_info['includes']);
    $include = array_shift($includes);
    $include_type = $this->project_info['project_type'];
  }
  else {

    // Just use the system module to find where we've installed drupal
    $include = 'system';
    $include_type = 'module';
  }

  //$include = 'image_captcha';
  $path = drupal_get_path($include_type, $include);

  // Now we need to find the path of the info file in the downloaded package:
  $temp = '';
  foreach ($this->remote_files->files as $file) {
    if (preg_match('@(^|.*/)' . $include . '.info$@', $file)) {
      $temp = $file;
      break;
    }
  }

  // How many '/' were in that path:
  $slash_count = substr_count($temp, '/');
  $back_track = str_repeat('/..', $slash_count);
  return realpath($path . $back_track);
}