1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 12:48:24 +01:00

MediaManager Fixes.

This commit is contained in:
Cameron 2018-08-16 19:02:02 -07:00
parent 0c900efdf2
commit 1754887672
6 changed files with 134 additions and 45 deletions

View File

@ -1303,7 +1303,7 @@ class media_admin_ui extends e_admin_ui
}
function uploadTab()
private function uploadTab()
{
if(!ADMIN){ exit; }
@ -1358,7 +1358,7 @@ class media_admin_ui extends e_admin_ui
* Replacement for mediaSelectUpload()
* @return string
*/
function mediaManagerTabs()
private function mediaManagerTabs()
{
$frm = e107::getForm();
$tp = e107::getParser();
@ -1374,9 +1374,10 @@ class media_admin_ui extends e_admin_ui
$cat = $this->getQuery('for');
$tabOptions = array(
'core-media-icon' => array('caption'=> $tp->toGlyph('fa-file-photo-o').IMALAN_72, 'method' => 'iconTab' ),
'core-media-icon' => array('caption'=> $tp->toGlyph('fa-file-photo-o').IMALAN_72, 'method' => 'iconTab' ),
'core-media-image' => array('caption'=> $tp->toGlyph('fa-file-photo-o').ADLAN_105, 'method' => 'imageTab2' ),
'core-media-video' => array('caption'=> $tp->toGlyph('fa-file-video-o').IMALAN_163, 'method' => 'videoTab'),
'core-media-file' => array('caption'=> $tp->toGlyph('fa-file').ADLAN_CL_5, 'method' => 'fileTab'),
'core-media-audio' => array('caption'=> $tp->toGlyph('fa-file-audio-o')."Audio", 'method' => 'audioTab'),
'core-media-youtube' => array('caption'=> $tp->toGlyph('fa-youtube-play')."Youtube", 'method' => 'youtubeTab' ),
'core-media-glyph' => array('caption'=> $tp->toGlyph('fa-flag')."Glyphs", 'method' => 'glyphTab'),
@ -1455,8 +1456,25 @@ class media_admin_ui extends e_admin_ui
$youtubeActive = 'inactive';
$options = array();
$options['bbcode'] = ($this->getQuery('bbcode')=='img') ? 'img' : FALSE;
switch($this->getQuery('bbcode'))
{
case "img":
$options['bbcode'] = 'img';
break;
case "video":
$options['bbcode'] = 'video';
break;
case "glyph":
$options['bbcode'] = 'glyph';
break;
default:
$options['bbcode'] = false;
}
$text = "<ul id='admin-ui-media-manager' class='nav nav-tabs'>\n";
@ -1683,9 +1701,16 @@ class media_admin_ui extends e_admin_ui
private function mediaManagerSaveButtons($options = array())
{
$text = "<div style='text-align:right;padding:5px'>
if(empty($options['bbcode']))
{
return null;
}
// hidden from view but used by javascript to re-create the button in the modal-footer.
// Tinymce will remove the 'display:none' when loaded.
$text = "<div id='media-manager-submit-buttons' class='buttons-bar' style='text-align:right;padding-right:15px;display:none;'>
<button type='submit' class='btn btn-success submit e-dialog-save' data-bbcode='".$options['bbcode']."' data-target='".$this->getQuery('tagid')."' name='save_image' value='Save it' >
<button id='etrigger-submit' type='submit' class='btn btn-success submit e-dialog-save e-dialog-close' data-bbcode='".$options['bbcode']."' data-target='".$this->getQuery('tagid')."' name='save_image' value='Save it' >
<span>".LAN_SAVE."</span>
</button>
<button type='submit' class=' btn btn-default btn-secondary submit e-dialog-close' name='cancel_image' value='Cancel' data-close='true'>
@ -1729,9 +1754,9 @@ class media_admin_ui extends e_admin_ui
}
private function iconTab($option=array())
private function iconTab($cat, $option=array())
{
$tp = e107::getParser();
$tp = e107::getParser();
$parms = array(
'width' => 64,
@ -1880,6 +1905,22 @@ class media_admin_ui extends e_admin_ui
}
private function fileTab($cat='', $parm=array())
{
$this->perPage = 0;
$this->getTreeModel()->setParam('db_query', $this->_modifyListQry(false, false, false, false, $this->listQry))->load();
$this->setFileListMode($cat);
$text = $this->getUI()->getList();
$tagid = e107::getParser()->filter($this->getQuery('tagid'));
// $text .= '<div class="media-select-file-footer"><a class="btn btn-danger e-media-select-file-none e-dialog-close" data-target="'.$tagid.'" data-target-label="'.LAN_CHOOSE_FILE.'" href="#" ><span><i class="fa fa-ban"></i> '.IMALAN_167.'</span></a></div>';
return $text;
}
private function audioTab($cat='', $parm=array())
{
@ -1952,10 +1993,13 @@ class media_admin_ui extends e_admin_ui
'perPage' => 8,
'gridClass' => 'col-xs-6 col-sm-3 admin-ui-grid media-carousel-item-video',
'bbcode' => 'video',
'close' => 'true'
);
$close = (!empty($this->getQuery('bbcode'))) ? false : true; // only close on 'select' when bbcodes are not in use.
$items = array();
$videos = e107::getMedia()->getVideos($cat);
@ -1974,7 +2018,8 @@ class media_admin_ui extends e_admin_ui
'tooltip' => basename($val['media_url'])." (".$size.")",
'slideCaption' => '',
'slideCategory' => 'bootstrap',
'mime' => $val['media_type']
'mime' => $val['media_type'],
'close' => $close
);
}
@ -2003,7 +2048,7 @@ class media_admin_ui extends e_admin_ui
function glyphTab($parm=array())
private function glyphTab($cat='', $parm=array())
{
$parms = array(
@ -2159,7 +2204,7 @@ class media_admin_ui extends e_admin_ui
* @return mixed|string
* @see https://www.googleapis.com/youtube/v3/search
*/
function youtubeTab($parm='')
private function youtubeTab($parm='')
{
$apiKey = e107::pref('core','youtube_apikey');
@ -2269,6 +2314,8 @@ class media_admin_ui extends e_admin_ui
}
$close = (!empty($this->getQuery('bbcode'))) ? false : true; // only close on 'select' when bbcodes are not in use.
if(!empty($data))
{
foreach($data['items'] as $value)
@ -2281,7 +2328,8 @@ class media_admin_ui extends e_admin_ui
'previewUrl' => $thumbnail,
'saveValue' => $id.".".$extension, // youtube",
'thumbUrl' => $thumbnail,
'title' => varset($value['snippet']['title'],'')
'title' => varset($value['snippet']['title'],''),
'close' => $close
);
if($extension == 'youtubepl') // save Image for background.
@ -2306,6 +2354,8 @@ class media_admin_ui extends e_admin_ui
);
$text = e107::getMedia()->browserCarousel($items, $parms);
if(E107_DEBUG_LEVEL > 0 && !empty($feed))

View File

@ -136,6 +136,17 @@ class bbcode_shortcodes extends e_shortcode
{
//$text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Youtube video via Media Manager : " . $this->var['template'] . "' id='{$id}' href='" . e_HTTP . e_ADMIN . "image.php?mode=main&amp;action=dialog&amp;for=" . $this->var['template'] . "&amp;tagid=" . $tag . "&amp;iframe=1&amp;bbcode=video' >";
$text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Youtube video via Media Manager : " . $this->var['template'] . "' id='{$id}' href='" . e_ADMIN_ABS . "image.php?mode=main&amp;action=dialog&amp;for=" . $this->var['template'] . "&amp;tagid=" . $tag . "&amp;iframe=1&amp;bbcode=video&amp;youtube=1' >";
$label = $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube');
$opts = array(
'bbcode' => 'video',
'class' => 'btn btn-small btn-primary bbcode bbcode_buttons e-pointer',
'title' => $this->br2nl(LANHELP_48),
'youtube' => 1
);
return e107::getForm()->mediaUrl($this->var['template'],$label, $tag, $opts);
}
else
{
@ -143,13 +154,22 @@ class bbcode_shortcodes extends e_shortcode
$event = $this->getEvent('addtext',$data,LANHELP_48);
$text = "<a {$event} class='btn btn-default' id='{$id}' data-function='insert' href='#{$this->var['tagid']}' data-bbcode='{$data}' title='".$this->br2nl(LANHELP_48)."'>";
}
$text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube'); // , LANHELP_48
$text .= "</a>";
return $text;
}
/**
* todo complete for 2.2.0
* @param $id
* @return string
*/
function bb_glyph($id)
{
if($this->var['tagid'] == 'data_') // BC work-around for duplicate IDs.
@ -162,10 +182,22 @@ class bbcode_shortcodes extends e_shortcode
}
$text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Glyphicon via Media Manager : ".$this->var['template']."' id='{$id}' href='".e_HTTP.e_ADMIN."image.php?mode=main&amp;action=dialog&amp;for=".$this->var['template']."&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=glyph' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube'); // LANHELP_48
/* $text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert a Glyphicon via Media Manager : ".$this->var['template']."' id='{$id}' href='".e_HTTP.e_ADMIN."image.php?mode=main&amp;action=dialog&amp;for=".$this->var['template']."&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=glyph' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'flag'); // LANHELP_48
$text .= "</a>";
*/
$label = $this->button(e_IMAGE_ABS."bbcode/preimage.png",'picture-o');
$opts = array(
'bbcode' => 'img',
'class' => 'btn btn-small btn-primary bbcode bbcode_buttons e-pointer',
'title' => "Insert an Image from the Media Manager : ".$this->var['template']
);
$text = e107::getForm()->mediaUrl($this->var['template'],$label, $tag, $opts);
return $text;
}
@ -188,10 +220,7 @@ class bbcode_shortcodes extends e_shortcode
function button($image, $glyph='')
{
// $text .= "<button type='button' class='btn e-pointer' title='".$title."'>";
// $text .= ($link) ? $link : "";
if(deftrue('BOOTSTRAP') && $glyph && deftrue('FONTAWESOME'))
{
$text = "<span class='fa fa-".$glyph."'></span>";
@ -200,10 +229,7 @@ class bbcode_shortcodes extends e_shortcode
{
$text ="<img src='".$image."' alt='' style='max-height:18px' />";
}
// $text .= ($link) ? "</a>" : "";
// $text .= "</button>";
return $text;
@ -221,12 +247,23 @@ class bbcode_shortcodes extends e_shortcode
{
list($tag,$tmp) = explode("--",$this->var['tagid']); // works with $frm->bbarea to detect textarea from first half of tag.
}
// $text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert an Image from the Media Manager : ".$this->var['template']."' id='{$id}' href='".e_HTTP.e_ADMIN."image.php?mode=main&amp;action=dialog&amp;for=".$this->var['template']."&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=img' >";
$text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert an Image from the Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN_ABS."image.php?mode=main&amp;action=dialog&amp;for=".$this->var['template']."&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=img' >";
/*
$text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' title='Insert an Image from the Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN_ABS."image.php?mode=main&amp;action=dialog&amp;for=".$this->var['template']."&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=img' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/preimage.png",'picture-o');
// $text .= "<img class='btn btn-small bbcode bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/preimage.png' title='".LANHELP_45."' alt='' />";
$text .= "</a>\n";
*/
$label = $this->button(e_IMAGE_ABS."bbcode/preimage.png",'picture-o');
$opts = array(
'bbcode' => 'img',
'class' => 'btn btn-small btn-primary bbcode bbcode_buttons e-pointer',
'title' => "Insert an Image from the Media Manager : ".$this->var['template']
);
$text = e107::getForm()->mediaUrl($this->var['template'],$label, $tag, $opts);
return $text;
}

View File

@ -985,7 +985,7 @@ class e_form
* @param null $extras
* @return string
*/
private function mediaUrl($category = '', $label = '', $tagid='', $extras=null)
public function mediaUrl($category = '', $label = '', $tagid='', $extras=null)
{
if(is_string($extras))
{
@ -1012,7 +1012,7 @@ class e_form
if(!empty($extras['bbcode']))
{
$url .= '&amp;bbcode=1';
$url .= '&amp;bbcode='.$extras['bbcode'];
}
$url .= "&amp;iframe=1";
@ -1070,7 +1070,7 @@ class e_form
$class = !empty($extras['class']) ? $extras['class']." " : '';
$title = !empty($extras['title']) ? $extras['title'] : $title;
$ret = "<a title=\"{$title}\" class='".$class."e-modal' data-modal-caption='".LAN_EFORM_007."' data-cache='false' data-target='#uiModal' href='".$url."'>".$label."</a>"; // using bootstrap.
$ret = "<a title=\"{$title}\" class='".$class."e-modal' data-modal-submit='true' data-modal-caption='".LAN_EFORM_007."' data-cache='false' data-target='#uiModal' href='".$url."'>".$label."</a>"; // using bootstrap.
if(!e107::getRegistry('core/form/mediaurl'))
{

View File

@ -108,6 +108,9 @@ if((e107::wysiwyg(null, true) === 'tinymce4' && check_class($pref['post_html']))
$('#bbcode-panel-'+id+'--preview').hide();
});
$('#media-manager-submit-buttons').show();
$('.tinyInsert').click(function() {

View File

@ -48,7 +48,11 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
if($this.attr('data-modal-submit'))
{
var buttonCaption = $('#e-modal-iframe').contents().find('#etrigger-submit').text(); // copy submit button caption from iframe form.
$('#e-modal-submit').text(buttonCaption).fadeIn(); // display the button in the modal footer.
if(buttonCaption)
{
$('#e-modal-submit').text(buttonCaption).fadeIn(); // display the button in the modal footer.
}
$('#e-modal-iframe').contents().find('.buttons-bar').hide(); // hide buttons in the iframe's form.
}

View File

@ -519,6 +519,7 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
$this.closest('img').addClass('active');
console.log('Bbcode: '+bbcode);
@ -572,20 +573,7 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
$('img#' + target + "_prev", window.top.document).attr('src', preview); // set new value
if(previewHTML) // mediapicker() method. New in v2.1.9
{
console.log("Mode: MediaPicker");
console.log("Preview Raw: "+previewHTML);
if($htmlHolder.length > 0)
{
$htmlHolder.val(previewHTML);
}
preview = atob(previewHTML).trim();
e107.mediaManager.eMediaAttribute($this, bbcode);
}
else if(type === 'glyph')
if(type === 'glyph')
{
preview = "<span class='" + src + "'>&nbsp;</span>";
@ -676,11 +664,18 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
var bbcode = $this.attr('data-bbcode'); // TinyMce/Textarea insert mode
var close = $this.attr('data-close');
if(!target || !bbcode)
{
console.log('eDialogSave: no target or bbcode');
console.log('eDialogSave (bbcode): ' + bbcode);
console.log('eDialogSave (target): ' + target);
return true;
}
var $target = $('#' + target, window.top.document);
if ($target.length > 0)