1
0
mirror of https://github.com/e107inc/e107.git synced 2025-04-21 21:21:54 +02:00

More media-manager bbcode fixes.

This commit is contained in:
Cameron 2014-01-23 17:23:38 -08:00
parent d2d58451cf
commit 07950a1af2
5 changed files with 119 additions and 87 deletions
e107_admin
e107_core
e107_handlers
e107_web/js/core

@ -1181,7 +1181,6 @@ class media_admin_ui extends e_admin_ui
if($options['bbcode'] || E107_DEBUG_LEVEL > 0)
{
$text .= "<div style='text-align:right;padding:5px'>
@ -1192,19 +1191,19 @@ class media_admin_ui extends e_admin_ui
<span>Cancel</span>
</button>
</div>";
$type = (E107_DEBUG_LEVEL > 0) ? "text" : "hidden";
$br = (E107_DEBUG_LEVEL > 0) ? "<br />" : "";
$text .= "
".$br."<input title='bbcode' type='{$type}' readonly='readonly' class='span11' id='bbcode_holder' name='bbcode_holder' value='' />
".$br."<input title='html/wysiwyg' type='{$type}' class='span11' readonly='readonly' id='html_holder' name='html_holder' value='' />
".$br."<input title='(preview) src' type='{$type}' class='span11' readonly='readonly' id='src' name='src' value='' />
".$br."<input title='path (saved to db)' type='{$type}' class='span11' readonly='readonly' id='path' name='path' value='' />
";
}
$type = (E107_DEBUG_LEVEL > 0) ? "text" : "hidden";
$br = (E107_DEBUG_LEVEL > 0) ? "<br />" : "";
$text .= "
".$br."<input title='bbcode' type='{$type}' readonly='readonly' class='span11' id='bbcode_holder' name='bbcode_holder' value='' />
".$br."<input title='html/wysiwyg' type='{$type}' class='span11' readonly='readonly' id='html_holder' name='html_holder' value='' />
".$br."<input title='(preview) src' type='{$type}' class='span11' readonly='readonly' id='src' name='src' value='' />
".$br."<input title='path (saved to db)' type='{$type}' class='span11' readonly='readonly' id='path' name='path' value='' />
";
return $text;
}
@ -1250,7 +1249,8 @@ class media_admin_ui extends e_admin_ui
'action' =>'glyph', // Used by AJAX to identify correct function.
'perPage' => 90,
'gridClass' => 'media-carousel-item-glyph pull-left',
'bbcode' =>'glyph',
'close' => 'true'
);

