Skip to content

Commit

Permalink
Media-Manager Issue #3200 Work in Progress. Local video-file browser.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Jul 17, 2018
1 parent bac9652 commit bb7f871
Show file tree
Hide file tree
Showing 3 changed files with 197 additions and 40 deletions.
135 changes: 115 additions & 20 deletions e107_admin/image.php
Original file line number Diff line number Diff line change
Expand Up @@ -1077,19 +1077,33 @@ function init()



if($this->getAction() == 'youtube')
if($this->getAction() === 'youtube')
{
$parm = array('search' => $tp->filter($_GET['search']));
echo $this->videoTab($parm);
echo $this->youtubeTab($parm);
exit;
}

if($this->getAction() == 'glyph')
if($this->getAction() === 'glyph')
{
$parm = array('search' => $tp->filter($_GET['search']));
echo $this->glyphTab($parm);
exit;
}

if($this->getAction() === 'video')
{
$parm = array('search' => $tp->filter($_GET['search']));
echo $this->videoTab($parm);
exit;
}

if($this->getAction() === 'audio')
{
$parm = array('search' => $tp->filter($_GET['search']));
echo $this->audioTab($parm);
exit;
}

if($this->getAction() == 'nav' )
{
Expand Down Expand Up @@ -1315,7 +1329,7 @@ function mediaSelectUpload($type='image')
if($type === 'video')
{
$tabs = array(
'youtube' => array('caption'=>'Youtube', 'text' => $this->videoTab())
'youtube' => array('caption'=>'Youtube', 'text' => $this->youtubeTab())
);

return $frm->tabs($tabs, array('class'=>'media-manager'));
Expand All @@ -1324,7 +1338,7 @@ function mediaSelectUpload($type='image')



$videoActive = 'inactive';
$youtubeActive = 'inactive';

$options = array();
$options['bbcode'] = ($this->getQuery('bbcode')=='img') ? 'img' : FALSE;
Expand All @@ -1344,7 +1358,7 @@ function mediaSelectUpload($type='image')
}
else
{
$videoActive = 'active';
$youtubeActive = 'active';
}


Expand All @@ -1367,7 +1381,12 @@ function mediaSelectUpload($type='image')

if($this->getQuery('video') == 1 || $this->getQuery('bbcode') == 'video')
{
$text .= "<li class='{$videoActive}'><a data-toggle='tab' href='#core-media-video'>Youtube</a></li>\n";
$text .= "<li class='{$youtubeActive}'><a data-toggle='tab' href='#core-media-youtube'>Youtube</a></li>\n";

if(deftrue('e_DEBUG_VIDEO'))
{
$text .= "<li class='{$videoActive}'><a data-toggle='tab' href='#core-media-video'>Videos</a></li>\n";

This comment has been minimized.

Copy link
@yesszus

yesszus Jul 17, 2018

Contributor

@CaMer0n Use this lan code: IMALAN_163 // video.

}
}


Expand Down Expand Up @@ -1496,15 +1515,33 @@ function mediaSelectUpload($type='image')

if($this->getQuery('video') || $this->getQuery('bbcode') == 'video')
{
$text .= "<div class='tab-pane clearfix {$videoActive}' id='core-media-video' >";
$text .= "<div class='tab-pane clearfix {$youtubeActive}' id='core-media-youtube' >";
// $text .= "<div class='row-fluid'>";
$text .= $this->videoTab();
$text .= "</div>";
// $text .= "</div>";
$text .= $this->youtubeTab();
$text .= "</div>";

if(deftrue('e_DEBUG_VIDEO'))
{
$text .= "<div class='tab-pane clearfix {$videoActive}' id='core-media-video' >";
// $text .= "<div class='row-fluid'>";
$text .= $this->videoTab();
$text .= "</div>";
}

}



// todo
if($this->getQuery('audio') || $this->getQuery('bbcode') == 'audio')
{
if(deftrue('e_DEBUG_AUDIO'))
{
$text .= "<div class='tab-pane clearfix {$videoActive}' id='core-media-audio' >";
// $text .= "<div class='row-fluid'>";
$text .= $this->audioTab();
$text .= "</div>";
}

}



Expand Down Expand Up @@ -1566,13 +1603,74 @@ function imageTab($type,$options)
return $text;
}


function audioTab($parm=array())
{
//todo (@see videoTab)

}


function videoTab($parm=array())
{

$tp = e107::getParser();

$parms = array(
'width' => 340,
'height' => 220,
'type' =>'video',
'tagid' => $this->getQuery('tagid'),
'action' =>'video', // Used by AJAX to identify correct function.
'perPage' => 12,
'gridClass' => 'media-carousel-item-video pull-left',
'bbcode' => 'video',
'close' => 'true'

);

$items = array();

$videos = e107::getMedia()->getVideos();

foreach($videos as $val)
{
$items[] = array(
'previewUrl' => e_IMAGE_ABS."generic/playlist_120.png", //todo place entire video tag into imagepicker when saving.
'saveValue' => $val['media_url'],
'thumbUrl' => $tp->replaceConstants($val['media_url']),
'title' => $val['media_name'],
'slideCaption' => '',
'slideCategory' => 'bootstrap',
'mime' => $val['media_type']
);

}


if(!empty($parm['search']))
{
$filtered = array();
if(!empty($items))
{
foreach($items as $v)
{
if(strpos($v['title'], $parm['search'])!==false)
{
$filtered[] = $v;
}
}
}
$items = $filtered;
}

return e107::getMedia()->browserCarousel($items, $parms);
}





