Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CiviCRM Core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Development
CiviCRM Core
Commits
d759bd10
Commit
d759bd10
authored
11 years ago
by
colemanw
Browse files
Options
Downloads
Patches
Plain Diff
Move settings to html-header region CRM-12339
parent
8053ab8a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CRM/Core/Resources.php
+10
-3
10 additions, 3 deletions
CRM/Core/Resources.php
templates/CRM/common/scripts.tpl
+0
-5
0 additions, 5 deletions
templates/CRM/common/scripts.tpl
with
10 additions
and
8 deletions
CRM/Core/Resources.php
+
10
−
3
View file @
d759bd10
...
...
@@ -202,7 +202,7 @@ class CRM_Core_Resources {
$this
->
settings
=
$this
->
mergeSettings
(
$this
->
settings
,
$settings
);
if
(
!
$this
->
addedSettings
)
{
$resources
=
$this
;
CRM_Core_Region
::
instance
(
'
settings
'
)
->
add
(
array
(
CRM_Core_Region
::
instance
(
'
html-header
'
)
->
add
(
array
(
'callback'
=>
function
(
&
$snippet
,
&
$html
)
use
(
$resources
)
{
$html
.
=
"
\n
"
.
$resources
->
renderSetting
();
}
...
...
@@ -219,7 +219,6 @@ class CRM_Core_Resources {
* @return CRM_Core_Resources
*/
public
function
addSettingsFactory
(
$callable
)
{
$this
->
addSetting
(
array
());
// ensure that 'settings' region is created, even if empty
$this
->
settingsFactories
[]
=
$callable
;
return
$this
;
}
...
...
@@ -260,7 +259,8 @@ class CRM_Core_Resources {
* @return string
*/
public
function
renderSetting
()
{
return
'CRM = cj.extend(true, '
.
json_encode
(
$this
->
getSettings
())
.
', CRM);'
;
$js
=
'var CRM = cj.extend(true, '
.
json_encode
(
$this
->
getSettings
())
.
', CRM || {});'
;
return
sprintf
(
"<script type=
\"
text/javascript
\"
>
\n
%s
\n
</script>
\n
"
,
$js
);
}
/**
...
...
@@ -450,6 +450,13 @@ class CRM_Core_Resources {
$js
=
"CRM.url('init', '
$url
');"
;
$this
->
addScript
(
$js
,
$jsWeight
++
,
$region
);
// Add global settings
$settings
=
array
(
'userFramework'
=>
json_encode
(
$config
->
userFramework
),
'resourceBase'
=>
json_encode
(
$config
->
resourceBase
),
);
$this
->
addSetting
(
array
(
'config'
=>
$settings
));
// Give control of jQuery back to the CMS - this loads last
$this
->
addScriptFile
(
'civicrm'
,
'js/noconflict.js'
,
9999
,
$region
,
FALSE
);
...
...
This diff is collapsed.
Click to expand it.
templates/CRM/common/scripts.tpl
+
0
−
5
View file @
d759bd10
...
...
@@ -42,13 +42,8 @@
strings
:
{},
config
:
{
{/
literal
}
urlIsPublic
:
{
if
$urlIsPublic
}
true
{
else
}
false
{/
if
}
,
userFramework
:
'
{
$config
->
userFramework
}
'
,
resourceBase
:
'
{
$config
->
resourceBase
}
'
,
search_autocomplete_count
:
{
crmSetting
name
=
"search_autocomplete_count"
group
=
"Search Preferences"
}
{
literal
}
},
},
CRM
);
{/
literal
}
{* Dynamically add server-side variables to the CRM object *}
{
crmRegion
name
=
'settings'
}
{/
crmRegion
}
</script>
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment