Changeset 20260
- Timestamp:
- 07/17/09 21:41:49 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
plugins/sfJqueryMediaPlugin/trunk/lib/helper/JQueryMediaHelper.php
r20175 r20260 20 20 21 21 22 22 /** 23 * The jQuery Media Plugin supports unobtrusive conversion of standard markup into rich media content. 24 * It can be used to embed virtually any media type, including Flash, Quicktime, Windows Media Player, Real Player, 25 * MP3, Silverlight, PDF and more, into a web page. The plugin converts an element (usually an <a>) 26 * into a <div> which holds the object, embed or iframe tags neccessary to render the media content. 27 * 28 * @author Yoda-BZH, yodabzh@gmail.com 29 * @param $pId the id of the link 30 * @param $pOptions an array of options 31 * @param $pHtmlAttributes unused 32 * @return javascript code 33 */ 23 34 function jq_media($pId, array $pOptions = array(), array $pHtmlAttributes = array()) { 35 /** 36 * adding javascript files to the headers 37 */ 24 38 $response = sfContext::getInstance()->getResponse(); 25 39 $response->addJavascript('/sfJqueryMediaPlugin/js/jquery.media.js'); 40 /** 41 * apparently jquery media doesn't support on-the-fly by-option player change ... 42 */ 43 $preferences = ''; 44 foreach(array('mp3Player', 'flvPlayer') as $player) { 45 if(array_key_exists($player, $pOptions)) { 46 $preferences .= ' $.fn.media.defaults.'.$player.' = "'.$pOptions[$player].'"'."\n"; 47 unset($pOptions[$player]); 48 } 49 } 50 /** 51 * sort the options by *key* name 52 */ 53 ksort($pOptions); 26 54 $opts = jq_media_compute_options($pOptions); 27 55 $code = ' 28 56 jQuery(document).ready(function() { 57 '.$preferences.' 29 58 jQuery("#'.$pId.'").media({ 30 59 '.$opts.' … … 35 64 } 36 65 37 66 /** 67 * return a string for a well formated json array 68 * @param $pOptions 69 * @return a string with the options 70 * @author Yoda-BZH, yodabzh@gmail.com 71 */ 38 72 function jq_media_compute_options($pOptions) { 39 73 /** … … 42 76 $opts = array(); 43 77 foreach($pOptions as $k => $v) { 44 //if($k == 'height' || $k == 'width') {45 // $v .= 'px';46 //}47 78 switch(gettype($v)) { 48 79 case 'int' :