'swftools_imagerotator', 'title' => t('JW Image Rotator 3'), 'download' => 'http://www.longtailvideo.com/players/jw-image-rotator', 'width' => 400, 'height' => 320, 'library' => swftools_get_library('imagerotator') . '/imagerotator.swf', 'profile' => array( 'path' => 'imagerotator', 'settings' => array('swftools_imagerotator'), 'file' => 'swftools_imagerotator.admin.inc', 'page argument' => 'swftools_imagerotator_profile_form', ), ); $methods['image_list']['imagerotator'] = $image_rotator; return $methods; } /** * Implementation of hook_menu(). */ function swftools_imagerotator_menu() { $items['admin/settings/swftools/imagerotator'] = array( 'title' => 'JW Image Rotator 3', 'description' => 'Plug-in for ' . l('JW Image Rotator 3', 'http://www.longtailvideo.com/players/jw-image-rotator') . '.', 'access arguments' => array('administer flash'), 'page callback' => 'drupal_get_form', 'page arguments' => array('swftools_imagerotator_admin_form'), 'file' => 'swftools_imagerotator.admin.inc', ); return $items; } /** * These are the default settings as they are stored in the database and displayed * on the settings page. */ function _swftools_imagerotator_settings($profile = '', $mode = SWFTOOLS_STORED_SETTINGS) { /** * SWFTOOLS_STORED_SETTINGS is the minimum set of variables required to put a functional * player on the page. It should include any required variables that must be passed to * the player creation function to avoid notice errors because of undefined variables. * * SWFTOOLS_FULL_SETTINGS is the full complement of variables, as assigned on the input * page. It is normally only retrieved when the admin page requests them. */ $defaults = array( SWFTOOLS_STORED_SETTINGS => array( 'basic' => array( 'width' => '400', 'height' => '320', ), 'imagecache' => array( 'imagecache' => SWFTOOLS_UNDEFINED, ), ), SWFTOOLS_FULL_SETTINGS => array( 'basic' => array( 'width' => '400', 'height' => '320', ), 'color' => array( 'backcolor' => '', 'frontcolor' => '', 'lightcolor' => '', ), 'appearance' => array( 'logo' => '', 'overstretch' => 'default', 'showicons' => 'default', 'shownavigation' => 'default', 'transition' => 'default', ), 'playback' => array( 'rotatetime' => '3', 'shuffle' => 'default', ), 'interaction' => array( 'enablejs' => 'default', 'link' => '', 'linkfromdisplay' => 'default', 'linktarget' => 'default', ), 'imagecache' => array( 'imagecache' => SWFTOOLS_UNDEFINED, ), ), ); // Retrieve default settings $settings = swftools_variable_get('swftools_imagerotator', $defaults[SWFTOOLS_STORED_SETTINGS], $profile); // If a full set of settings are requested for the admin page then merge with full defaults if ($mode == SWFTOOLS_FULL_SETTINGS) { $settings = swftools_array_merge($defaults[SWFTOOLS_FULL_SETTINGS], $settings); } // Return resulting defaults return $settings; } /** * Implementation of hook_swftools_preprocess_[player](). */ function swftools_imagerotator_swftools_preprocess_imagerotator(&$data) { // Get current defaults for the player $saved_settings = _swftools_imagerotator_flashvars($data['othervars']['profile']); // Don't output our imagecache settings unset($saved_settings['imagecache']); // Prepare an array of flashvars by merging defaults and user values $data['flashvars'] = array_merge($saved_settings, $data['flashvars']); // Attach file url of the content to display to flashvars $data['flashvars']['file'] = $data['othervars']['file_url']; } /** * This function is called from swftools_imagerotator_swftools_flashvars() which is called from swf() * It will return the default flashvar configuration, just prior to any overrides * passed into swf(). We start with the settings defined on admin/swf/imagerotator * which are returned by _swftools_imagerotator_settings(). Then we prepare these values for output * to html (eg. '1' become 'true') and we unset undefined flashvars to prevent their output. * */ function _swftools_imagerotator_flashvars($profile = '') { // Initialise cache to handle repeated calls static $cache = array(); // Store name of profile $_profile = $profile ? $profile : SWFTOOLS_UNDEFINED; // If no settings stored for this profile then fetch them if (!isset($cache[$_profile])) { // Get saved settings for this method. $settings = _swftools_imagerotator_settings($profile); // Flatten defaults swftools_array_flatten($settings); // Iterate over boolean settings foreach (array('showicons', 'shownavigation', 'shuffle', 'enablejs', 'linkfromdisplay') as $key) { // Settings are already encoded properly on the settings page, but if we called from PHP it might be 1/0 or TRUE/FALSE if ($settings[$key] != 'default') { $settings[$key] = _swftools_tf($settings[$key]); } } // Store the result $cache[$_profile] = $settings; } // Return the result return $cache[$_profile]; } /** * Implementation of hook_swftools_playlist_PLAYER(). */ function swftools_imagerotator_swftools_playlist_imagerotator($data) { /** * ImageRotator prints undefined if there is a blank title amongst * others that are set, but it skips all titles if all of them are * blank. To make tidy output we will build two playlists in parallel * and count the number of blanks. Then we will decide which one to * return. If every title is blank we output the xml with blank titles. * If there is a mixture of blank and non-blank titles then we output * a list where the blanks are replaced with a dash. */ // Get array of image rotator settings $saved_settings = _swftools_imagerotator_flashvars($data['othervars']['profile']); // Initialise a string to contain the elements $xml_with_blanks = ''; $xml_with_blanks_replaced = ''; $blanks = 0; // Iterate over the playlist to build elements xml foreach ($data['othervars']['playlist_data']['playlist'] AS $track => $details) { // If imagecache is enabled see if we need to use a modified thumbnail if ($saved_settings['imagecache'] != SWFTOOLS_UNDEFINED) { $details['fileurl'] = swftools_imagecache_create_path($saved_settings['imagecache'], $details['fileurl']); } // Create an individual xml element on the raw playlist $xml_with_blanks .= theme('swftools_imagerotator_playlist_element', $details); // Is the title blank? if (!$details['title']) { $details['title'] = '-'; $blanks++; } // Create the parallel xml which has blanks replaced with a dash $xml_with_blanks_replaced .= theme('swftools_imagerotator_playlist_element', $details); } // Was every title in the playlist blank? if ($blanks == count($data['othervars']['playlist_data']['playlist'])) { $xml = $xml_with_blanks; } else { $xml = $xml_with_blanks_replaced; } // Add xml wrapper around the elements $xml = theme('swftools_imagerotator_playlist_wrapper', $data['othervars']['playlist_data']['header'], $xml); // Return the resulting xml return $xml; } /* * Implementation of hook_swftools_variable_mapping. * */ function swftools_imagerotator_swftools_variable_mapping() { return array( 'imagerotator' => array( 'height' => 'flashvars', 'width' => 'flashvars', 'shuffle' => 'flashvars', 'shownavigation' => 'flashvars', 'linkfromdisplay' => 'flashvars', 'showicons' => 'flashvars', 'enablejs' => 'flashvars', 'backcolor' => 'flashvars', 'frontcolor' => 'flashvars', 'lightcolor' => 'flashvars', 'logo' => 'flashvars', 'link' => 'flashvars', 'rotatetime' => 'flashvars', 'transition' => 'flashvars', 'linktarget' => 'flashvars', 'overstretch' => 'flashvars', ), ); } /** * Implementation of hook_help */ function swftools_imagerotator_help($path, $arg) { switch ($path) { case 'admin/settings/swftools/imagerotator': return '
' . t('These are the settings for Jeroen Wijering\'s imagerotator.swf and correspond (by category and order) to the Media Player and Image Rotator read me. It is possible that you do not need to change any of these settings and blank values will defer to friendly defaults. Note that the label in (brackets) is the actual flashvar name and corresponds to the read me.', array('@imagerotator' => 'http://jeroenwijering.com/extras/readme.html')) . '
'; } } /** * Implementation of hook_theme(). */ function swftools_imagerotator_theme() { return array( 'swftools_imagerotator_playlist_element' => array( 'template' => 'swftools-imagerotator-playlist-element', 'arguments' => array('element' => NULL), ), 'swftools_imagerotator_playlist_wrapper' => array( 'template' => 'swftools-imagerotator-playlist-wrapper', 'arguments' => array('header' => NULL, 'xml' => NULL), ), ); }