mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 21:57:51 +02:00
Youtube browser now supports searching by video and playlist ids. eg. video:_j0b9syAuIk
This commit is contained in:
@@ -744,6 +744,7 @@ 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')),
|
'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
|
// 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_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_showinfo' => array('title'=> "Show Video Info", '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);
|
return e107::getMedia()->browserCarousel($items, $parms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getYouTubeCode($url)
|
||||||
|
{
|
||||||
|
list($url,$qry) = explode("?",$url);
|
||||||
|
parse_str($qry,$opt);
|
||||||
|
|
||||||
|
return $opt['v'];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function videoTab($parm='')
|
function videoTab($parm='')
|
||||||
@@ -1382,19 +1390,69 @@ class media_admin_ui extends e_admin_ui
|
|||||||
|
|
||||||
// @see https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters
|
// @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
|
else
|
||||||
{
|
{
|
||||||
$feed = "https://gdata.youtube.com/feeds/api/users/e107inc/uploads";
|
|
||||||
|
$defaultAccount = e107::pref('core','youtube_default_account','e107inc');
|
||||||
|
$feed = "https://gdata.youtube.com/feeds/api/users/".$defaultAccount."/uploads";
|
||||||
|
$extension = 'youtube';
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = e107::getXml()->loadXMLfile($feed,true);
|
|
||||||
|
|
||||||
|
|
||||||
|
if(!empty($feed) && empty($data))
|
||||||
|
{
|
||||||
|
$data = e107::getXml()->loadXMLfile($feed,true);
|
||||||
|
}
|
||||||
// $text .= "<h2>".$data['title']."</h2>";
|
// $text .= "<h2>".$data['title']."</h2>";
|
||||||
// $text .= print_a($data,true);
|
// return print_a($data,true);
|
||||||
|
|
||||||
$items = array();
|
$items = array();
|
||||||
|
|
||||||
@@ -1404,14 +1462,17 @@ class media_admin_ui extends e_admin_ui
|
|||||||
$thumbnail = "https://i1.ytimg.com/vi/".$id."/0.jpg";
|
$thumbnail = "https://i1.ytimg.com/vi/".$id."/0.jpg";
|
||||||
|
|
||||||
$items[] = array(
|
$items[] = array(
|
||||||
'previewUrl' => $thumbnail,
|
'previewUrl' => ($value['thumb']) ? $value['thumb'] : $thumbnail,
|
||||||
'saveValue' => $id.".youtube",
|
'saveValue' => $id.".".$extension, // youtube",
|
||||||
'thumbUrl' => $thumbnail,
|
'thumbUrl' => ($value['thumb']) ? $value['thumb'] : $thumbnail,
|
||||||
'title' => $value['title']
|
'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);
|
$text = e107::getMedia()->browserCarousel($items, $parms);
|
||||||
|
|
||||||
|
@@ -2405,7 +2405,7 @@ class admin_newspost
|
|||||||
".$frm->help(LAN_NEWS_23)."</td>
|
".$frm->help(LAN_NEWS_23)."</td>
|
||||||
<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'];
|
$_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;
|
return false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -2972,7 +2972,7 @@ class e_parser
|
|||||||
{
|
{
|
||||||
$ext = pathinfo($file,PATHINFO_EXTENSION);
|
$ext = pathinfo($file,PATHINFO_EXTENSION);
|
||||||
|
|
||||||
return ($ext == 'youtube') ? true : false;
|
return ($ext == 'youtube' || $ext == 'youtubepl') ? true : false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3042,6 +3042,26 @@ class e_parser
|
|||||||
return '<div class="video-responsive '.vartrue($parm['class']).'">'.$video.'</div>';
|
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
|
if($type == 'mp4') //TODO FIXME
|
||||||
{
|
{
|
||||||
return '
|
return '
|
||||||
|
@@ -699,6 +699,7 @@ class e_form
|
|||||||
parse_str($sc_parameters, $sc_parameters);
|
parse_str($sc_parameters, $sc_parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// print_a($sc_parameters);
|
// print_a($sc_parameters);
|
||||||
|
|
||||||
if(empty($sc_parameters['media']))
|
if(empty($sc_parameters['media']))
|
||||||
|
@@ -1157,6 +1157,59 @@ class e_media
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
function browserCarousel($data,$parm=null)
|
||||||
{
|
{
|
||||||
/* Fix for Bootstrap2 margin-left issue when wrapping */
|
/* Fix for Bootstrap2 margin-left issue when wrapping */
|
||||||
@@ -1176,7 +1229,7 @@ class e_media
|
|||||||
|
|
||||||
$data_src = $this->mediaSelectNav($category,$parm['tagid'], $parm);
|
$data_src = $this->mediaSelectNav($category,$parm['tagid'], $parm);
|
||||||
$carouselID = 'myCarousel-'.$parm['action'];
|
$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'>";
|
//$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);
|
$searchPlaceholder = varset($parm['searchPlaceholder'], LAN_SEARCH);
|
||||||
|
|
||||||
$text = '<div class="btn-group"><span class="input-append">';
|
$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 .= '<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 .= '<a class="btn btn-primary" href="#'.$carouselID.'" data-slide="prev">‹</a><a class="btn btn-primary" href="#'.$carouselID.'" data-slide="next">›</a>';
|
||||||
$text .= "</span>";
|
$text .= "</span>";
|
||||||
|
@@ -30,10 +30,7 @@ class sitelinks
|
|||||||
{
|
{
|
||||||
while ($row = $sql->fetch())
|
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.'){
|
// if (substr($row['link_name'], 0, 8) == 'submenu.'){
|
||||||
// $tmp=explode('.', $row['link_name'], 3);
|
// $tmp=explode('.', $row['link_name'], 3);
|
||||||
@@ -259,6 +256,7 @@ class sitelinks
|
|||||||
if(vartrue($linkInfo['link_sefurl']))
|
if(vartrue($linkInfo['link_sefurl']))
|
||||||
{
|
{
|
||||||
$linkInfo['link_url'] = $linkInfo['link_sefurl'];
|
$linkInfo['link_url'] = $linkInfo['link_sefurl'];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If submenu: Fix Name, Add Indentation.
|
// If submenu: Fix Name, Add Indentation.
|
||||||
|
Reference in New Issue
Block a user