From 8cb324ccb85e2a940993259b0ce09564a4ab134f Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sat, 13 Apr 2013 16:31:47 -0700 Subject: [PATCH] Fix inconsistent ordering of header elements CRM-12339 In D6 & D7 our header region seems to always render before drupal's scripts and styles, whereas Joomla was the opposite. To fix this I have rolled-back the use of JFactory to add scripts, and weighted our settings region so it will always be the first thing in the header. --- CRM/Core/Resources.php | 5 +++-- CRM/Utils/System/Joomla.php | 10 ---------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/CRM/Core/Resources.php b/CRM/Core/Resources.php index d5c39145e9..5b247f00b0 100644 --- a/CRM/Core/Resources.php +++ b/CRM/Core/Resources.php @@ -205,7 +205,8 @@ class CRM_Core_Resources { CRM_Core_Region::instance('html-header')->add(array( 'callback' => function(&$snippet, &$html) use ($resources) { $html .= "\n" . $resources->renderSetting(); - } + }, + 'weight' => -100000, )); $this->addedSettings = TRUE; } @@ -261,7 +262,7 @@ class CRM_Core_Resources { * @return string */ public function renderSetting() { - $js = 'var CRM = cj.extend(true, ' . json_encode($this->getSettings()) . ', CRM || {});'; + $js = 'var CRM = ' . json_encode($this->getSettings()) . ';'; return sprintf("\n", $js); } diff --git a/CRM/Utils/System/Joomla.php b/CRM/Utils/System/Joomla.php index d644e1bbbc..518d85f439 100644 --- a/CRM/Utils/System/Joomla.php +++ b/CRM/Utils/System/Joomla.php @@ -261,11 +261,6 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { * @access public */ public function addScriptUrl($url, $region) { - if ($region == 'html-header') { - $document = JFactory::getDocument(); - $document->addScript($url); - return TRUE; - } return FALSE; } @@ -282,11 +277,6 @@ class CRM_Utils_System_Joomla extends CRM_Utils_System_Base { * @access public */ public function addScript($code, $region) { - if ($region == 'html-header') { - $document = JFactory::getDocument(); - $document->addScriptDeclaration($code); - return TRUE; - } return FALSE; } -- 2.25.1