function _jplayer_check_id in jPlayer 6
Same name and namespace in other branches
- 7.2 includes/jplayer.theme.inc \_jplayer_check_id()
Return a unique ID for a jPlayer. This allows multiple embedded jPlayers to point to an identical file on the same page.
Parameters
$id: The ID to check for uniqueness.
Return value
A modified ID if the ID was not unique, or the same ID passed in if it was unique.
3 calls to _jplayer_check_id()
- template_preprocess_jplayer_playlist in includes/
jplayer.theme.inc - Preprocess function for jplayer.tpl.php when using a playlist.
- template_preprocess_jplayer_single in includes/
jplayer.theme.inc - Preprocess function for jplayer.tpl.php when doing a single item.
- template_preprocess_jplayer_view_playlist in includes/
jplayer.theme.inc - Preprocess function for jplayer.tpl.php when displaying a view as a playlist.
File
- includes/
jplayer.theme.inc, line 117
Code
function _jplayer_check_id($id) {
// We keep track of player IDs generated per request. This ensures that if a
// player pointing to the same field is shown multiple times on a page, that
// each player gets a unique ID. This is especially a problem when jPlayers
// are embedded in hidden content such as View rendered with Quicktabs.
static $player_ids = array();
// Add the request time, so if the same player is inserted multiple times
// AJAX all players are functional.
$id = $id . '-' . $_SERVER['REQUEST_TIME'];
// Store a count of the number of times a unique ID is used, and make it
// unique if needed.
if (isset($player_ids[$id])) {
$id = $id . '-' . $player_ids[$id]++;
}
else {
$player_ids[$id] = 0;
}
return $id;
}