summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2011-05-14 12:33:11 (GMT)
committerDries Buytaert2011-05-14 12:33:11 (GMT)
commit09c65ba70e96b5bde5f09063f0d1035c332fe5bc (patch)
treee7b967e164d45b6867ee35b89f76def938a7dfe6
parent1617b25ab9098a5cb91d1da93041249948436541 (diff)
- Patch #759844 by jpmckinney, dixon_, plach, ksenzee, fabsor, pillarsdotnet: overlay does not work with prefixed URL paths.
-rw-r--r--includes/common.inc5
-rw-r--r--modules/overlay/overlay-parent.js5
-rw-r--r--modules/simpletest/tests/common.test7
3 files changed, 13 insertions, 4 deletions
diff --git a/includes/common.inc b/includes/common.inc
index d4461f9..95e03e8 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -3951,10 +3951,15 @@ function drupal_add_js($data = NULL, $options = NULL) {
// Add jquery.js and drupal.js, as well as the basePath setting, the
// first time a JavaScript file is added.
if (empty($javascript)) {
+ // url() generates the prefix using hook_url_outbound_alter(). Instead of
+ // running the hook_url_outbound_alter() again here, extract the prefix
+ // from url().
+ url('', array('prefix' => &$prefix));
$javascript = array(
'settings' => array(
'data' => array(
array('basePath' => base_path()),
+ array('pathPrefix' => empty($prefix) ? '' : $prefix),
),
'type' => 'setting',
'scope' => 'header',
diff --git a/modules/overlay/overlay-parent.js b/modules/overlay/overlay-parent.js
index 67c97b8..8f11df6 100644
--- a/modules/overlay/overlay-parent.js
+++ b/modules/overlay/overlay-parent.js
@@ -350,8 +350,9 @@ Drupal.overlay.isAdminLink = function (url) {
// Turn the list of administrative paths into a regular expression.
if (!this.adminPathRegExp) {
- var adminPaths = '^(' + Drupal.settings.overlay.paths.admin.replace(/\s+/g, ')$|^(') + ')$';
- var nonAdminPaths = '^(' + Drupal.settings.overlay.paths.non_admin.replace(/\s+/g, ')$|^(') + ')$';
+ var regExpPrefix = '^' + Drupal.settings.pathPrefix + '(';
+ var adminPaths = regExpPrefix + Drupal.settings.overlay.paths.admin.replace(/\s+/g, ')$|' + regExpPrefix) + ')$';
+ var nonAdminPaths = regExpPrefix + Drupal.settings.overlay.paths.non_admin.replace(/\s+/g, ')$|'+ regExpPrefix) + ')$';
adminPaths = adminPaths.replace(/\*/g, '.*');
nonAdminPaths = nonAdminPaths.replace(/\*/g, '.*');
this.adminPathRegExp = new RegExp(adminPaths);
diff --git a/modules/simpletest/tests/common.test b/modules/simpletest/tests/common.test
index 9181fba..6cee722 100644
--- a/modules/simpletest/tests/common.test
+++ b/modules/simpletest/tests/common.test
@@ -1170,6 +1170,8 @@ class JavaScriptTestCase extends DrupalWebTestCase {
$this->assertTrue(array_key_exists('misc/drupal.js', $javascript), t('Drupal.js is added when file is added.'));
$this->assertTrue(array_key_exists('misc/collapse.js', $javascript), t('JavaScript files are correctly added.'));
$this->assertEqual(base_path(), $javascript['settings']['data'][0]['basePath'], t('Base path JavaScript setting is correctly set.'));
+ url('', array('prefix' => &$prefix));
+ $this->assertEqual(empty($prefix) ? '' : $prefix, $javascript['settings']['data'][1]['pathPrefix'], t('Path prefix JavaScript setting is correctly set.'));
}
/**
@@ -1177,8 +1179,8 @@ class JavaScriptTestCase extends DrupalWebTestCase {
*/
function testAddSetting() {
$javascript = drupal_add_js(array('drupal' => 'rocks', 'dries' => 280342800), 'setting');
- $this->assertEqual(280342800, $javascript['settings']['data'][1]['dries'], t('JavaScript setting is set correctly.'));
- $this->assertEqual('rocks', $javascript['settings']['data'][1]['drupal'], t('The other JavaScript setting is set correctly.'));
+ $this->assertEqual(280342800, $javascript['settings']['data'][2]['dries'], t('JavaScript setting is set correctly.'));
+ $this->assertEqual('rocks', $javascript['settings']['data'][2]['drupal'], t('The other JavaScript setting is set correctly.'));
}
/**
@@ -1208,6 +1210,7 @@ class JavaScriptTestCase extends DrupalWebTestCase {
$javascript = drupal_get_js('header');
$this->assertTrue(strpos($javascript, 'basePath') > 0, t('Rendered JavaScript header returns basePath setting.'));
$this->assertTrue(strpos($javascript, 'misc/jquery.js') > 0, t('Rendered JavaScript header includes jQuery.'));
+ $this->assertTrue(strpos($javascript, 'pathPrefix') > 0, t('Rendered JavaScript header returns pathPrefix setting.'));
// Test whether drupal_add_js can be used to override a previous setting.
$this->assertTrue(strpos($javascript, 'commonTestShouldAppear') > 0, t('Rendered JavaScript header returns custom setting.'));