1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02: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; } if(!ADMIN){ exit; }
@@ -1358,7 +1358,7 @@ class media_admin_ui extends e_admin_ui
* Replacement for mediaSelectUpload() * Replacement for mediaSelectUpload()
* @return string * @return string
*/ */
function mediaManagerTabs() private function mediaManagerTabs()
{ {
$frm = e107::getForm(); $frm = e107::getForm();
$tp = e107::getParser(); $tp = e107::getParser();
@@ -1374,9 +1374,10 @@ class media_admin_ui extends e_admin_ui
$cat = $this->getQuery('for'); $cat = $this->getQuery('for');
$tabOptions = array( $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-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-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-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-youtube' => array('caption'=> $tp->toGlyph('fa-youtube-play')."Youtube", 'method' => 'youtubeTab' ),
'core-media-glyph' => array('caption'=> $tp->toGlyph('fa-flag')."Glyphs", 'method' => 'glyphTab'), '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'; $youtubeActive = 'inactive';
$options = array(); $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"; $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()) 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> <span>".LAN_SAVE."</span>
</button> </button>
<button type='submit' class=' btn btn-default btn-secondary submit e-dialog-close' name='cancel_image' value='Cancel' data-close='true'> <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( $parms = array(
'width' => 64, '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()) private function audioTab($cat='', $parm=array())
{ {
@@ -1952,10 +1993,13 @@ class media_admin_ui extends e_admin_ui
'perPage' => 8, 'perPage' => 8,
'gridClass' => 'col-xs-6 col-sm-3 admin-ui-grid media-carousel-item-video', 'gridClass' => 'col-xs-6 col-sm-3 admin-ui-grid media-carousel-item-video',
'bbcode' => 'video', 'bbcode' => 'video',
'close' => 'true'
); );
$close = (!empty($this->getQuery('bbcode'))) ? false : true; // only close on 'select' when bbcodes are not in use.
$items = array(); $items = array();
$videos = e107::getMedia()->getVideos($cat); $videos = e107::getMedia()->getVideos($cat);
@@ -1974,7 +2018,8 @@ class media_admin_ui extends e_admin_ui
'tooltip' => basename($val['media_url'])." (".$size.")", 'tooltip' => basename($val['media_url'])." (".$size.")",
'slideCaption' => '', 'slideCaption' => '',
'slideCategory' => 'bootstrap', '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( $parms = array(
@@ -2159,7 +2204,7 @@ class media_admin_ui extends e_admin_ui
* @return mixed|string * @return mixed|string
* @see https://www.googleapis.com/youtube/v3/search * @see https://www.googleapis.com/youtube/v3/search
*/ */
function youtubeTab($parm='') private function youtubeTab($parm='')
{ {
$apiKey = e107::pref('core','youtube_apikey'); $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)) if(!empty($data))
{ {
foreach($data['items'] as $value) foreach($data['items'] as $value)
@@ -2281,7 +2328,8 @@ class media_admin_ui extends e_admin_ui
'previewUrl' => $thumbnail, 'previewUrl' => $thumbnail,
'saveValue' => $id.".".$extension, // youtube", 'saveValue' => $id.".".$extension, // youtube",
'thumbUrl' => $thumbnail, 'thumbUrl' => $thumbnail,
'title' => varset($value['snippet']['title'],'') 'title' => varset($value['snippet']['title'],''),
'close' => $close
); );
if($extension == 'youtubepl') // save Image for background. 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); $text = e107::getMedia()->browserCarousel($items, $parms);
if(E107_DEBUG_LEVEL > 0 && !empty($feed)) 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_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' >"; $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 else
{ {
@@ -143,13 +154,22 @@ class bbcode_shortcodes extends e_shortcode
$event = $this->getEvent('addtext',$data,LANHELP_48); $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 = "<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 .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube'); // , LANHELP_48
$text .= "</a>"; $text .= "</a>";
return $text; return $text;
} }
/**
* todo complete for 2.2.0
* @param $id
* @return string
*/
function bb_glyph($id) function bb_glyph($id)
{ {
if($this->var['tagid'] == 'data_') // BC work-around for duplicate IDs. 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 = "<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 .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'flag'); // LANHELP_48
$text .= "</a>"; $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; return $text;
} }
@@ -188,10 +220,7 @@ class bbcode_shortcodes extends e_shortcode
function button($image, $glyph='') function button($image, $glyph='')
{ {
// $text .= "<button type='button' class='btn e-pointer' title='".$title."'>";
// $text .= ($link) ? $link : "";
if(deftrue('BOOTSTRAP') && $glyph && deftrue('FONTAWESOME')) if(deftrue('BOOTSTRAP') && $glyph && deftrue('FONTAWESOME'))
{ {
$text = "<span class='fa fa-".$glyph."'></span>"; $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 ="<img src='".$image."' alt='' style='max-height:18px' />";
} }
// $text .= ($link) ? "</a>" : "";
// $text .= "</button>";
return $text; 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. 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 .= $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"; $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; return $text;
} }

View File

@@ -985,7 +985,7 @@ class e_form
* @param null $extras * @param null $extras
* @return string * @return string
*/ */
private function mediaUrl($category = '', $label = '', $tagid='', $extras=null) public function mediaUrl($category = '', $label = '', $tagid='', $extras=null)
{ {
if(is_string($extras)) if(is_string($extras))
{ {
@@ -1012,7 +1012,7 @@ class e_form
if(!empty($extras['bbcode'])) if(!empty($extras['bbcode']))
{ {
$url .= '&amp;bbcode=1'; $url .= '&amp;bbcode='.$extras['bbcode'];
} }
$url .= "&amp;iframe=1"; $url .= "&amp;iframe=1";
@@ -1070,7 +1070,7 @@ class e_form
$class = !empty($extras['class']) ? $extras['class']." " : ''; $class = !empty($extras['class']) ? $extras['class']." " : '';
$title = !empty($extras['title']) ? $extras['title'] : $title; $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')) 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(); $('#bbcode-panel-'+id+'--preview').hide();
}); });
$('#media-manager-submit-buttons').show();
$('.tinyInsert').click(function() { $('.tinyInsert').click(function() {

View File

@@ -48,7 +48,11 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
if($this.attr('data-modal-submit')) if($this.attr('data-modal-submit'))
{ {
var buttonCaption = $('#e-modal-iframe').contents().find('#etrigger-submit').text(); // copy submit button caption from iframe form. 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. $('#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'); $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 $('img#' + target + "_prev", window.top.document).attr('src', preview); // set new value
if(previewHTML) // mediapicker() method. New in v2.1.9 if(type === 'glyph')
{
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')
{ {
preview = "<span class='" + src + "'>&nbsp;</span>"; 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 bbcode = $this.attr('data-bbcode'); // TinyMce/Textarea insert mode
var close = $this.attr('data-close'); var close = $this.attr('data-close');
if(!target || !bbcode) if(!target || !bbcode)
{ {
console.log('eDialogSave: no target or bbcode');
console.log('eDialogSave (bbcode): ' + bbcode);
console.log('eDialogSave (target): ' + target);
return true; return true;
} }
var $target = $('#' + target, window.top.document); var $target = $('#' + target, window.top.document);
if ($target.length > 0) if ($target.length > 0)