diff --git a/sites/all/modules/swftools/swftools.module b/sites/all/modules/swftools/swftools.module index 54e09ed..591a5ec 100644 --- a/sites/all/modules/swftools/swftools.module +++ b/sites/all/modules/swftools/swftools.module @@ -497,9 +497,9 @@ function swf($file, $options = array()) { // all existing values by reference to allow optional override at the player.module level. if (module_hook($resolved_methods->player['module'], 'swftools_flashvars')) { - // Get player flashvars - $player_flashvars = module_invoke($resolved_methods->player['module'], 'swftools_flashvars', $action, $resolved_methods, $vars); - + // Get player flashvars - use a custom invoke to allow pass by reference + $player_flashvars = swftools_flashvars_invoke($action, $resolved_methods, $vars); + // Merge player flashvars with existing flashvars if (is_array($player_flashvars)) { $vars->flashvars = array_merge($vars->flashvars, $player_flashvars); @@ -1901,10 +1901,10 @@ function theme_swftools_formatter_playlist($element) { // Find out what the alternate formatter should be if ($formatter = _content_get_formatter($formatter_name, 'filefield')) { $theme = $formatter['module'] .'_formatter_'. $formatter_name; - + // Theme the element according to the alternate formatter return theme($theme, $element[$child]); - + } } } @@ -1917,13 +1917,41 @@ function theme_swftools_formatter_playlist($element) { $files[] = $element[$key]['#item']['filepath']; } } - + // If files array is empty then there is nothing to be rendered if (empty($files)) { return; } - + // But if we got something then we can call swf() now to render it return swf($files); - + +} + +/** + * Invokes hook_swftools_flashvars() in the relevant player module. + * + * We cannot use module_invoke() for this, because the arguments need to be passed by reference. + * + * @param $action + * String defining the action that is to be performed, eg SWFTOOLS_FLV_DISPLAY + * @param &$methods + * Object containing two keys - player and method. Each consists of an array + * that defines the details of the resolved player and embedding method that + * is being used for this file. + * @param &$vars + * Object containing three keys - othervars, flashvars and params. These are + * arrays containing key/value pairs that contain all the data assigned to this + * file so far. Refer to swf() for more details about the $vars array. + * @return + * Return an array of flashvars needed to allow the player to work. + */ +function swftools_flashvars_invoke($action, &$methods, &$vars) { + + // Build the name of the function we are going to call + $function = $methods->player['module'] . '_swftools_flashvars'; + + // Call the function and return the resulting flashvars to the caller + return($function($action, $methods, $vars)); + }