Skip to content
This repository was archived by the owner on Oct 30, 2021. It is now read-only.

scripts from Cdn's #26

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion elements/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,25 @@ function getIncludeFile()
// not found
RETURN false;
}
}

/**
* Replace javascript frameworks or own scripts with versions from Cdn's
* renames an array key, only if it exists, keeping the order
* $array is the js array from the document object
* $url_oldjs = the original path
* $url_newjs = the path to a Cdn
*
* returns the changed array
*/
public static function replaceUrljs($array, $url_oldjs, $url_newjs)
{
$keys = array_keys($array);
$index = array_search($url_oldjs, $keys);

if ($index !== false) {
$keys[$index] = $url_newjs;
$array = array_combine($keys, $array);
}
return $array;
}
}