Skip to content
Snippets Groups Projects
Commit 2fa8bc5b authored by Tim Steiner's avatar Tim Steiner
Browse files

[gh-157] Merging from testing into staging

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@865 20a16fea-79d4-4915-8869-1ea9d5ebf173
parent dc5e4073
No related branches found
No related tags found
No related merge requests found
......@@ -327,6 +327,10 @@ function unl_add_site_to_htaccess($site_id, $site_path, $is_alias) {
$site_or_alias = 'SITE';
}
if (substr($site_path, -1) != '/') {
$site_path .= '/';
}
$stub_token = ' # %UNL_CREATION_TOOL_STUB%';
$htaccess = file_get_contents(DRUPAL_ROOT . '/.htaccess');
$stub_pos = strpos($htaccess, $stub_token);
......@@ -336,7 +340,7 @@ function unl_add_site_to_htaccess($site_id, $site_path, $is_alias) {
$new_htaccess = substr($htaccess, 0, $stub_pos)
. " # %UNL_START_{$site_or_alias}_ID_{$site_id}%\n";
foreach (array('misc', 'modules', 'sites', 'themes') as $drupal_dir) {
$new_htaccess .= " RewriteRule $site_path/$drupal_dir/(.*) $drupal_dir/$1\n";
$new_htaccess .= " RewriteRule $site_path$drupal_dir/(.*) $drupal_dir/$1\n";
}
$new_htaccess .= " # %UNL_END_{$site_or_alias}_ID_{$site_id}%\n\n"
. $stub_token
......
......@@ -358,3 +358,14 @@ function unl_update_7109() {
->fields(array('title' => '<none>'))
->execute();
}
/**
* Updates unl sites and site aliases to have trailing slashes.
*/
function unl_update_7110()
{
db_query("UPDATE {unl_sites} SET site_path = CONCAT(site_path, '/') WHERE SUBSTRING(site_path, -1) != '/'");
db_query("UPDATE {unl_sites} SET uri = CONCAT(uri, '/') WHERE SUBSTRING(uri, -1) != '/'");
db_query("UPDATE {unl_sites_aliases} SET base_uri = CONCAT(base_uri, '/') WHERE SUBSTRING(base_uri, -1) != '/'");
db_query("UPDATE {unl_sites_aliases} SET path = CONCAT(path, '/') WHERE SUBSTRING(path, -1) != '/' AND path != ''");
}
......@@ -46,8 +46,8 @@ function unl_site_create_validate($form, &$form_state) {
if (substr($site_path, 0, 1) == '/') {
$site_path = substr($site_path, 1);
}
if (substr($site_path, -1) == '/') {
$site_path = substr($site_path, 0, -1);
if (substr($site_path, -1) != '/') {
$site_path .= '/';
}
$site_path_parts = explode('/', $site_path);
......@@ -312,7 +312,7 @@ function unl_site_alias_create($form, &$form_state) {
->execute()
->fetchAll();
foreach ($sites as $site) {
$site_list[$site->site_id] = $site->uri . '/';
$site_list[$site->site_id] = $site->uri;
}
$form['root'] = array(
......@@ -331,7 +331,7 @@ function unl_site_alias_create($form, &$form_state) {
$form['root']['base_uri'] = array(
'#type' => 'textfield',
'#title' => t('Alias Base URL'),
'#description' => t('The base URL for the new alias.'),
'#description' => t('The base URL for the new alias. (This should resolve to the directory containing drupal\'s .htaccess file'),
'#default_value' => url('', array('https' => FALSE)),
'#required' => TRUE,
);
......@@ -350,6 +350,23 @@ function unl_site_alias_create($form, &$form_state) {
return $form;
}
function unl_site_alias_create_validate($form, &$form_state) {
$form_state['values']['base_uri'] = trim($form_state['values']['base_uri']);
$form_state['values']['path'] = trim($form_state['values']['path']);
if (substr($form_state['values']['base_uri'], -1) != '/') {
$form_state['values']['base_uri'] .= '/';
}
if (substr($form_state['values']['path'], -1) != '/') {
$form_state['values']['path'] .= '/';
}
if (substr($form_state['values']['path'], 0, 1) == '/') {
$form_state['values']['path'] = substr($form_state['values']['path'], 1);
}
}
function unl_site_alias_create_submit($form, &$form_state) {
db_insert('unl_sites_aliases')->fields(array(
'site_id' => $form_state['values']['site'],
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment