From ce75c17dd6861b455ad00e08a12b638022f52d39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20S=C3=B6rqvist?= Date: Mon, 7 Mar 2011 19:00:39 +0100 Subject: [PATCH] applied patch --- includes/common.inc | 5 +++++ modules/overlay/overlay-parent.js | 5 +++-- modules/simpletest/tests/common.test | 7 +++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/includes/common.inc b/includes/common.inc index a6901f3..1ee68a0 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -3947,10 +3947,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 e7ad338..9ce60cd 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 4664f04..d618ddb 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.')); -- 1.7.1