@ -133,18 +133,34 @@ 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.
}
$data = "[youtube]*[/youtube]";
$event = $this->getEvent('addinput',$data,LANHELP_48);
// $text = "<a {$event} class='btn ' id='{$id}' data-function='input' href='#{$this->var['tagid']}' title='".$this->br2nl(LANHELP_48)."' data-bbcode='{$data}'>";
// $text .="<img class='btn btn-small bbcode bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/youtube.png' alt='' title='".nl2br(LANHELP_48)."' />";
$text = "<a class='e-modal btn' data-modal-caption='Media Manager' data-target='#uiModal' title='Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&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."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=video' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48);
$text .= "</a>";
return $text;
}
function bb_glyph($id)
{
if($this->var['tagid'] == 'data_') // BC work-around for duplicate IDs.
{
$tag = "data";
}
else
{
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 a Glyphicon via Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&bbcode=glyph' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/youtube.png", 'youtube', LANHELP_48);
$text .= "</a>";
return $text;
}
function bb_link($id)
{
@ -196,7 +212,7 @@ 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' data-modal-caption='Media Manager' data-target='#uiModal' title='Media Manager : ".$this->var['template']."' id='{$id}' href='".e_ADMIN."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&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."image.php?mode=main&action=dialog&for=".$this->var['template']."&tagid=".$tag."&iframe=1&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='' />";
@ -214,7 +230,7 @@ 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' data-modal-caption='Media Manager' data-target='#uiModal' id='{$id}' title='".LANHELP_39."' href='".e_ADMIN."image.php?mode=main&amp;action=dialog&amp;for=_common_file&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=file' >";
$text = "<a class='e-modal btn btn-primary' data-modal-caption='Media Manager' data-target='#uiModal' id='{$id}' title='Insert a file from the Media-Manager' href='".e_ADMIN."image.php?mode=main&amp;action=dialog&amp;for=_common_file&amp;tagid=".$tag."&amp;iframe=1&amp;bbcode=file' >";
$text .= $this->button(e_IMAGE_ABS."bbcode/prefile.png", 'file');
// $text .= "<img class='btn btn-small bbcode bbcode_buttons e-pointer' src='".e_IMAGE_ABS."bbcode/prefile.png' title='".LANHELP_39."' alt='' />";
@ -457,20 +473,31 @@ class bbcode_shortcodes extends e_shortcode
function sc_bb($parm)
{
if(method_exists($this,"bb_".$parm)) // start of the big cleanup.
{
$meth = "bb_".$parm;
$mes = e107::getMessage();
// $mes->debug("Loaded BB: ".$parm);
// e107::getMessage()->debug("Loaded BB: ".$parm);
$unique = $this->var['template']."--".$parm; // works in conjunction with media-manager category
return "\n\n<!-- {$parm} -->\n".$this->$meth($unique);
}
// NOTE: everything below here could be replaced with separate 'bb_xxxx' methods if need be. (see above)
//XXX NOTE: everything below here could be replaced with separate 'bb_xxxx' methods if need be. (see above)
//FIXME - cachevars/getcachedvars!
global $pref, $eplug_bb, $bbcode_func, $bbcode_help, $bbcode_filedir, $bbcode_imagedir, $bbcode_helpactive, $bbcode_helptag, $register_bb;
global $pref, $eplug_bb, $bbcode_func, $bbcode_help, $bbcode_helpactive, $bbcode_helptag, $register_bb;
// if(defsettrue('e_WYSIWYG')){ return; }
$eplug_bb = $this->var['eplug_bb'] ? $this->var['eplug_bb'] : array();
@ -482,8 +509,8 @@ class bbcode_shortcodes extends e_shortcode
$bbcode_tag = ($bbcode_helptag != 'helpb') ? ",'$bbcode_helptag'" : "";
$rand = rand(1000,9999);
$imagedir_display = str_replace('../','',$bbcode_imagedir);
// $imagedir_display = str_replace('../','',$bbcode_imagedir);
/*
if($parm == 'emotes')
{
if ($pref['comments_emoticons'] && $pref['smiley_activate'] && !defsettrue('e_WYSIWYG'))
@ -495,12 +522,12 @@ class bbcode_shortcodes extends e_shortcode
return '';
}
}
*/
// Format: $bbcode['UNIQUE_NAME'] = array(ONCLICK_FUNC, ONCLICK_VAR, HELPTEXT, ICON, INCLUDE_FUNC, INCLUDE_FUNCTION_VAR);
// $bbcode['newpage'] = array($bbcode_func,"[newpage]", LANHELP_34, "newpage.png");
$bbcode['link'] = array('addinput', "[link=".LANHELP_35."][/link]", LANHELP_23, "link.png", 'link');
// $bbcode['link'] = array('addinput', "[link=".LANHELP_35."][/link]", LANHELP_23, "link.png", 'link');
$bbcode['b'] = array($bbcode_func, "[b][/b]", LANHELP_24, "bold.png", '', '', 'bold');
$bbcode['i'] = array($bbcode_func, "[i][/i]", LANHELP_25, "italic.png", '', '', 'italic');
@ -513,17 +540,18 @@ class bbcode_shortcodes extends e_shortcode
$bbcode['list'] = array($bbcode_func, "[list][/list]", LANHELP_36, "list.png", '', '', 'list');
$bbcode['img'] = array($bbcode_func, "[img][/img]", LANHELP_27, "image.png" , '', '', 'picture-o');
$bbcode['flash'] = array($bbcode_func, "[flash=width,height][/flash]", LANHELP_47, "flash.png", '', '', 'flash');
$bbcode['youtube'] = array($bbcode_func, "[youtube][/youtube]", LANHELP_48, "youtube.png", '', '', 'youtube');
// $bbcode['youtube'] = array($bbcode_func, "[youtube][/youtube]", LANHELP_48, "youtube.png", '', '', 'youtube');
$bbcode['sanitised'] = array('', '', '');
$bbcode['nobr'] = array($bbcode_func, "[nobr][/nobr]", LANHELP_51, "nobr.png"); // FIXME bbcode icon
$bbcode['br'] = array($bbcode_func, "[br]", LANHELP_52, "br.png"); // FIXME bbcode icon
$bbcode['fontsize'] = array("expandit", "size_selector_".$rand, LANHELP_22,"fontsize.png","Size_Select",'size_selector_'.$rand);
$bbcode['fontcol'] = array("e-expandit", "col_selector_".$rand, LANHELP_21,"fontcol.png","Color_Select",'col_selector_'.$rand);
$bbcode['preimage'] = array("e-dialog", "preimage_selector_".$rand, LANHELP_45.$imagedir_display,"preimage.png","PreImage_Select","preimage_selector_".$rand);
$bbcode['prefile'] = array("expandit", "prefile_selector_".$rand, LANHELP_39,"prefile.png","PreFile_Select",'prefile_selector_'.$rand);
// $bbcode['fontsize'] = array("expandit", "size_selector_".$rand, LANHELP_22,"fontsize.png","Size_Select",'size_selector_'.$rand);
// $bbcode['fontcol'] = array("e-expandit", "col_selector_".$rand, LANHELP_21,"fontcol.png","Color_Select",'col_selector_'.$rand);
// $bbcode['preimage'] = array("e-dialog", "preimage_selector_".$rand, LANHELP_45.$imagedir_display,"preimage.png","PreImage_Select","preimage_selector_".$rand);
// $bbcode['prefile'] = array("expandit", "prefile_selector_".$rand, LANHELP_39,"prefile.png","PreFile_Select",'prefile_selector_'.$rand);
if(!isset($iconpath[$parm]))
{
@ -627,10 +655,10 @@ class bbcode_shortcodes extends e_shortcode
function sc_bb_preimagedir($parm)
{
if(defsettrue('e_WYSIWYG')) { return; }
global $bbcode_imagedir;
$bbcode_imagedir = $parm;
return;
// if(defsettrue('e_WYSIWYG')) { return; }
// global $bbcode_imagedir;
// $bbcode_imagedir = $parm;
// return;
}
}
?>

@ -56,16 +56,16 @@ $BBCODE_TEMPLATE_ADMIN = "
<div class='btn-toolbar'>
{BB=link}{BB=b}{BB=i}{BB=u}{BB=img}{BB=format}{BB=left}{BB=center}{BB=right}{BB=justify}
{BB=list}{BB=table}{BB=fontcol}{BB=fontsize}{BB=emotes}
{BB_PREIMAGEDIR}
{BB=preimage}{BB=prefile}{BB=flash}{BB=youtube}
{BB_PREIMAGEDIR}{BB=flash}
<div class='btn-group'>{BB=preimage}{BB=prefile}{BB=youtube}</div>
</div>
";
$BBCODE_TEMPLATE_MAILOUT = "
<div class='btn-toolbar'>
{BB=link}{BB=b}{BB=i}{BB=u}{BB=img}{BB=left}{BB=center}{BB=right}{BB=justify}{BB=list}{BB=fontcol}{BB=fontsize}{BB=emotes}
{BB_PREIMAGEDIR}
{BB=preimage}{BB=prefile}{BB=flash}{BB=shortcode}
{BB_PREIMAGEDIR}{BB=flash}
<div class='btn-group'>{BB=preimage}{BB=prefile}{BB=shortcode}</div>
</div>
";
@ -74,18 +74,18 @@ $BBCODE_TEMPLATE_MAILOUT = "
$BBCODE_TEMPLATE_NEWSPOST = "
<div class='btn-toolbar'>
{BB=link}{BB=b}{BB=i}{BB=u}{BB=img}{BB=format}{BB=left}{BB=center}{BB=right}{BB=justify}
{BB=list}{BB=table}{BB=fontcol}{BB=fontsize}{BB=emotes}
{BB=list}{BB=table}{BB=fontcol}{BB=fontsize}{BB=emotes}{BB=flash}
{BB_PREIMAGEDIR=news}
{BB=preimage}{BB=prefile}{BB=flash}{BB=youtube}
<div class='btn-group'>{BB=preimage}{BB=prefile}{BB=youtube}</div>
</div>
";
$BBCODE_TEMPLATE_CPAGE = "
<div class='btn-toolbar'>
{BB=link}{BB=b}{BB=i}{BB=u}{BB=img}{BB=format}{BB=left}{BB=center}{BB=right}{BB=justify}
{BB=list}{BB=table}{BB=fontcol}{BB=fontsize}{BB=emotes}
{BB=list}{BB=table}{BB=fontcol}{BB=fontsize}{BB=emotes}{BB=flash}
{BB_PREIMAGEDIR=page}
{BB=preimage}{BB=prefile}{BB=flash}{BB=youtube}
<div class='btn-group'>{BB=preimage}{BB=prefile}{BB=youtube}</div>
</div>
";
?>

@ -1036,16 +1036,16 @@ class e_media
{
$data[$k] = isset($row[$k]) ? $row[$k] : $default[$k];
}
$close = (E107_DEBUG_LEVEL > 0) ? "" : "e-dialog-close";
$close = (E107_DEBUG_LEVEL > 0) ? "" : " data-close='true' "; //
$text .= "\n\n<!-- Start Item -->\n<div class='media-carousel ".$data['gridClass']."'>
<div class='well clearfix'>
<a data-toggle='context' class='e-media-select ".$close." e-tip' 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='#' >";
<a data-toggle='context' class='e-media-select e-dialog-save e-tip' ".$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='#' >";
if($data['type'] == 'image')
{

@ -1,36 +1,7 @@
$(document).ready(function()
{
$(".e-dialog-save").live("click", function(){// FIXME TODO missing caret , text selection overwrite etc.
var newval = $('#bbcode_holder').val();
var target = $(this).attr('data-target');
var bbcode = $(this).attr('data-bbcode'); // TinyMce/Textarea insert mode
// if(!target || !bbcode){ return true; }
if(target && newval)
{
$('#' + target, window.top.document).atCaret('insert', newval); // http://code.google.com/p/jquery-at-caret/wiki/GettingStarted
}
//var cursorIndex = $('#' + target, window.top.document).attr("selectionStart");
//var lStr = $('#' + target, window.top.document).attr('value').substr(0,cursorIndex) + " " + newval + " ";
//var rStr = $('#' + target, window.top.document).attr('value').substr(cursorIndex);
//$('#' + target, window.top.document).attr('value',lStr+rStr);
//$('#' + target, window.top.document).attr("selectionStart",lStr.length);
//('#' + target, window.top.document).insertAtCaret(newVal);
// $('#' + target, window.parent.document).append(newval); //FIXME caret!!
// var t = $('#' + target, window.parent.document).text();
//$('#' + target, window.top.document).attr('value',newval); // set new value
// inserttext(newval,target);
// alert(newval);
});
$(".e-media-attribute").keyup(function () {
@ -116,7 +87,7 @@ $(document).ready(function()
style = style + 'height:' + height + 'px;';
}
if(bbcode !== 'video')
if(bbcode != 'video')
{
bb = '[img';
@ -128,7 +99,6 @@ $(document).ready(function()
bb = bb + ']';
bb = bb + path;
bb = bb + '[/img]';
$('#bbcode_holder').val(bb); // Set the BBcode Value.
}
@ -145,9 +115,9 @@ $(document).ready(function()
// $(".e-media-select").click(function () {
$(".e-media-select").live("click", function(){
// console.log(this);
// alert('hi');
var id = $(this).attr('data-id');
var target = $(this).attr('data-target');
@ -160,6 +130,7 @@ $(document).ready(function()
var height = ''; // disable for now - will be updated by bb parser. // $(this).attr('data-height');
var type = $(this).attr('data-type');
// return;
// alert(width);
@ -181,12 +152,11 @@ $(document).ready(function()
//alert('hello');
}
if(bbcode == "video")
if(bbcode == "video" || bbcode == 'glyph')
{
bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']';
$('#bbcode_holder').val(bbpath);
}
@ -245,7 +215,41 @@ $(document).ready(function()
});
// Must be defined after e-media-select
$(".e-dialog-save").live("click", function(){// FIXME TODO missing caret , text selection overwrite etc.
var newval = $('#bbcode_holder').val();
var target = $(this).attr('data-target');
var bbcode = $(this).attr('data-bbcode'); // TinyMce/Textarea insert mode
var close = $(this).attr('data-close');
if(!target || !bbcode){ return true; }
$('#' + target, window.top.document).atCaret('insert', newval); // http://code.google.com/p/jquery-at-caret/wiki/GettingStarted
if(close == 'true')
{
parent.$('.modal').modal('hide');
}
//var cursorIndex = $('#' + target, window.top.document).attr("selectionStart");
//var lStr = $('#' + target, window.top.document).attr('value').substr(0,cursorIndex) + " " + newval + " ";
//var rStr = $('#' + target, window.top.document).attr('value').substr(cursorIndex);
//$('#' + target, window.top.document).attr('value',lStr+rStr);
//$('#' + target, window.top.document).attr("selectionStart",lStr.length);
//('#' + target, window.top.document).insertAtCaret(newVal);
// $('#' + target, window.parent.document).append(newval); //FIXME caret!!
// var t = $('#' + target, window.parent.document).text();
//$('#' + target, window.top.document).attr('value',newval); // set new value
// inserttext(newval,target);
// alert(newval);
});