| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: lutman.module,v 1.4.2.1 2009/03/31 21:21:26 stuartgreenfield Exp $ 3 4 /** 5 * SWF Tools - Luke Lutman Flash Replacement 6 * 7 * Enables the use of Luke Lutman's jquery.flash.js which ships with 8 * the SWF Tools module. jquery.flash.js provides Flash replacement 9 * techniques. 10 * 11 * Author's Site. 12 * http://jquery.lukelutman.com/plugins/flash/ 13 */ 14 15 function lutman_swftools_methods() { 16 $methods = array(); 17 $methods[SWFTOOLS_EMBED_METHOD]['lutman_replace'] = array ( 18 'name' => 'lutman_replace', 19 'module' => 'lutman', 20 'shared_file' => 'lutman/jquery.flash.js', 21 'title' => t('jQuery Flash plugin - JavaScript'), 22 'download' => 'http://jquery.lukelutman.com/plugins/flash/', 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 lutman_swftools_embed($action = 'add_js', $methods = FALSE, $vars = FALSE, $html_alt = '') { 32 33 static $lutman_has_run; 34 35 // Output javascript to the header 36 if (!$lutman_has_run) { 37 // Add jquery.flash.js 38 drupal_add_js(swftools_get_player_path() .'/lutman/jquery.flash.js'); 39 drupal_add_js(_lutman_header_js(), 'inline', 'header'); 40 $lutman_has_run = TRUE; 41 if ($action == 'add_js') { 42 // Exit early having put the javascript in the header. 43 return; 44 } 45 } 46 47 // Initialise a counter to give each div a unique id 48 static $unique_id = 0; 49 $unique_id++; 50 51 // Construct a unique id for each div by using time() combined with $unique_id 52 // This is necessary to prevent clashes between cached content 53 $id = time() . $unique_id; 54 55 // Use time() to prevent caching issues. 56 $html = '<div id="swfobject-id-' . $id . '" class="swftools lutman" ' . 57 swftools_json_params($vars->params, 'swftools') . ' ' . ">\n" . 58 $html_alt . 59 '</div>'; 60 return $html; 61 } 62 63 /** 64 * The jQuery code that will try to replace all elements after the page loads. 65 * This parses the JSON out of the 'data' attribute of all swftools-embed divs. 66 * 67 */ 68 function _lutman_header_js() { 69 $js = " 70 $(document).ready(function(){ 71 $('.lutman').flash(null, {version:7}, function(htmlOptions) { 72 htmlOptions = Drupal.parseJson($(this).attr('swftools')); 73 $(this).parent().prepend($.fn.flash.transform(htmlOptions)); 74 $(this).remove(); 75 }); 76 }); 77 "; 78 return $js; 79 }
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 |