1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 19:30:25 +02:00

More media-picker work.

This commit is contained in:
Cameron
2018-07-22 14:45:26 -07:00
parent 45de0a49f3
commit 5a4847871d
4 changed files with 131 additions and 12 deletions

View File

@@ -1104,6 +1104,14 @@ class media_admin_ui extends e_admin_ui
echo $this->audioTab($parm);
exit;
}
if($this->getAction() === 'image2')
{
$parm = array('search' => $tp->filter($_GET['search']));
$cat = $tp->filter($_GET['for']);
echo $this->imageTab2($cat,$parm);
exit;
}
if($this->getAction() == 'nav' )
{
@@ -1594,13 +1602,90 @@ class media_admin_ui extends e_admin_ui
}
else
{
$text = e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid'), $options); // eg. news, news-thumbnail
if(deftrue('e_DEBUG_MEDIAPICKER'))
{
$text = $this->imageTab2($this->getQuery('for'),$options); // todo test with tinymce etc.
}
else
{
$text = e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid'), $options); // eg. news, news-thumbnail
}
}
return $text;
}
private function imageTab2($category,$option=array())
{
$tp = e107::getParser();
$parms = array(
'width' => 340,
'height' => 220,
'type' =>'image',
'category' => $category,
'tagid' => $this->getQuery('tagid'),
'action' =>'image2', // Used by AJAX to identify correct function.
'perPage' => 8,
'gridClass' => 'col-sm-3 media-carousel-item-image',
'bbcode' => 'image',
'close' => 'true'
);
$items = array();
$frm = !empty($option['from']) ? $option['from'] : 0;
$limit = !empty($option['limit']) ? $option['limit'] : 200;
// $newfrm = $frm + $limit;
// $bbcode = varset($option['bbcode']) ? $option['bbcode'] : null;
// $navMode = varset($option['nav']) ? TRUE : FALSE;
$search = !empty($option['search']) ? $option['search'] : null;
$cat = ($category) ? $category."+" : ""; // the '+' loads category '_common' as well as the chosen category.
$images = e107::getMedia()->getImages($cat,$frm,$limit,$search);
foreach($images as $val)
{
$items[] = array(
// 'previewHtml' => $tp->toImage($val['media_url'], array('w'=>210, 'h'=>140)),
'previewUrl' => $tp->thumbUrl($val['media_url'], array('w'=>210, 'h'=>140)),
'saveValue' => $val['media_url'],
'thumbUrl' => $tp->thumbUrl($val['media_url'], array('w'=>340, 'h'=>220)),
'title' => $val['media_name'],
'slideCaption' => '',
'slideCategory' => 'bootstrap',
'mime' => $val['media_type']
);
}
if(!empty($option['search']))
{
$filtered = array();
if(!empty($items))
{
foreach($items as $v)
{
if(strpos($v['title'], $option['search'])!==false)
{
$filtered[] = $v;
}
}
}
$items = $filtered;
}
return e107::getMedia()->browserCarousel($items, $parms);
}
function audioTab($parm=array())
private function audioTab($parm=array())
{
$tp = e107::getParser();
@@ -1682,7 +1767,7 @@ class media_admin_ui extends e_admin_ui
foreach($videos as $val)
{
$items[] = array(
'previewHtml' => $tp->toVideo($val['media_url'], array('w'=>210, 'h'=>140)), // e_IMAGE_ABS."generic/playlist_120.png", //todo place entire video tag into imagepicker when saving.
'previewHtml' => $tp->toVideo($val['media_url'], array('w'=>210, 'h'=>140)), // e_IMAGE_ABS."generic/playlist_120.png",
'saveValue' => $val['media_url'],
'thumbUrl' => $val['media_url'],
'title' => $val['media_name'],

View File

@@ -495,7 +495,7 @@ class e_media
if($search)
{
$searchinc[] = "media_name LIKE '%".$search."%' ";
$searchinc[] = "media_name LIKE '%".$search."%' ";
$searchinc[] = "media_description LIKE '%".$search."%' ";
$searchinc[] = "media_caption LIKE '%".$search."%' ";
$searchinc[] = "media_tags LIKE '%".$search."%' ";
@@ -537,7 +537,7 @@ class e_media
$query .= " LIMIT ".$from." ,".$amount;
}
// e107::getDebug()->log($query);
e107::getDebug()->log($query);
e107::getDb()->gen($query);
while($row = e107::getDb()->fetch())
@@ -1366,9 +1366,28 @@ class e_media
case "image":
$text .= $linkTag;
$text .= "<span>";
$text .= '<img class="img-responsive img-fluid" alt="" src="'.$data['thumbUrl'].'" style="width:100%;display:inline-block" />';
$text .= "</span>";
$text .= "\n</a>\n\n";
$text .= "\n<div><small class='media-carousel-item-caption'>".$data['title']."</small></div>";
$text .= "<div class='row' style='margin-top:5px'>
<div class='col-md-8'><small class='media-carousel-item-caption'>";
$text .= $this->browserCarouselItemSelector($data);
$text .= "\n".$data['title'];
$text .= "\n</a></small></div>";
$data['style'] = 'float:right';
$text .= "<div class='col-md-4 text-right'>".
$this->browserCarouselItemSelector($data).
"<button class='btn btn-xs btn-primary' style='margin-top:7px'>Select</button></a></div>
</div>";
// $text .= "\n<div><small class='media-carousel-item-caption'>".$data['title']."</small></div>";
break;
@@ -1489,8 +1508,8 @@ class e_media
// $text .= print_a($_GET,true);
$data_src = $this->mediaSelectNav($category,$parm['tagid'], $parm);
$carouselID = 'myCarousel-'.$parm['action'];
$data_src = $this->mediaSelectNav($parm['category'], $parm['tagid'], $parm);
$carouselID = 'media-carousel-'.$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'>";
@@ -1504,8 +1523,18 @@ class e_media
$text .= "<input type='text' class='form-control 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">&lsaquo;</a><a class="btn btn-primary" href="#'.$carouselID.'" data-slide="next">&rsaquo;</a>';
$text .= "</span>";
// $text .= '<a class="btn btn-primary" href="#'.$carouselID.'" data-slide="prev">&lsaquo;</a><a class="btn btn-primary" href="#'.$carouselID.'" data-slide="next">&rsaquo;</a>';
$text .= '&nbsp;<div class="btn-group" >
<a id="'.$carouselID.'-prev" class="btn btn-primary btn-secondary" href="#'.$carouselID.'" data-slide="prev"><i class="fa fa-backward"></i></a>
<a id="'.$carouselID.'-index" class="btn btn-primary btn-secondary">1</a>
<a id="'.$carouselID.'-next" class="btn btn-primary btn-secondary" href="#'.$carouselID.'" data-slide="next"><i class="fa fa-forward"></i></a>
</div>';
$text .= "</span>";
$text .= "</div>";
$text .= "<div id='media-browser-container-".$parm['action']."' class='form-inline clearfix row-fluid'>";
}
@@ -1517,7 +1546,7 @@ class e_media
$text .= '<div id="'.$carouselID.'" class="carousel slide" data-interval="false">';
$text .= '{INDICATORS}';
// $text .= '{INDICATORS}';
$text .= '<div style="margin-top:10px" class="row admingrid carousel-inner">';

View File

@@ -266,6 +266,9 @@ td.right, th.right { text-align:right }
/* media picker */
.media-carousel-item-image .well { height: 200px; overflow:hidden }
.media-carousel-item-image span { display:block; height:150px; }
.media-carousel-item-image img { width:100%; max-height: 100%; }
.media-carousel-item-video .video-responsive { padding-top: 0; }
.media-carousel-item-video video { max-width: 100%; max-height: 200px; }

View File

@@ -786,7 +786,9 @@ $(document).ready(function()
$('.carousel').on('slid.bs.carousel', function () {
var currentIndex = $(this).find('.active').index();
var text = (currentIndex + 1);
$('#admin-ui-carousel-index').text(text);
var id = $(this).attr('id') + '-index'; // admin-ui-carousel-index etc.
$('#'+id).text(text);
});