Guest User

Untitled

a guest
Oct 18th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.08 KB | None | 0 0
  1. fd37a2b I added the _elc_domain_get_domain_aliases() function to the elc_domain/includes/bootstrap.inc file. This function allows the settings.ENV.php files to load a subset of domains to be used as aliases for a master domain. This master domain record is stored in the {domain} table of the brand's database. (Greg Amaroso, 28 hours ago)
  2.  
  3. diff --git a/drupal/drupal-7.9/sites/all/modules/custom/elc_domain/includes/bootstrap.inc b/drupal/drupal-7.9/sites/all/modules/custom/elc_domain/includes/bootstrap.inc
  4. index d0a0a15..d4a5d36 100644
  5. --- a/drupal/drupal-7.9/sites/all/modules/custom/elc_domain/includes/bootstrap.inc
  6. +++ b/drupal/drupal-7.9/sites/all/modules/custom/elc_domain/includes/bootstrap.inc
  7. @@ -29,6 +29,7 @@ function _elc_domain_directory_aliases(&$sites = NULL) {
  8. * Add personal site directory aliases to an existing $sites array
  9. */
  10. function _elc_domain_personal_site_directory_aliases(&$sites = NULL, $username) {
  11. + $username = &drupal_static(__FUNCTION__, $username);
  12. if (empty($username)) {
  13. return;
  14. }
  15. @@ -42,14 +43,52 @@ function _elc_domain_personal_site_directory_aliases(&$sites = NULL, $username)
  16. if ($environment != 'eng') {
  17. continue;
  18. }
  19. - foreach ($locale as $domains) {
  20. - array_walk($domains, create_function('&$v, $k', '$v = preg_replace(\'/\.eng\./\', \'.' . $username . '.eng.\', $v);'));
  21. - foreach ($domains as $domain) {
  22. - $sites[$domain] = $brand;
  23. + foreach ($locale as $urls) {
  24. + _elc_domain_substitute_user_domain_alias($urls, $username);
  25. + foreach ($urls as $url) {
  26. + $sites[$url] = $brand;
  27. + }
  28. + }
  29. + }
  30. + }
  31. +}
  32. +
  33. +/**
  34. + * Retrieve domain aliases for each brand
  35. + */
  36. +function _elc_domain_get_domain_aliases($key) {
  37. + $domains = _elc_domain_retrieve_master_domain_file();
  38. + foreach ($domains as $brand => $environments) {
  39. + foreach ($environments as $environment => $locale) {
  40. + foreach ($locale as $initial => $urls) {
  41. + // Create a variable to test against the desired key
  42. + $key_test = implode('_', array($brand, $environment, $initial));
  43. +
  44. + if ($key == $key_test) {
  45. + // If a sites.local.php files exists, then the directory alias function should be called, and thus we have a static $username variable available
  46. + $username = &drupal_static('_elc_domain_personal_site_directory_aliases');
  47. +
  48. + // If a username does exist, then include the tokenized URLs into the list of domains
  49. + if (!empty($username)) {
  50. + $tmp = $urls;
  51. + _elc_domain_substitute_user_domain_alias($urls, $username, $environment);
  52. + $urls = array_merge($urls, $tmp);
  53. + }
  54. +
  55. + return array_unique($urls);
  56. }
  57. }
  58. }
  59. }
  60. +
  61. + return array();
  62. +}
  63. +
  64. +/**
  65. + * This is a function to perform URL pattern substitution - mainly used for personal server setup
  66. + */
  67. +function _elc_domain_substitute_user_domain_alias(&$urls, $alias, $env = 'eng') {
  68. + return array_walk($urls, create_function('&$v, $k', '$v = preg_replace(\'/\.eng\./\', \'.' . $alias . '.' . $env . '.\', $v);'));
  69. }
  70.  
  71. /**
Add Comment
Please, Sign In to add comment