function swftools_get_from_cache in SWF Tools 6.3
Creates a cid for the call to swf() and returns its data from the cache when available.
To make our cid we create an array from $file and $options. Then we serialize it, and then we run it through md5. This generates a unique cid for that piece of content.
Once the cid is created it is attached to $options['othervars']['cid'] so that subsequent functions don't have to rehash the data to generate it again.
Within {cache_swftools} we store each item as an associative array.
- html: the actual mark up to place the Flash on the page
- xml: associated xml (for xml based playlists)
Parameters
string $file: The $file parameter from the call to swf().
array $options: The $options parameter from the call to swf().
Return value
mixed The cached content as a array, or FALSE if it is isn't available.
1 call to swftools_get_from_cache()
- swf in ./
swftools.module - Processes a file, or an array of files, and returns the relevant mark-up to render a Flash based player.
File
- ./
swftools.module, line 1763 - The primary component of SWF Tools that enables comprehensive media handling.
Code
function swftools_get_from_cache($file, &$options) {
// Construct a cid for this piece of content
$cid = md5(serialize(array(
$file,
$options,
)));
// Set the cid on othervars ready to store this item if we have to render it
$options['othervars']['cid'] = $cid;
// If this is in the cache then return it
if ($ret = cache_get($cid, 'cache_swftools')) {
return $ret;
}
// Indicate that we don't have cached data
return SWFTOOLS_NOT_CACHED;
}