'swftools' * - Return constants defining the library, alternate content, * and the default for adding JavaScript to all pages. */ /** * @addtogroup swftools * @{ */ /** * JavaScript will be added to all pages when they are served, even if SWF Tools isn't called directly. */ define('SWFTOOLS_ALWAYS_ADD_JS', 0x0001); /** * The default alternate markup string that is displayed if the embedding process fails. */ define('SWFTOOLS_DEFAULT_HTML_ALT', '

You are missing some Flash content that should appear here! Perhaps your browser cannot display it, or maybe it did not initialize correctly.

'); /** * JavaScript will be added inline with the page markup. */ define('SWFTOOLS_JAVASCRIPT_INLINE', 0x0000); /** * JavaScript will be added to the page header. */ define('SWFTOOLS_JAVASCRIPT_HEADER', 0x0001); /** * JavaScript will be added to the page footer. */ define('SWFTOOLS_JAVASCRIPT_FOOTER', 0x0002); /** * Turns an SWF Tools data array in to markup for inclusion on the page, * using W3C compliant HTML. */ function theme_swftools_direct($file, $options) { // Strip out unset values, e.g. bgcolor $options['params'] = array_filter($options['params']); // Build parameters string $params = ''; foreach ($options['params'] as $key => $value) { $params .= ''; } // Attach flashvars parameter, if flashvars are present $params .= $options['flashvars'] ? '' : ''; // Construct embedding markup $html = ''; $html .= ''; $html .= $params; $html .= ''; $html .= ''; $html .= $params; $html .= ''; $html .= $options['othervars']['html_alt']; $html .= ''; $html .= ''; $html .= ''; $html .= ''; // Return the result return $html; } /** * @} End of "addtogroup swftools". */ /** * Collects information from all modules about the players and embedding methods available. * * @param $action * Optional parameter to retrieve data only about a specific method. * @param $reset * Optional parameter which if TRUE will reset the method cache and rebuild it. * * @return * An array of data describing the available methods. */ function swftools_get_methods($action = NULL, $reset = FALSE) { // Cache methods array as it may be called several times static $methods; // If user has requested the cache to be reset then reset it if ($reset || !isset($methods)) { if (!$reset && ($cached = cache_get('swftools:methods'))) { $methods = $cached->data; } else { $methods = array(); foreach (module_implements('swftools_methods') as $module) { $function = $module . '_swftools_methods'; if (function_exists($function)) { $implements = $function(); foreach ($implements as $method_type => $method) { foreach ($method as $method_name => $method_details) { $method_details += array( 'name' => $method_name, 'module' => '', 'title' => '', 'download' => '', 'library' => '', 'profile' => array(), ); if ($method_type == 'swftools_embed_method') { $method_details += array( 'theme' => $method_name, ); } else { $method_details += array( 'version' => 7, ); } $methods[$method_type][$method_name] = $method_details; } } } } cache_set('swftools:methods', $methods); } } // In case no module is presenting a method for the required action the following line avoids a notice error if ($action) { $methods += array( $action => NULL, ); } // Return results - either for the specific action, or the whole array return $action ? $methods[$action] : $methods; } /** * Flushes all caches when new settings are stored. * * This function is called by player and embedding modules as a * submit handler to ensure all cached content is purged. * * @ingroup swftools */ function swftools_admin_settings_submit($form, &$form_state) { // Flush all caches so new players appear drupal_flush_all_caches(); } /** * Themes an swftools element by passing it on to the appropriate theme function. * * If the incoming element is not an array someone is calling to place a simple * swf on the page and they're using the API, so hand it to theme_swftools_api() * * If the incoming element is an array, and SWF Tools main module is present then * hand the element to swf() as it provides more power, such as auto-detection of * sizes and automatic rendering of media in to players. * * If the incoming element is an array, and SWF Tools main module is not avaiable * then assume we have a simple swf, so call theme_swftools_api() with just * $element['#value'] * * @param $element * An element array. * * @return * Markup to render the object. * * @ingroup swftools */ function theme_swftools($element, $options = array()) { // If the incoming element is a Forms API element remap it if (is_array($element) && isset($element['#value'])) { $options = array( 'params' => $element['#params'], 'othervars' => $element['#othervars'], 'flashvars' => $element['#flashvars'], 'methods' => $element['#methods'], ); $element = $element['#value']; } // Is the full version of SWF Tools installed? if (defined('SWFTOOLS_INSTALLED')) { // Hand over to swf() and return the result return $element ? swf($element, $options) : ''; } // Hand over to theme_swftools_api and return the result return $element ? theme('swftools_api', $element, $options) : ''; } /** * Implementation of hook_swftools_methods(). * * Note that we use a trick here as this method is always available. * We implement system_swftools_methods() as we know the system module * will always be present so we can be sure this gets reported. */ function system_swftools_methods() { $methods['swftools_embed_method']['swftools_direct'] = array( 'module' => 'swftools', 'title' => t('Direct embedding'), ); return $methods; } /** * Returns a path to the requested library, using Libraries API when it is available. * * If the Libraries API is present then the library will be searched for under the * profiles/$profile/libraries, sites/all/libraries, and sites/sitename/libraries. * * sites/sitename/libraries has the highest priority and will "win" if it is present. * * If Libraries API is not present then the library should be present in * sites/all/libraries * * @param $library * The name of the library, e.g. jwplayer4. * * @return * A path to the requested library. * * @see http://drupal.org/project/libraries Libraries API * * @ingroup swftools */ function swftools_get_library($library) { return ($ret = module_invoke('libraries', 'get_path', $library)) ? $ret : 'sites/all/libraries/' . $library; }