aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2011-03-09 10:17:14 +0000
committerpatdenice <patdenice@piwigo.org>2011-03-09 10:17:14 +0000
commita9a05f39ac98390ae62b4bac9fe90b7014a84a72 (patch)
tree827c6d3e846b1f908e7a164c470df70da418d13d /include
parent639fd15a7c6b5bbeb2f79fa78ac6597913260602 (diff)
feature:2114
footer_script can use multiple required scripts (like combine_script). automaticaly load know scripts. git-svn-id: http://piwigo.org/svn/trunk@9580 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/template.class.php37
1 files changed, 30 insertions, 7 deletions
diff --git a/include/template.class.php b/include/template.class.php
index 2d6d7078a..de135ac8a 100644
--- a/include/template.class.php
+++ b/include/template.class.php
@@ -658,7 +658,10 @@ var s,after = document.getElementsByTagName(\'script\')[document.getElementsByTa
$content = trim($content);
if ( !empty($content) )
{ // second call
- $this->scriptLoader->add_inline( $content, @$params['require'] );
+ $this->scriptLoader->add_inline(
+ $content,
+ empty($params['require']) ? array() : explode(',', $params['require'])
+ );
}
}
@@ -934,11 +937,14 @@ class ScriptLoader
{
if(!empty($require))
{
- if(!isset($this->registered_scripts[$require]))
- fatal_error("inline script not found require $require");
- $s = $this->registered_scripts[$require];
- if($s->load_mode==2)
- $s->load_mode=1; // until now the implementation does not allow executing inline script depending on another async script
+ foreach ($require as $id)
+ {
+ if(!isset($this->registered_scripts[$id]))
+ $this->load_known_required_script($id, 1) or fatal_error("inline script not found require $id");
+ $s = $this->registered_scripts[$id];
+ if($s->load_mode==2)
+ $s->load_mode=1; // until now the implementation does not allow executing inline script depending on another async script
+ }
}
$this->inline_scripts[] = $code;
}
@@ -974,6 +980,13 @@ class ScriptLoader
foreach (self::$ui_core_dependencies as $script_id => $required_ids)
$this->add($script_id, $load_mode, $required_ids, null, $version);
}
+
+ // Try to load undefined required script
+ foreach ($script->precedents as $script_id)
+ {
+ if (! isset( $this->registered_scripts[$script_id] ) )
+ $this->load_known_required_script($script_id, $load_mode);
+ }
}
function did_head()
@@ -1113,7 +1126,7 @@ class ScriptLoader
$required_ids = array('jquery', 'jquery.effects');
if ( empty($script->path) )
- $script->path = dirname(self::$known_paths['jquery.ui'])."/$id.min.js";
+ $script->path = dirname(self::$known_paths['jquery.effects'])."/$id.min.js";
}
foreach ($required_ids as $required_id)
@@ -1124,6 +1137,16 @@ class ScriptLoader
}
}
+ private function load_known_required_script($id, $load_mode)
+ {
+ if ( isset(self::$known_paths[$id]) or strncmp($id, 'jquery.ui.', 10)==0 or strncmp($id, 'jquery.effetcs.', 15)==0 )
+ {
+ $this->add($id, $load_mode, array(), null);
+ return true;
+ }
+ return false;
+ }
+
private function compute_script_topological_order($script_id, $recursion_limiter=0)
{
if (!isset($this->registered_scripts[$script_id]))