Skip to content

Commit

Permalink
Now allows for passing an array of scripts to expJavascript::pushToFo…
Browse files Browse the repository at this point in the history
…ot/expTheme::foot(), etc... like we allow for css; also now compensates for not having passed those scripts or css with the 'unique' param so we assign one based on microtime to keep errors out [#1146]
  • Loading branch information
dleffler committed Feb 3, 2016
1 parent 57a8d69 commit 06532d8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
7 changes: 6 additions & 1 deletion framework/core/subsystems/expCSS.php
Expand Up @@ -114,7 +114,12 @@ public static function pushToHead($params) {
// css hard coded in a view
if (!empty($params['css'])){
$tcss = trim($params['css']);
if (!empty($tcss)) $css_inline[$params['unique']] = $params['css'];
if (!empty($tcss)) {
if (empty($params['unique'])) {
$params['unique'] = "unique-" . microtime(); // must be unique for each call
}
$css_inline[$params['unique']] = $params['css'];
}
}

// if within an ajax call, immediately output the css
Expand Down
25 changes: 14 additions & 11 deletions framework/core/subsystems/expJavascript.php
Expand Up @@ -399,18 +399,21 @@ public static function pushToFoot($params) {
global $js2foot, $yui3js, $jqueryjs, $bootstrapjs, $expJS;

if (!empty($params['src'])) {
//$src = str_replace(URL_FULL,PATH_RELATIVE,$params['src']);
$src = $params['src'];
//FIXME we need to allow for an array of scripts with unique+index as name
//if (file_exists(str_replace(PATH_RELATIVE,"",$src))) {
$expJS[$params['unique']] = array(
"name" => $params['unique'],
"type" => 'js',
"fullpath" => $src
$params['src'] = is_array($params['src']) ? $params['src'] : array($params['src']);
foreach ($params['src'] as $unique=>$url) {
//if (file_exists(str_replace(PATH_RELATIVE,"",$src))) {
if (is_int($unique)) {
$unique = "unique-" . microtime(); // must be unique for each call
}
$expJS[$unique] = array(
"name" => $unique,
"type" => 'js',
"fullpath" => $url
);
// } else {
// flash('error',"Exponent could not find ".$src.". Check to make sure the path is correct.");
// }
// } else {
// flash('error',"Exponent could not find ".$src.". Check to make sure the path is correct.");
// }
}
}

// insert the yui2mods wrapper if needed
Expand Down

0 comments on commit 06532d8

Please sign in to comment.