From ef1091993832edf1a2829e24d5a288ddb19132f9 Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Tue, 13 Mar 2012 16:27:29 +0000
Subject: [PATCH] [gh-298] Merging from testing into staging -c 1473

git-svn-id: file:///tmp/wdn_thm_drupal/branches/drupal-7.x/staging@1478 20a16fea-79d4-4915-8869-1ea9d5ebf173
---
 sites/all/modules/unl/unl.module | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/sites/all/modules/unl/unl.module b/sites/all/modules/unl/unl.module
index 66be7168..0f75e4f5 100644
--- a/sites/all/modules/unl/unl.module
+++ b/sites/all/modules/unl/unl.module
@@ -460,7 +460,7 @@ function unl_menu_alter(&$items) {
     $items['node/%node/moderation']['theme callback'] = '_unl_get_admin_theme';
     $items['node/%node/moderation/%/unpublish']['theme callback'] = '_unl_get_admin_theme';
   }
-  
+
   // Add a menu hook for the image module to use clean file URLs.
   if (variable_get('unl_clean_file_url') && module_exists('image')) {
     $directory_path = file_stream_wrapper_get_instance_by_scheme('public')->getDirectoryPath();
@@ -469,7 +469,7 @@ function unl_menu_alter(&$items) {
     // Since clean URLs have no "prefix", we can just set it to 1.
     $items['styles/%image_style']['page arguments'] = array(1);
   }
-  
+
   $items['admin/modules/uninstall']['access callback'] = 'unl_user_is_administrator';
 }
 
@@ -1026,6 +1026,7 @@ function unl_get_alternate_base_uris() {
  * Implementation of hook_init().
  */
 function unl_init() {
+  // Redirect to desired URL if needed
   $primary_base_url = variable_get('unl_primary_base_url');
   if ($primary_base_url) {
     if (substr($primary_base_url, -1) != '/') {
@@ -1041,20 +1042,30 @@ function unl_init() {
     }
   }
 
-  drupal_add_js('sites/all/modules/unl/unl.js');
-
+  // Insert <base> tag
   if (variable_get('unl_use_base_tag', TRUE)) {
+    $base_href = url('<front>', array('absolute' => TRUE));
+    if (substr($base_href, -1) != '/') {
+      $base_href .= '/';
+    }
+    if ($GLOBALS['is_https']) {
+      $base_href = str_replace('http://', 'https://', $base_href);
+    }
     $base_tag = array(
       '#type' => 'html_tag',
       '#tag' => 'base',
       '#attributes' => array(
-        'href' => '//' . $_SERVER['HTTP_HOST'] . base_path(),
+        'href' => $base_href
       ),
     );
     drupal_add_html_head($base_tag, 'base');
   }
   drupal_add_js(array('unl' => array('use_base_tag' => variable_get('unl_use_base_tag', TRUE))), 'setting');
 
+  // Add JS
+  drupal_add_js('sites/all/modules/unl/unl.js');
+
+  // Handle unneeded index.html references
   _unl_handle_directory_index();
 }
 
-- 
GitLab