Commit d8b98d28 authored by anarcat's avatar anarcat

Merge branch 'master' into 6.x-1.x

parents e93c2e54 e1bd1a94
......@@ -339,12 +339,64 @@ function provision_drupal_find_sites() {
return $sites;
}
function _provision_drupal_get_cvs_versions($files) {
foreach ($files as $modulename => $file) {
$project = array();
$project['filename'] = $file->filename;
$project['name'] = $file->name;
$file->info['description'] = str_replace("\n", "", $file->info['description']);
if (!isset($project['project'])) {
$project['project'] = cvs_deploy_get_project_name($project);
}
_cvs_deploy_version_alter($file->info['version'], $project);
$name = !empty($project['project']) ? $project['project'] : $modulename;
$files[$name] = $file;
}
return $files;
}
class provisionConfig_drupal_alias_store extends provisionConfig_data_store {
public $template = 'provision_drupal_sites.tpl.php';
public $description = 'Drupal sites.php file';
public $key = 'sites';
protected $mode = 0644;
function filename() {
return $this->root . '/sites/sites.php';
}
function maintain() {
$this->delete();
if (!$this->redirection) {
foreach ($this->aliases as $alias) {
$this->records[$alias] = $this->uri;
}
}
}
function delete() {
foreach ($this->find() as $alias) {
unset($this->records[$alias]);
unset($this->loaded_records[$alias]);
}
}
function find() {
return array_keys($this->merged_records(), $this->uri);
}
}
/**
* Retrieve a list of aliases for the curent site.
*/
function provision_drupal_find_aliases() {
$aliases = array();
if (d()->type === 'site') {
if (drush_drupal_major_version() >= 7) {
$config = new provisionConfig_drupal_alias_store(d()->name);
$aliases = $config->find();
} else {
if ($dir = opendir(d()->root . "/sites")) {
while (FALSE !== ($subdir = readdir($dir))) {
// skip internal directory pointers
......@@ -360,26 +412,9 @@ function provision_drupal_find_aliases() {
closedir($dir);
}
}
return $aliases;
}
function _provision_drupal_get_cvs_versions($files) {
foreach ($files as $modulename => $file) {
$project = array();
$project['filename'] = $file->filename;
$project['name'] = $file->name;
$file->info['description'] = str_replace("\n", "", $file->info['description']);
if (!isset($project['project'])) {
$project['project'] = cvs_deploy_get_project_name($project);
}
_cvs_deploy_version_alter($file->info['version'], $project);
$name = !empty($project['project']) ? $project['project'] : $modulename;
$files[$name] = $file;
}
return $files;
return $aliases;
}
/**
......@@ -388,6 +423,12 @@ function _provision_drupal_get_cvs_versions($files) {
*/
function _provision_drupal_maintain_aliases() {
if (d()->type === 'site') {
if (drush_drupal_major_version() >= 7) {
$config = new provisionConfig_drupal_alias_store(d()->name);
$config->maintain();
$config->write();
d()->service('http')->sync($config->filename());
} else {
_provision_drupal_delete_aliases();
if (!d()->redirection) {
......@@ -401,6 +442,7 @@ function _provision_drupal_maintain_aliases() {
}
}
}
}
}
/**
......@@ -409,6 +451,12 @@ function _provision_drupal_maintain_aliases() {
function _provision_drupal_delete_aliases() {
if (d()->type === 'site') {
if (drush_drupal_major_version() >= 7) {
$config = new provisionConfig_drupal_alias_store(d()->name);
$config->delete();
$config->write();
d()->service('http')->sync($config->filename());
} else {
$aliases = provision_drupal_find_aliases();
foreach ($aliases as $alias) {
......@@ -419,6 +467,7 @@ function _provision_drupal_delete_aliases() {
d()->service('http')->sync($path);
}
}
}
}
require_once(dirname(__FILE__) . '/cvs_deploy.inc');
......
<?php print "<?php \n"; ?>
/**
* @file
* Configuration file for Drupal's multi-site directory aliasing feature.
*
* Drupal searches for an appropriate configuration directory based on the
* website's hostname and pathname. A detailed description of the rules for
* discovering the configuration directory can be found in the comment
* documentation in 'sites/default/default.settings.php'.
*
* This file allows you to define a set of aliases that map hostnames and
* pathnames to configuration directories. These aliases are loaded prior to
* scanning for directories, and they are exempt from the normal discovery
* rules. The aliases are defined in an associative array named $sites, which
* should look similar to the following:
*
* $sites = array(
* 'devexample.com' => 'example.com',
* 'localhost.example' => 'example.com',
* );
*
* The above array will cause Drupal to look for a directory named
* "example.com" in the sites directory whenever a request comes from
* "example.com", "devexample.com", or "localhost/example". That is useful
* on development servers, where the domain name may not be the same as the
* domain of the live server. Since Drupal stores file paths into the database
* (files, system table, etc.) this will ensure the paths are correct while
* accessed on development servers.
*
* To use this file, copy and rename it such that its path plus filename is
* 'sites/sites.php'. If you don't need to use multi-site directory aliasing,
* then you can safely ignore this file, and Drupal will ignore it too.
*/
/**
* Multi-site directory aliasing:
*
* Edit the lines below to define directory aliases. Remove the leading hash
* signs to enable.
*/
$sites = <?php print var_export($records, TRUE) ?>;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment