mirror of
https://github.com/e107inc/e107.git
synced 2025-08-01 20:30:39 +02:00
Youtube browser now supports searching by video and playlist ids. eg. video:_j0b9syAuIk
This commit is contained in:
@@ -744,7 +744,8 @@ class media_admin_ui extends e_admin_ui
|
||||
'watermark_opacity' => array('title'=> 'Watermark Opacity', 'tab'=>1, 'type' => 'number', 'data' => 'int', 'help'=>'Enter a number between 1 and 100'), // 'validate' => 'regex', 'rule' => '#^[\d]+$#i', 'help' => 'allowed characters are a-zA-Z and underscore')),
|
||||
|
||||
// https://developers.google.com/youtube/player_parameters
|
||||
|
||||
'youtube_default_account' => array('title'=> "Default YouTube account", 'tab'=>2, 'type' => 'text', 'data'=>'str', 'help'=>'Used by the Media-Manager Youtube browser. Enter account name. eg. e107inc'),
|
||||
|
||||
'youtube_rel' => array('title'=> "Show Related Videos", 'tab'=>2, 'type' => 'boolean', 'data'=>'int', 'help'=>''),
|
||||
'youtube_showinfo' => array('title'=> "Show Video Info", 'tab'=>2, 'type' => 'boolean', 'data'=>'int', 'help'=>''),
|
||||
'youtube_cc_load_policy' => array('title'=> "Show Closed-Captions by default", 'tab'=>2, 'type' => 'boolean', 'data'=>'int', 'help'=>''),
|
||||
@@ -1372,7 +1373,14 @@ class media_admin_ui extends e_admin_ui
|
||||
return e107::getMedia()->browserCarousel($items, $parms);
|
||||
}
|
||||
|
||||
|
||||
function getYouTubeCode($url)
|
||||
{
|
||||
list($url,$qry) = explode("?",$url);
|
||||
parse_str($qry,$opt);
|
||||
|
||||
return $opt['v'];
|
||||
|
||||
}
|
||||
|
||||
|
||||
function videoTab($parm='')
|
||||
@@ -1381,20 +1389,70 @@ class media_admin_ui extends e_admin_ui
|
||||
// $feed = "https://gdata.youtube.com/feeds/base/users/e107inc/uploads";
|
||||
|
||||
// @see https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters
|
||||
|
||||
if($search = vartrue($this->getQuery('search')))
|
||||
|
||||
$searchQry = $this->getQuery('search');
|
||||
|
||||
|
||||
if(!empty($searchQry))
|
||||
{
|
||||
$feed = "http://gdata.youtube.com/feeds/api/videos?orderby=relevance&vq=".urlencode($search)."&max-results=50"; // maximum is 50.
|
||||
if(substr($searchQry,0,6) == 'video:') // YouTube video code?
|
||||
{
|
||||
// return "video: ".$searchQry;
|
||||
$searchQry = trim(substr($searchQry,6));
|
||||
$data = array();
|
||||
$data['entry'][0]['id'] = $searchQry;
|
||||
$data['entry'][0]['title'] = "Specified Video";
|
||||
$extension = 'youtube';
|
||||
// return print_a($parm,true);
|
||||
}
|
||||
elseif(substr($searchQry,0,9) == 'playlist:') // playlist
|
||||
{
|
||||
$searchQry = trim(substr($searchQry,9));
|
||||
$feed = "http://gdata.youtube.com/feeds/api/playlists/".urlencode($searchQry);
|
||||
$plData = e107::getXml()->loadXMLfile($feed,true);
|
||||
unset($feed);
|
||||
// return print_a($plData,true);
|
||||
|
||||
$code = $this->getYouTubeCode( $plData['entry'][0]['link'][0]['@attributes']['href']);
|
||||
|
||||
|
||||
// return print_a($searchQry,true);
|
||||
|
||||
if(!empty($plData))
|
||||
{
|
||||
$data = array();
|
||||
$data['entry'][0]['id'] = $searchQry;
|
||||
$data['entry'][0]['title'] = "Playlist: ". $plData['title'];
|
||||
$data['entry'][0]['thumb'] = "http://i1.ytimg.com/vi/".$code."/maxresdefault.jpg";
|
||||
$extension = 'youtubepl';
|
||||
|
||||
e107::getMedia()->saveThumb("http://i1.ytimg.com/vi/".$code."/maxresdefault.jpg", $searchQry);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$feed = "http://gdata.youtube.com/feeds/api/videos?orderby=relevance&vq=".urlencode($searchQry)."&max-results=50"; // maximum is 50.
|
||||
$extension = 'youtube';
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$feed = "https://gdata.youtube.com/feeds/api/users/e107inc/uploads";
|
||||
}
|
||||
|
||||
$data = e107::getXml()->loadXMLfile($feed,true);
|
||||
|
||||
|
||||
$defaultAccount = e107::pref('core','youtube_default_account','e107inc');
|
||||
$feed = "https://gdata.youtube.com/feeds/api/users/".$defaultAccount."/uploads";
|
||||
$extension = 'youtube';
|
||||
}
|
||||
|
||||
|
||||
|
||||
if(!empty($feed) && empty($data))
|
||||
{
|
||||
$data = e107::getXml()->loadXMLfile($feed,true);
|
||||
}
|
||||
// $text .= "<h2>".$data['title']."</h2>";
|
||||
// $text .= print_a($data,true);
|
||||
// return print_a($data,true);
|
||||
|
||||
$items = array();
|
||||
|
||||
@@ -1404,14 +1462,17 @@ class media_admin_ui extends e_admin_ui
|
||||
$thumbnail = "https://i1.ytimg.com/vi/".$id."/0.jpg";
|
||||
|
||||
$items[] = array(
|
||||
'previewUrl' => $thumbnail,
|
||||
'saveValue' => $id.".youtube",
|
||||
'thumbUrl' => $thumbnail,
|
||||
'previewUrl' => ($value['thumb']) ? $value['thumb'] : $thumbnail,
|
||||
'saveValue' => $id.".".$extension, // youtube",
|
||||
'thumbUrl' => ($value['thumb']) ? $value['thumb'] : $thumbnail,
|
||||
'title' => $value['title']
|
||||
);
|
||||
}
|
||||
|
||||
$parms = array('width' => 200, 'height'=>113, 'type'=>'image', 'bbcode'=>'video', 'tagid'=> $this->getQuery('tagid'), 'action'=>'youtube','searchPlaceholder'=>'Search Youtube');
|
||||
|
||||
// return print_a($items,true);
|
||||
// return print_a($data,true);
|
||||
|
||||
$parms = array('width' => 200, 'height'=>113, 'type'=>'image', 'bbcode'=>'video', 'tagid'=> $this->getQuery('tagid'), 'action'=>'youtube','searchPlaceholder'=>'Search Youtube. Use video: or playlist: prefixes if you know the code.' );
|
||||
|
||||
$text = e107::getMedia()->browserCarousel($items, $parms);
|
||||
|
||||
|
@@ -2405,7 +2405,7 @@ class admin_newspost
|
||||
".$frm->help(LAN_NEWS_23)."</td>
|
||||
<td>
|
||||
";
|
||||
if(vartrue($_POST['news_thumbnail']) && (strpos($_POST['news_thumbnail'], ",") == false) && $_POST['news_thumbnail'][0] != "{" && substr($_POST['news_thumbnail'],-8) !== '.youtube')//BC compat
|
||||
if(vartrue($_POST['news_thumbnail']) && (strpos($_POST['news_thumbnail'], ",") == false) && $_POST['news_thumbnail'][0] != "{" && $tp->isVideo($_POST['news_thumbnail']) === false )//BC compat
|
||||
{
|
||||
$_POST['news_thumbnail'] = "{e_IMAGE}newspost_images/".$_POST['news_thumbnail'];
|
||||
}
|
||||
|
@@ -2647,8 +2647,10 @@ class e107
|
||||
|
||||
}
|
||||
|
||||
e107::getMessage()->addDebug("e_url.php in <b>".e_PLUGIN.$plugin."</b> is missing the key: <b>".$key."</b>. Or, you may need to <a href='".e_ADMIN."db.php?mode=plugin_scan'>scan your plugin directories</a> to register e_url.php");
|
||||
|
||||
if(!empty($plugin))
|
||||
{
|
||||
e107::getMessage()->addDebug("e_url.php in <b>".e_PLUGIN.$plugin."</b> is missing the key: <b>".$key."</b>. Or, you may need to <a href='".e_ADMIN."db.php?mode=plugin_scan'>scan your plugin directories</a> to register e_url.php");
|
||||
}
|
||||
return false;
|
||||
|
||||
/*
|
||||
|
@@ -2972,7 +2972,7 @@ class e_parser
|
||||
{
|
||||
$ext = pathinfo($file,PATHINFO_EXTENSION);
|
||||
|
||||
return ($ext == 'youtube') ? true : false;
|
||||
return ($ext == 'youtube' || $ext == 'youtubepl') ? true : false;
|
||||
|
||||
}
|
||||
|
||||
@@ -3041,6 +3041,26 @@ class e_parser
|
||||
|
||||
return '<div class="video-responsive '.vartrue($parm['class']).'">'.$video.'</div>';
|
||||
}
|
||||
|
||||
|
||||
if($type =='youtubepl')
|
||||
{
|
||||
|
||||
if($thumb == 'tag')
|
||||
{
|
||||
$thumbSrc = e107::getMedia()->getThumb($id);
|
||||
return "<img class='img-responsive' src='".$thumbSrc."' alt='Youtube Video Playlist' style='width:".vartrue($parm['w'],'80')."px'/>";
|
||||
|
||||
}
|
||||
|
||||
if($thumb == 'src')
|
||||
{
|
||||
return e107::getMedia()->getThumb($id);
|
||||
}
|
||||
|
||||
$video = '<iframe width="560" height="315" src="https://www.youtube.com/embed/videoseries?list='.$id.'" frameborder="0" allowfullscreen></iframe>';
|
||||
return '<div class="video-responsive '.vartrue($parm['class']).'">'.$video.'</div>';
|
||||
}
|
||||
|
||||
if($type == 'mp4') //TODO FIXME
|
||||
{
|
||||
|
@@ -698,7 +698,8 @@ class e_form
|
||||
if(strpos($sc_parameters, '=') === false) $sc_parameters = 'media='.$sc_parameters;
|
||||
parse_str($sc_parameters, $sc_parameters);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// print_a($sc_parameters);
|
||||
|
||||
if(empty($sc_parameters['media']))
|
||||
|
@@ -1155,7 +1155,60 @@ class e_media
|
||||
return $indicators;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Retriveve a Media-Manager thumbnail which was saved from a remote location. .
|
||||
* @param $id
|
||||
* @return bool|string
|
||||
*/
|
||||
function getThumb($id)
|
||||
{
|
||||
$id = trim($id);
|
||||
$filename = 'temp/thumb-'.md5($id).".jpg";
|
||||
$filepath = e_MEDIA.$filename;
|
||||
|
||||
if(file_exists($filepath))
|
||||
{
|
||||
return e107::getParser()->createConstants($filepath);
|
||||
}
|
||||
|
||||
e107::getMessage()->addDebug("Couldn't find ".$filepath);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Save a Media-Manager thumbnail from remote location.
|
||||
* @param string $imageUrl
|
||||
* @param string $id
|
||||
* @return bool|string
|
||||
*/
|
||||
function saveThumb($imageUrl='',$id='')
|
||||
{
|
||||
|
||||
if(empty($id) || empty($imageUrl))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$filename = 'temp/thumb-'.md5($id).".jpg";
|
||||
$filepath = e_MEDIA.$filename;
|
||||
|
||||
if(!file_exists($filepath))
|
||||
{
|
||||
e107::getFile()->getRemoteFile($imageUrl, $filename,'media');
|
||||
}
|
||||
|
||||
return $filepath;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function browserCarousel($data,$parm=null)
|
||||
{
|
||||
@@ -1176,7 +1229,7 @@ class e_media
|
||||
|
||||
$data_src = $this->mediaSelectNav($category,$parm['tagid'], $parm);
|
||||
$carouselID = 'myCarousel-'.$parm['action'];
|
||||
|
||||
$searchToolttip = (empty($parm['searchTooltip'])) ? "Enter some text to filter results" : $parm['searchTooltip'];
|
||||
//$text = "<form class='form-search' action='".e_SELF."?".e_QUERY."' id='core-plugin-list-form' method='get'>";
|
||||
|
||||
|
||||
@@ -1186,7 +1239,8 @@ class e_media
|
||||
$searchPlaceholder = varset($parm['searchPlaceholder'], LAN_SEARCH);
|
||||
|
||||
$text = '<div class="btn-group"><span class="input-append">';
|
||||
$text .= "<input type='text' class='e-ajax-keyup e-tip' placeholder= '".$searchPlaceholder."...' title='Enter some text to filter results' name='search' value='' data-target='media-browser-container-".$parm['action']."' data-src='".$data_src."' />";
|
||||
$text .= "<input type='text' class='e-ajax-keyup input-xxlarge ' placeholder= '".$searchPlaceholder."...' title=\"".$searchToolttip."\" name='search' value='' data-target='media-browser-container-".$parm['action']."' data-src='".$data_src."' />";
|
||||
// $text .= "<span class='field-help'>bablalal</span>";
|
||||
// $text .= '<button class="btn btn-primary" name="'.$submitName.'" type="submit">'.LAN_GO.'</button>';
|
||||
$text .= '<a class="btn btn-primary" href="#'.$carouselID.'" data-slide="prev">‹</a><a class="btn btn-primary" href="#'.$carouselID.'" data-slide="next">›</a>';
|
||||
$text .= "</span>";
|
||||
|
@@ -30,10 +30,7 @@ class sitelinks
|
||||
{
|
||||
while ($row = $sql->fetch())
|
||||
{
|
||||
if(!empty($row['link_sefurl']) && !empty($row['link_owner']))
|
||||
{
|
||||
$this->sefList[$row['link_sefurl']] = e107::url($row['link_owner'],$row['link_url']);
|
||||
}
|
||||
|
||||
|
||||
// if (substr($row['link_name'], 0, 8) == 'submenu.'){
|
||||
// $tmp=explode('.', $row['link_name'], 3);
|
||||
@@ -259,6 +256,7 @@ class sitelinks
|
||||
if(vartrue($linkInfo['link_sefurl']))
|
||||
{
|
||||
$linkInfo['link_url'] = $linkInfo['link_sefurl'];
|
||||
|
||||
}
|
||||
|
||||
// If submenu: Fix Name, Add Indentation.
|
||||
|
Reference in New Issue
Block a user