code with the appropriate pmwiki video markup
** cleaned up YouTube code
** fixed GoogleVideo bug that prevented fullscreen
** permitted option of compliant and non-compliant XHTML versions of each recipe (except FlickrVid).
** removed $YouTubeDefaultHeightFmt & ..WidthFmt (for all recipes) - default width and height are now included in $YouTubeDefaultParams, $VimeoDefaultParams, and so forth.
** replaced/updated much of the documentation
* 2009-10-09 - YouTube: added 'scale' option for youtube; returned youtube code back to being xhtml 1.0 compliant; incorporated suggestion from Byron Lunz for non-XHTML-compliant version, via $YouTube_XHTMLcompliant
* 2009-09-21b: YouTube: added ability to embed YouTube playlists
* 2009-09-21: Updated swf-sites.php - changed YouTube code so that it accepts valid YouTube api parameters
*/
# Version date
$RecipeInfo['SWFSites']['Version'] = '2016-05-06';
### VIMEO
# More info on new universal version: https://vimeo.com/blog:334
SDV($Vimeo_enableNewPlayer, true);
SDV($VimeoSimpleEmbed, true);
# some parameter names have changed - drops the "show_" in some param names
SDVA($VimeoDefaultParams, array(
'width' => '400'
,'height' => '327'
,'scale' => '1'
,'title' => '1'
,'byline' => '1'
,'portrait' => '0'
,'color' => '00ADEF' # color of text
,'fullscreen' => '1'
,'autoplay' => '0'
,'loop' => '0'
));
SDV($Vimeo_XHTMLcompliant, true);
SDV($VimeoROEenabled, true);
SDV($VimeoOverrideUserParams, ''); # make a list of the parameters above that users shouldn't have control over, as in $VimeoOverrideUserParams = 'color,fullscreen';
#####################
# EMBED (:VIMEO:)
if($Vimeo_enableNewPlayer)
Markup_e('vimeo', '
$ROEPatterns['!!i'] = "VimeoROE(PSS(\$m[0]))";
function VimeoROE($vimeopattern) {
global $VimeoDefaultParams;
preg_match("#/video/(\d+)\?*#", $vimeopattern, $matchesVideoCode);
$id = $matchesVideoCode[1];
# gather all other parameters
preg_match('#\?([^\"]+)\"#', $vimeopattern, $matchesParams);
#echo "test: $matchesParams[1]"; break;
#$params .= " scale=1 ".str_replace("&"," ",$matchesParams[1]); # replace & with space
# if params aren't provided, plug in default params so that user knows what's available
if($matchesParams[1]) {
$paramsArray = explode("&",$matchesParams[1]); # separate params
foreach($paramsArray as $arr) {
# separate params into key=>val pairs, to be used in comparison with DefaultParamArray
list($arrKey,$arrVal) = explode("=",$arr);
$paramsArrayWithKeys[$arrKey] = $arrVal;
}
# add in elements from the DefaultParamArray not already provided
$paramsArray = array_merge($VimeoDefaultParams,$paramsArrayWithKeys);
} else {
$paramsArray = $VimeoDefaultParams;
}
# gather parameters - width, height
preg_match('#width=["\'](\d+)["\']\s+height=["\'](\d+)["\']#', $vimeopattern, $matchesWH);
$paramsArray['width'] = $matchesWH[1];
$paramsArray['height'] = $matchesWH[2];
# convert back to string
$params = '';
foreach($paramsArray as $key => $val) {
$params .= " $key=$val";
}
#echo $params; break;
# output
$out = "(:vimeo $id$params:)"; #echo $out; break;
return $out;
}
# *** VIMEO-EMBED-CODE-ROE: OLD, NON-HTML5 EMBED VERSION ***
# Converts pasted Vimeo embed code into valid pmwiki (:vimeo:) code
$ROEPatterns['!!i'] = "VimeoOLD_ROE(PSS(\$m[0]))";
function VimeoOLD_ROE($vimeopattern) {
global $VimeoDefaultParams;
# gather parameters - width, height
preg_match('#width=["\'](\d+)["\'] height=["\'](\d+)["\']#', $vimeopattern, $matches);
$params = 'width='.$matches[1].' height='.$matches[2];
$params .= " scale=".$VimeoDefaultParams['scale'];
# gather other parameters
preg_match('#clip_id=(\d+)&server=vimeo.com&([^\"\']*)[\"\']#', $vimeopattern, $matchesParams);
$id = $matchesParams[1];
$params .= " ".str_replace("&"," ",$matchesParams[2]);
# output
# remove empty 'color=' (sometimes provided by vimeo embed code) - causes error below in ParseArgs
$params = preg_replace('#(color=\\s+|color=$)#','',$params);
$out = "(:vimeo $id $params:)";
return $out;
}
}
###########
########
# *** NEW UNIVERSAL VIMEO PLAYER FUNCTION ***
function ShowVimeoUniversalVideo($id, $args='', $escape='') {
global $VimeoDefaultParams, $VimeoOverrideUserParams;
# escape SIMPLE EMBED if url is preceded by a `, ex.: `https://...
if($escape[0]=="`") return $escape[1];
# cleanup for new universal version - several params shortened from 'show_param' to 'param' (title, byline, portrait)
$args = str_replace("show_","",$args);
# gather up args
$args = ParseArgs($args);
# determine if any parameters/args should be overridden using the default values
if($VimeoOverrideUserParams) {
$VimeoOverrideUserParams = str_replace(" ","",$VimeoOverrideUserParams); # remove spaces
foreach(explode(",",$VimeoOverrideUserParams) as $key) {
$overrideArrayKeys[$key] = '';
}
$args = array_diff_key($args, $overrideArrayKeys);
}
# add default parameters before parsing arguments
$args = array_merge($VimeoDefaultParams, $args); # uses VimeoDefaultParams, unless supplied by user
# define width, height & scale
$scale = $args['scale'];
$width = $args['width'] * $scale;
$height = $args['height'] * $scale;
if($args) {
# remove width, height, scale params from param list, if there are any - they'll go elsewhere
# all other params go into $params
$args = array_diff_key($args, array('width'=>'','height'=>'','scale'=>''));
# create parameter string, in the form: ?arg1=val1&arg2=val2
$i = 0;
foreach($args as $key => $val) {
if ($key!='#') {
#echo "$key - $val
";
if ($i!=0) $params .= "&";
$params .= "$key=$val";
$i++;
}
}
}
#echo $params;
# Examples
#
#
# OR one with more parameters
#
#
# Output
$out = "";
return Keep($out);
}
# *** OLD VIMEO FUNCTION ***
function ShowVimeoOLDVideo($id, $args='', $escape='') {
global $VimeoDefaultParams, $Vimeo_XHTMLcompliant, $VimeoOverrideUserParams;
# escape SIMPLE EMBED if url is preceded by a `, ex.: `https://...
if($escape[0]=="`") return $escape[1];
# gather up args
$args = ParseArgs($args);
# determine if any parameters/args should be overridden using the default values
if($VimeoOverrideUserParams) {
$VimeoOverrideUserParams = str_replace(" ","",$VimeoOverrideUserParams); # remove spaces
foreach(explode(",",$VimeoOverrideUserParams) as $key) {
$overrideArrayKeys[$key] = '';
}
$args = array_diff_key($args, $overrideArrayKeys);
}
# add default parameters before parsing arguments
$args = array_merge($VimeoDefaultParams, $args); # uses VimeoDefaultParams, unless supplied by user
# define width & height
$scale = $args['scale'];
$width = $args['width'] * $scale;
$height = $args['height'] * $scale;
if($args) {
# remove width, height, scale params if there are any - they're non-api, so not necessary for parameter string
$args = array_diff_key($args, array('width'=>'','height'=>'','scale'=>''));
# create parameter string, in the form &arg1=val1&arg2=val2
$i = 0;
foreach($args as $key => $val) {
if ($key!='#') {
#echo "$key - $val
";
$params .= "&$key=$val";
$i++;
}
}
}
$url = "https://vimeo.com/moogaloop.swf?clip_id=$id&server=vimeo.com$params";
#echo "
$url";
# Output
if ($Vimeo_XHTMLcompliant) {
# XHTML 1.0 COMPLIANT
$out = "\n";
} else {
$out = "\n";
}
return Keep($out);
}
##############################
### YOUTUBE
SDV($YouTubeSimpleEmbed, true);
SDV($YouTube_enableNewPlayer, false);
SDVA($YouTubeDefaultParams, array(
'width' => '425'
,'height' => '344'
,'plwidth' => '480' # slightly different default size for embedding playlists
,'plheight' => '385' # slightly different default size for embedding playlists
,'scale' => '1'
,'fs' => '1'
,'hd' => '1'
,'nocookie' => '1'
));
SDV($YouTube_XHTMLcompliant, true);
SDV($YouTubeROEenabled, true);
SDV($YouTubeOverrideUserParams, ''); # make a list of the parameters above that users shouldn't have control over, as in $YouTubeOverrideUserParams = 'fs,width,height';
#####################
# EMBED: (:YOUTUBE:)
/*
if($YouTube_enableNewPlayer)
Markup('youtube', '
#$ROEPatterns['!!ie'] = "YouTubeIFRAME_ROE(PSS('$0'))";
$ROEPatterns['!!i'] = "YouTubeIFRAME_ROE(PSS(\$m[0]))";
function YouTubeIFRAME_ROE($videopattern) {
global $YouTubeDefaultParams;
preg_match("#/embed/([^\?\"]+)[\"\?]#", $videopattern, $matchesID);
$id = $matchesID[1];
#echo $id; break;
$params = '';
# check for playlist
#if(strpos($videocode, '/p/')) {
# $params = " playlist=1 ";
# $pl = 1;
#}
# gather all other parameters after the ?-mark
if(preg_match('#\?([^\"]+)\"#', $videopattern, $matchesParams)) {
# if params aren't provided, plug in default params so that user knows what's available
$paramsArray = explode("&",$matchesParams[1]); # separate params
foreach($paramsArray as $arr) {
# separate params into key=>val pairs, to be used in comparison with DefaultParamArray
list($arrKey,$arrVal) = explode("=",$arr);
$paramsArrayWithKeys[$arrKey] = $arrVal;
}
} else {
$paramsArrayWithKeys = array();
}
# gather width & height
preg_match('#width=["\'](\d+)["\']\s+height=["\'](\d+)["\']#', $videopattern, $matchesWH);
#$params = 'width='.$matchesWH[1].' height='.$matchesWH[2];
$paramsArrayWithKeys['width'] = $matchesWH[1];
$paramsArrayWithKeys['height'] = $matchesWH[2];
# add in elements from the DefaultParamArray not already provided
$paramsArray = array_merge($YouTubeDefaultParams,$paramsArrayWithKeys);
# get rid of plwidth & plheight if not a playlist
if(!$pl) $paramsArray = array_diff_key($paramsArray, array('plwidth'=>'','plheight'=>''));
else {
# if it is a playlist, then set plwidth and plheight to width and height
$paramsArray['plwidth'] = $paramsArrayWithKeys['width'];
$paramsArray['plheight'] = $paramsArrayWithKeys['height'];
# remove regular width and height params, leave behind plwidth and plheight
$paramsArray = array_diff_key($paramsArray, array('width'=>'','height'=>''));
}
# convert back to string
foreach($paramsArray as $key => $val) {
$params .= " $key=$val";
}
#echo $params; break;
# output
$out = "(:youtube $id$params:)"; #echo $out; break;
return $out;
}
# *** YOUTUBE-EMBED-CODE-ROE: OLD NON-IFRAME EMBED VERSION ***
$ROEPatterns['!!i'] = "YouTubeROE_NONIFRAME(PSS(\$m[0]))";
function YouTubeROE_NONIFRAME($videocode) {
global $YouTubeDefaultParams;
# get videoID
preg_match('#/[vp]/([^\?]+)\?#', $videocode, $matchesID);
$id = $matchesID[1];
$params = '';
# check for playlist
if(strpos($videocode, '/p/')) {
$params = " playlist=1 ";
$pl = 1;
}
# gather width & height
preg_match('#