function glyphTab($parm='')
function glyphTab($parm=array())
{

$parms = array(
Expand Down Expand Up @@ -1663,9 +1761,6 @@ function glyphTab($parm='')
}






if(!empty($parm['search']))
{
Expand Down Expand Up @@ -1726,7 +1821,7 @@ function getYouTubeCode($url)
* @return mixed|string
* @see https://www.googleapis.com/youtube/v3/search
*/
function videoTab($parm='')
function youtubeTab($parm='')
{
$apiKey = e107::pref('core','youtube_apikey');

Expand Down Expand Up @@ -2691,7 +2786,7 @@ function batchImportForm()

$default = $this->getFileXml($f['fname']);
$f = $fl->cleanFileName($f,true);

$c = md5($f['path'].$f['fname']);

if($f['error'])
Expand Down
23 changes: 22 additions & 1 deletion e107_handlers/file_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,28 @@ function get_file_info($path_to_file, $imgcheck = true, $auto_fix_ext = true)

if(empty($finfo['mime'])) // last resort.
{
$finfo['mime'] = 'application/'.$finfo['pathinfo']['extension'];
switch($finfo['pathinfo']['extension'])
{
case "mp3":
$finfo['mime'] = 'audio/mpeg';
break;

case "ogg":
$finfo['mime'] = 'audio/ogg';
break;

case "mp4":
$finfo['mime'] = 'video/mp4';
break;

case "3gp":
$finfo['mime'] = 'video/3gpp';
break;

default:
$finfo['mime'] = 'application/'.$finfo['pathinfo']['extension'];
}

}


Expand Down
79 changes: 60 additions & 19 deletions e107_handlers/media_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ public function getFiles($from=0, $amount = null, $search = null)
}


public function getVideos($from=0, $amount = null, $search = null)
{
return $this->getImages('_common_video', $from, $amount, $search);
}

/**
* Return an array of Images in a particular category
* @param string $cat : category name. use + to include _common eg. 'news+'
Expand Down Expand Up @@ -1265,28 +1270,65 @@ function browserCarouselItem($row = array())
$close = (E107_DEBUG_LEVEL > 0) ? "" : " data-close='true' "; //
$select = (E107_DEBUG_LEVEL > 0) ? '' : " e-dialog-save e-dialog-close";



$text = "\n\n<!-- Start Item -->\n<div class='media-carousel ".$data['gridClass']."'>
$text = "\n\n<!-- Start Item -->
<div class='well clearfix'>
<a data-toggle='context' class='e-media-select e-tip".$select."' ".$close." data-id='".$data['id']."' data-width='".$data['width']."' data-height='".$data['height']."' data-src='".$data['previewUrl']."' data-type='".$data['type']."' data-bbcode='".$data['bbcode']."' data-target='".$data['tagid']."' data-path='".$data['saveValue']."' data-preview='".$data['previewUrl']."' title=\"".$data['title']."\" style='float:left' href='#' >";
<div class='media-carousel ".$data['gridClass']."'>
if($data['type'] == 'image')
{
$text .= '<img class="img-responsive img-fluid" alt="" src="'.$data['thumbUrl'].'" style="width:100%;display:inline-block" />';
}
elseif($data['type'] == 'glyph')
{
$text .= "\n<span style='margin:7px;display:inline-block;color: inherit'>".$tp->toGlyph($data['thumbUrl'],false)."</span>";
}
$text .= "\n</a>\n\n";

if($data['type'] == 'image')
<div class='well clearfix'>\n";

$linkTag = "<a data-toggle='context' class='e-media-select e-tip".$select."' ".$close." data-id='".$data['id']."' data-width='".$data['width']."' data-height='".$data['height']."' data-src='".$data['previewUrl']."' data-type='".$data['type']."' data-bbcode='".$data['bbcode']."' data-target='".$data['tagid']."' data-path='".$data['saveValue']."' data-preview='".$data['previewUrl']."' title=\"".$data['title']."\" style='float:left' href='#' >";

switch($data['type'])
{
$text .= "\n<div><small class='media-carousel-item-caption'>".$data['title']."</small></div>";
case "video":
$mime = vartrue($data['mime'],"video/mp4");

$text .= '<video width="'.$data['width'].'" height="'.$data['height'].'" controls >
<source src="'.$data['thumbUrl'].'" type="'.$mime.'">
Your browser does not support the video tag.
</video>
<div class="clearfix" style="text-align:center">';

$text .= $linkTag;
$text .= "\n".$data['title'];
$text .= "\n</a></div>\n\n";
break;

case "audio":
$mime = vartrue($data['mime'],"audio/mpeg");
$text .= '<audio controls>
<source src="'.$data['thumbUrl'].'" type="'.$mime.'">
Your browser does not support the audio tag.
</audio>
<div class="clearfix" style="text-align:center">';

$text .= $linkTag;
$text .= "\n".$data['title'];
$text .= "\n</a></div>\n\n";

break;


case "image":
$text .= $linkTag;
$text .= '<img class="img-responsive img-fluid" alt="" src="'.$data['thumbUrl'].'" style="width:100%;display:inline-block" />';
$text .= "\n</a>\n\n";
$text .= "\n<div><small class='media-carousel-item-caption'>".$data['title']."</small></div>";
break;


case "glyph":
$text .= $linkTag;
$text .= "\n<span style='margin:7px;display:inline-block;color: inherit'>".$tp->toGlyph($data['thumbUrl'],false)."</span>";
$text .= "\n</a>\n\n";
break;


default:
// code to be executed if n is different from all labels;
}


$text .= "</div>
Expand Down Expand Up @@ -1453,7 +1495,6 @@ function browserCarousel($data,$parm=null)
}
}


$val['width'] = $parm['width'];
$val['height'] = $parm['height'];
$val['id'] = $parm['id'];
Expand Down

0 comments on commit bb7f871

Please sign in to comment.