Index: README.txt =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/swfobject_api/README.txt,v retrieving revision 1.1.2.3 diff -u -p -r1.1.2.3 README.txt --- README.txt 14 Aug 2007 03:35:10 -0000 1.1.2.3 +++ README.txt 13 Oct 2008 21:11:14 -0000 @@ -9,46 +9,44 @@ This module makes it easier to add flash Installation ------------------------------------- - 1) Please module into modules directory - 2) Download SWFObject library from: - http://blog.deconcept.com/swfobject/#download + 1) Place module into modules directory + 2) Download SWFObject library 2 from: + http://code.google.com/p/swfobject/ 3) Place the swfobject.js file into modules/swfobject_api/ 4) Place the expressinstall.swf file into modules/swfobject_api/ 5) Activate module in admin/build/modules 6) Configure the module via admin/settings/swfobject_api - - Usage - ------------------------------------ - Adding flash to your theme is as simple as: - - $url = "myflashfile.swf"; //path to flash file - $params = array('width' => 100, 'height' => 100 ); - $variables = array('foo' => 'bar'); - print theme("swfobject_api", $url, $params, $variables); - - Example: - - 320, - 'height' => 240, - ); - - $vars = array( - 'file' => base_path() . path_to_theme() .'/files/song.mp3', - 'image' => base_path() . path_to_theme() ./files/image.jpg', - ); - - print theme("swfobject_api", base_path() . path_to_theme() . '/flash/mediaplayer.swf', $params, $vars); + +Usage +------------------------------------ +Adding flash to your theme is as simple as: + + $url = "myflashfile.swf"; //path to flash file + $params = array('width' => 100, 'height' => 100 ); + $variables = array('foo' => 'bar'); + print theme("swfobject_api", $url, $params, $variables); + +Example: + + 320, + 'height' => 240, + ); + + $vars = array( + 'file' => base_path() . path_to_theme() .'/files/song.mp3', + 'image' => base_path() . path_to_theme() ./files/image.jpg', + ); + + print theme("swfobject_api", base_path() . path_to_theme() . '/flash/mediaplayer.swf', $params, $vars); ?> - - Advanced Usage - ------------------------------------ - You can change the class and id of the div wrapping the flash file with: - $param['div_id'] - $param['class'] - - You can change the "No flash detected" message with - $param['no_flash'] - - \ No newline at end of file + +Advanced Usage +------------------------------------ + You can change the class and id of the div wrapping the flash file with: + $param['div_id'] + $param['class'] + + You can change the "No flash detected" message with + $param['no_flash'] Index: swfobject_api.info =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/swfobject_api/swfobject_api.info,v retrieving revision 1.1 diff -u -p -r1.1 swfobject_api.info --- swfobject_api.info 25 Jan 2007 17:38:38 -0000 1.1 +++ swfobject_api.info 13 Oct 2008 21:11:14 -0000 @@ -1,3 +1,6 @@ ; $Id$ -name = SWFObject Module +name = SWFObject API description = Implements the SWFObject Library, makes it easy for developers to add flash content +core = 6.x +project = "swfobject_api" +version = "6.x-2.0" Index: swfobject_api.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/swfobject_api/swfobject_api.install,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 swfobject_api.install --- swfobject_api.install 14 Aug 2007 01:55:46 -0000 1.1.2.1 +++ swfobject_api.install 13 Oct 2008 21:11:14 -0000 @@ -1,14 +1,55 @@ l('http://code.google.com/p/swfobject/', 'http://code.google.com/p/swfobject/')) + ); -function swfobject_api_install() { + // we need to explicitly set the message when installing the module, + // because drupal_check_module() in install.inc doesn't print out + // warning messages, and we prefer to tell the user what's wrong. + if ($phase == 'install') { + drupal_set_message($error_message, 'warning'); + } - // alert the user that they need to download the js file - if (!(file_exists(drupal_get_path('module','swfobject_api') . "/swfobject.js"))) { - drupal_set_message(t("You need to download the swfobject.js file from ". l('http://blog.deconcept.com/swfobject/', 'http://blog.deconcept.com/swfobject/') . " and place it in the swfobject module directory. Please see the README.txt"), 'error'); - } + $requirements['swfobject_api'] = array( + 'title' => $t('SWFObject API'), + 'description' => $error_message, + 'severity' => $phase == 'install' ? REQUIREMENT_WARNING : REQUIREMENT_ERROR, + 'value' => $t('Copy swfobject.js'), + ); + } + elseif ($phase == 'runtime') { + $requirements['swfobject_api'] = array( + 'title' => $t('SWFObject API'), + 'severity' => REQUIREMENT_OK, + 'value' => $t('Installed correctly'), + ); + } -} \ No newline at end of file + return $requirements; +} Index: swfobject_api.js =================================================================== RCS file: swfobject_api.js diff -N swfobject_api.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ swfobject_api.js 13 Oct 2008 21:11:14 -0000 @@ -0,0 +1,8 @@ +Drupal.behaviors.swfobjectInit = function (context) { + var settings = Drupal.settings.swfobject_api; + + $('.swfobject:not(.swfobjectInit-processed)', context).addClass('swfobjectInit-processed').each(function () { + var config = settings['files'][$(this).attr('id')]; + swfobject.embedSWF(config.url, $(this).attr('id'), config.width, config.height, config.version, config.express_redirect, config.flashVars, config.params, config.attributes); + }); +}; Index: swfobject_api.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/swfobject_api/swfobject_api.module,v retrieving revision 1.2.2.20 diff -u -p -r1.2.2.20 swfobject_api.module --- swfobject_api.module 24 Jun 2008 12:33:39 -0000 1.2.2.20 +++ swfobject_api.module 13 Oct 2008 21:11:15 -0000 @@ -1,52 +1,47 @@ -http://blog.deconcept.com/swfobject/.'); + return t('This module creates an API for flash content generation in pages based on the swfObject library. For more information, visit http://code.google.com/p/swfobject/.'); break; - } } - /** - * Implementation of hook_menu(). + * Implementation of hook_perm(). */ -function swfobject_api_menu($may_cache) { - $items = array(); - if ($may_cache) { - $items[] = array( - 'path' => 'admin/settings/swfobject_api', - 'title' => t('SWFObject API'), - '#description' => t('Configure the SWFObject API.'), - 'access' => user_access('administer swfobject_api'), - 'callback' => 'drupal_get_form', - 'callback arguments' => 'swfobject_api_settings_form' - ); - } - return $items; +function swfobject_api_perm() { + return array('administer swfobject'); } - /** - * implementation of drupal's hook_perm + * Implementation of hook_menu(). */ -function swfobject_api_perm(){ - return array('administer swfobject_api'); +function swfobject_api_menu() { + $items = array(); + $items['admin/settings/swfobject_api'] = array( + 'title' => 'SWFObject API', + 'page callback' => 'drupal_get_form', + 'page arguments' => array('swfobject_api_settings_form'), + 'access arguments' => array('administer swfobject'), + ); + return $items; } - /** * Menu callback: SWFObject API configuration form. */ @@ -56,133 +51,127 @@ function swfobject_api_settings_form() { $form['swfobject_api_settings'] = array( '#type' => 'fieldset', '#title' => t('Settings'), - '#tree' => TRUE + '#tree' => TRUE, ); $form['swfobject_api_settings']['swfoa_version'] = array( '#type' => 'textfield', '#title' => t('Default minimum version required'), '#description' => t('This value can be overridden via the theme call.'), '#default_value' => variable_get('swfoa_express', '6'), - '#required' => TRUE + '#required' => TRUE, ); $form['swfobject_api_settings']['swfoa_express'] = array( '#type' => 'checkbox', '#title' => t('Enable express install.'), '#description' => t('Express install allows player upgrades without having to leave the site. Only versions 6.0.65 and above are supported.'), - '#default_value' => variable_get('swfoa_express', false), + '#default_value' => variable_get('swfoa_express', FALSE), ); $form['submit'] = array('#type' => 'submit', '#value' => t('Save settings')); return system_settings_form($form); } - /** - * Implementation of theme - * @param $url a web accessible url to the flash file - * @param $params an associative array of parameters that describe the SWF - * @param $vars an associative array of variables to pass through to the SWF flashvars value - * @param $id is an id to appened to the so object - * @param string $method determins if the object is written or placed in jquery document ready - * @return themed html + * Implementation of hook_theme(). */ -function theme_swfobject_api($url, $params = array(), $vars = array(), $id = null, $method = null) { - static $id_count; +function swfobject_api_theme() { + return array( + 'swfobject_api' => array( + 'arguments' => array( + 'url' => NULL, + 'params' => NULL, + 'vars' => NULL, + 'id' => NULL, + 'attributes' => NULL + ) + ) + ); +} - // set the base parameters +/** + * Theme function to add a flash file to the page. + * + * The actual returned HTML from this function is minimal. Its main effect is + * side effects to setup the Javascript properly. + * + * @ingroup themeable + * @param $url + * A web accessible url to the flash file. + * @param $params + * An associative array of parameters that describe the SWF. + * @param $vars + * An associative array of variables to pass through to the SWF flashvars value. + * @param $id + * An id to appened to the so object. + * @param $attributes + * Associative array of attributes to apply to the resulting flash tag (embed, object, etc.) + */ +function theme_swfobject_api($url, $params = array(), $vars = array(), $id = NULL, $attributes = array()) { + static $swfobject_id = 1; + + _swfobject_api_ensure_swfobject(); + + // Build the base params. $base_params = array( 'width' => '100%', 'height' => '100%', 'no_flash' => t('Sorry, you need to install flash to see this content.'), - 'version' => variable_get('swfoa_version', '5'), + 'version' => variable_get('swfoa_version', '6'), 'type' => 'movie', - 'bg_color' => '#FFFFFF' + 'bg_color' => '#FFFFFF', + 'express_redirect' => variable_get('swfoa_express', TRUE) ? drupal_get_path('module', 'swfobject_api') .'/expressinstall.swf' : 'false', + 'class' => '', ); + + // Merge in default parameters. + $params += $base_params; + + $div_id = empty($id) ? 'swfobject-'. $swfobject_id++ : $id; - $params = array_merge($base_params, $params); - - // Express install redirect URL: as per the SWFObject docs, this should - // actually be xiRedirectUrl; variable name changed for simplicity. - if (isset($param['express_redirect'])) { - $redirect = $param['express_redirect']; - } - - // create a unique id, use what's passed in, what has been saved locally - if ($id) { $id_count = $id; } - else { - $id_count = $id_count ? $id_count : 1; - } - - // set the name of the swf file - $name = form_clean_id(str_replace('.swf', '', basename($url))) .'_'. $id_count; - - // set the div id to the params - if ($params['div_id']) { - $div_id = $params['div_id']; - unset($params['div_id']); - } - else { - $div_id = 'flashcontent_'. $name; - } - - // build the class - if ($params['class']) { - $class = ' class="'. $params['class'] .'"'; - unset($params['class']); - } - - // build the div structure - $html[] = '
'. $params['no_flash'] ."
"; - - // build the javascript - // get the path to thje swf object library - $path = base_path() . drupal_get_path('module', 'swfobject_api') .'/swfobject.js'; - - // we need to add the swfobject library but we need to do this inside the - // html because theme functions can be cached - $html[] = ''; - - $html[] = ''; - - // increment the id count - $id_count ++; - - return implode("\n", $html); + // Load the swfobject library and our add-on to activate it. + drupal_add_js(drupal_get_path('module', 'swfobject_api') .'/swfobject.js', 'module', 'footer'); + drupal_add_js(drupal_get_path('module', 'swfobject_api') .'/swfobject_api.js', 'module', 'footer'); + + $done = TRUE; }