| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: ufo.module,v 1.2 2008/09/07 19:42:14 stuartgreenfield Exp $ 3 4 /** 5 * SWF Tools - UFO 6 * 7 * Enables the use of Bobby Van der Sluis's ufo.js which provides image replacement 8 * for Flash content. ufo.js must be downloaded separately (add the whole zip 9 * file to swftools/shared/ 10 * 11 * Author's Site. 12 * http://www.bobbyvandersluis.com/ufo/ 13 */ 14 15 function ufo_swftools_methods() { 16 $methods = array(); 17 $methods[SWFTOOLS_EMBED_METHOD]['ufo_replace'] = array ( 18 'name' => 'ufo_replace', 19 'module' => 'ufo', 20 'shared_file' => 'ufo/ufo.js', 21 'title' => t('UFO - JavaScript'), 22 'download' => 'http://www.bobbyvandersluis.com/ufo/', 23 ); 24 return $methods; 25 } 26 27 /** 28 * Implementation of swftools_embed hook 29 * Returns the markup for the page, plus set necessary javascript. 30 */ 31 function ufo_swftools_embed($action = 'add_js', $methods = FALSE, $vars = FALSE, $html_alt = '') { 32 33 static $ufo_has_run; 34 static $ufo_id = 0; 35 36 // Output javascript to the header 37 if (!$ufo_has_run) { 38 // Add ufo.js 39 drupal_add_js(swftools_get_player_path() .'/ufo/ufo.js'); 40 drupal_add_js(_ufo_header_js(), 'inline', 'header'); 41 $ufo_has_run = TRUE; 42 if ($action == 'add_js') { 43 // Exit early having put the javascript in the header. 44 return; 45 } 46 } 47 48 static $unique_id = 0; 49 $unique_id++; 50 51 $html = '<div id="ufo-id-'. time() . $unique_id . '" class="swftools ufo" '. 52 swftools_json_params($vars->params, 'swftools') .' '.">\n". 53 $html_alt . 54 '</div>'; 55 return $html; 56 } 57 58 /** 59 * The jQuery code that will try to replace all elements after the page loads. 60 * This parses the JSON out of the 'swftools' attribute of all class="ufo" divs. * 61 */ 62 function _ufo_header_js() { 63 64 $js = " 65 $(document).ready(function(){ 66 $('.ufo').each(function(i){ 67 params = Drupal.parseJson($(this).attr('swftools')); 68 var FO = { movie: params['src'], width: params['width'], height: params['height'], 69 majorversion: params['version'], build: '0', xi: 'false', 70 quality: params['quality'], wmode: params['wmode'], align: params['align'], 71 salign: params['salign'], play: params['play'], loop: params['loop'], 72 menu: params['menu'], base: params['base'], flashvars: params['flashvars'], 73 allowfullscreen: 'true' 74 }; 75 UFO.create(FO, this.id); 76 }); 77 }); 78 "; 79 return $js; 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |