Fixed img tag in editor + tpl mediamanager

This commit is contained in:
Francisco 2020-09-17 22:36:24 +01:00
parent 12354e7292
commit a3fb3e6e3e
11 changed files with 225 additions and 109 deletions

View File

@ -51,6 +51,7 @@
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/formats/bbcode.js"></script>
<script src="{$smarty.const.BLOG_BASEURL}/fp-interface/lang/{$lang_locale}/sceditor.js"></script>
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/plugins/flatPressFileManager.js"></script>
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/plugins/flatPressCustomBBCodes.js"></script>
<script>
// Replace the textarea #example with SCEditor
var lang_editor = "{$lang_locale}";

View File

@ -42,6 +42,8 @@
-->
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/formats/bbcode.js"></script>
<script src="{$smarty.const.BLOG_BASEURL}/fp-interface/lang/{$lang_locale}/sceditor.js"></script>
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/plugins/flatPressFileManager.js"></script>
<script src="{$smarty.const.BLOG_BASEURL}/admin/res/sceditor/plugins/flatPressCustomBBCodes.js"></script>
<script>
// Replace the textarea #example with SCEditor
var lang_editor = "{$lang_locale}";
@ -50,11 +52,12 @@
{literal}
var textarea = document.getElementById('content_textarea');
sceditor.create(textarea, {
plugins: 'flatPressFileManager',
toolbar: 'bold,italic,underline,strike,subscript,superscript|left,center,right,justify|font,size,color,removeformat|cut,copy,pastetext|bulletlist,orderedlist,indent,outdent|table|code,quote|horizontalrule,flatPressFileManager,email,link,unlink|emoticon,youtube,date,time|ltr,rtl|print,maximize,source',
emoticonsRoot: eRoot,
format: 'bbcode',
height: "400px",
locale: lang_editor
//style: '../../res/sceditor/themes/content/default.min.css'
});
</script>
{/literal}
@ -87,7 +90,7 @@
<!-- Bootstrap Modal (Open the editor) -->
<div class="modal fade" id="flatpress-files-modal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">File Manager</h5>
@ -96,7 +99,23 @@
</button>
</div>
<div class="modal-body">
NOT WORKING YEY :(
<div class="row">
<div class="col-12" id="currentDirectory">
<input class="form-control mw-100" id="directoryInput" readonly>
</div>
</div>
<div class="row visualizator">
<div class="p-2 col-6 h-100">
<div class="flatpress-files-modal-box h-100 p-3" id="mediaDirectory"></div>
</div>
<div class="p-2 col-6 h-100">
<div class="flatpress-files-modal-box h-100" id="mediaPreview"></div>
</div>
</div>
</div>
<div class="modal-footer">
<div class="w-100 text-center" id="FilesModalFooter">
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,70 @@
/* Include a headers and IMG fix */
// IMG copied and modified from format/bbcode.js
sceditor.formats.bbcode.set('img', {
allowsEmpty: true,
tags: {
img: {
src: null
}
},
allowedChildren: ['#'],
quoteType: sceditor.BBCodeParser.QuoteType.never,
format: function (element, content) {
var width, height,
attribs = '',
style = function (name) {
return element.style ? element.style[name] : null;
};
const EMOTICON_DATA_ATTR = 'data-sceditor-emoticon';
// check if this is an emoticon image
if (sceditor.dom.attr(element, EMOTICON_DATA_ATTR)) {
return content;
}
width = sceditor.dom.attr(element, 'width') || style('width');
height = sceditor.dom.attr(element, 'height') || style('height');
// only add width and height if one is specified
if ((element.complete && (width || height)) ||
(width && height)) {
attribs = '=' + sceditor.dom.width(element) + 'x' +
sceditor.dom.height(element);
}
return '[img=' + sceditor.dom.attr(element, 'src') + '' + attribs + ']' + '[/img]';
},
html: function (token, attrs, content) {
var undef, width, height, match,
attribs = '';
// handle [img width=340 height=240]url[/img]
width = attrs.width;
height = attrs.height;
// handle [img=340x240]url[/img]
if (attrs.defaultattr) {
match = attrs.defaultattr.split(/x/i);
width = match[0];
height = (match.length === 2 ? match[1] : match[0]);
}
if (width !== undef) {
attribs += ' width="' + sceditor.escapeEntities(width, true) + '"';
}
if (height !== undef) {
attribs += ' height="' + sceditor.escapeEntities(height, true) + '"';
}
if(/^images/.test(content)) { // Fix small bug with fp-content directory
return '<img' + attribs + ' src="fp-content/' + sceditor.escapeUriScheme(content) + '" />';
} else {
return '<img' + attribs + ' src="' + sceditor.escapeUriScheme(content) + '" />';
}
}
});

Binary file not shown.

Before

Width:  |  Height:  |  Size: 225 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 537 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 516 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 309 B

View File

@ -1,18 +1,22 @@
.type-attachs a {
padding-left: 25px;
background-image: url('unknown.gif');
background-image: url('unknown.png');
background-repeat: no-repeat;
background-position: left center;
}
.type-images a {
padding-left: 25px;
background-image: url('image2.gif');
background-image: url('image.png');
background-repeat: no-repeat;
background-position: left center;
}
.type-gallery a {
padding-left: 25px;
background-image: url('folder.gif');
background-image: url('folder.png');
background-repeat: no-repeat;
background-position: left center;
}
.btn {
margin-bottom: 0.2rem !important;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 245 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

View File

@ -1,112 +1,134 @@
<link rel="stylesheet" type="text/css" href="{$mmurl}res/style.css" />
<h2>{$plang.head}</h2>
<p>{$plang.description}</p>
{include file=shared:errorlist.tpl}
{html_form class=option-set}
{$plang.page}: {$paginator.current} / {$paginator.total}</br>
{if $currentgallery!=""}<h3>gallery '{$currentgallery}'</h3>{/if}
<table class="entrylist">
<thead>
<colgroup><col/><col width="50%"/><col/><col/><col/></colgroup>
<tr>
<th>&nbsp;</th>
<th>{$plang.colname}</th>
<th>{$plang.colusecount}</th>
<th>{$plang.colsize}</th>
<th>{$plang.colmtime}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{if $currentgallery!=""}
<tr><td>&nbsp;</td>
<td class="main-cell type-gallery" colspan="5">
<a class="link-general" href="admin.php?p=uploader&action=mediamanager">{$plang.up}</a>
</td>
</tr>
{else}
{foreach from=$galleries item=v}
<tr>
<td>
&nbsp;
</td>
<td class="main-cell type-{$v.type}">
<a class="link-general" href="admin.php?p=uploader&action=mediamanager&gallery={$v.name}">{$v.name}</a>
</td>
<td>{if $v.usecount>0}
<a class="link-general" href="search.php?q=images%2F{$v.name}&stype=full&Date_Day=&Date_Month=&Date_Year=&submit=Search">{$v.usecount}</a>
{else}
0
{/if}
</td>
<td>{$v.size}</td>
<td>{$v.mtime}</td>
<td>
<a class="link-delete" href="{$mmbaseurl}&deletefile={$v.type}-{$v.name}">{$plang.delete}</a>
</td>
</tr>
{/foreach}
{/if}
{if $totalfilescount=="0" }
<tr><td colspan="6"><br>{$plang.nofiles} <a class="link-general" href="admin.php?p=uploader&action=default">{$plang.loadfile}</a><br><br></td></tr>
{else}
{foreach from=$files item=v}
<tr>
<td>
{if $v.type=='images'}
<input type='checkbox' name='file[{$v.type}-{$v.name}]'>
{else}
&nbsp;
{/if}
</td>
<td class="main-cell type-{$v.type}"><a class="link-general" {if $v.type=='images'}rel="lightbox[mm]"{/if} href="{$v.url}">{$v.name}</a></td>
<td>{if $v.usecount>0}
<a class="link-general" href="search.php?q={$v.type}%2F{$v.name}&stype=full&Date_Day=&Date_Month=&Date_Year=&submit=Search">{$v.usecount}</a>
{else}
0
{/if}
</td>
<td>{$v.size}</td>
<td>{$v.mtime}</td>
<td>
<a class="link-delete" href="{$mmbaseurl}&deletefile={$v.type}-{$v.name}">{$plang.delete}</a>
</td>
</tr>
{/foreach}
{/if}
</tbody>
</table>
<!-- paginator -->
<p class="paginator">
{foreach name=pagelist from=$paginator.pages item=page}
{if $paginator.current==$page}
{$page}
{else}
<a href="{$mmbaseurl}&page={$page}">{$page}</a>
{/if}
{if $smarty.foreach.pagelist.last==false} - {/if}
{/foreach}
</p>
<div class="row">
<div class="col-xl-12 col-lg-12">
<div class="card shadow mb-4">
<div class="card-header">
<h6 class="m-0 font-weight-bold text-primary">{$plang.head} {if $currentgallery!=""}<span class="ti-angle-double-right"></span> gallery '{$currentgallery}'{/if}</h6>
</div>
<div class="card-body">
<div class="table-responsive table-striped">
<table class="entrylist table">
<thead>
<colgroup><col/><col width="50%"/><col/><col/><col/></colgroup>
<tr class="head_table" style="background-color:#aa4142; color:#fff">
<th>&nbsp;</th>
<th>{$plang.colname}</th>
<th>{$plang.colusecount}</th>
<th>{$plang.colsize}</th>
<th>{$plang.colmtime}</th>
<th>&nbsp;</th>
</tr>
</thead>
<tbody>
{if $currentgallery!=""}
<tr><td>&nbsp;</td>
<td class="main-cell type-gallery" colspan="5">
<a class="link-general" href="admin.php?p=uploader&action=mediamanager">{$plang.up}</a>
</td>
</tr>
{else}
{foreach from=$galleries item=v}
<tr>
<td>&nbsp;
<p>
{$plang.selected}:
<select name='action'>
<option value='-'>{$plang.selectaction}</option>
<{foreach from=$dwgalleries item=v}
<option value='atg-{$v.name}'>{$plang.addtogallery} '{$v.name}'</option>
{/foreach}
</select>
<input type="submit" name="mm-addto" value="{$plang.go}"/>
</p>
<p>
<label>{$plang.newgallery}:
<input type="text" name="mm-newgallery-name" />
</label>
<input type="submit" name="mm-newgallery" value="{$plang.add}"/>
</p>
</td>
<td class="main-cell type-{$v.type}">
<a class="link-general" href="admin.php?p=uploader&action=mediamanager&gallery={$v.name}">{$v.name}</a>
</td>
<td>{if $v.usecount>0}
<a class="link-general" href="search.php?q=images%2F{$v.name}&stype=full&Date_Day=&Date_Month=&Date_Year=&submit=Search">{$v.usecount}</a>
{else}
0
{/if}
</td>
<td>{$v.size}</td>
<td>{$v.mtime}</td>
<td>
<a class="link-delete" href="{$mmbaseurl}&deletefile={$v.type}-{$v.name}">
<span class="ti-trash"></span> {$plang.delete}</a>
</td>
</tr>
{/foreach}
{/if}
{if $totalfilescount=="0" }
<tr><td colspan="6"><br>{$plang.nofiles} <a class="link-general" href="admin.php?p=uploader&action=default">{$plang.loadfile}</a><br><br></td></tr>
{else}
{foreach from=$files item=v}
<tr>
<td>
{if $v.type=='images'}
<input type='checkbox' class='mt-1' name='file[{$v.type}-{$v.name}]'>
{else}
&nbsp;
{/if}
</td>
<td class="main-cell type-{$v.type}"><a class="link-general" {if $v.type=='images'}rel="lightbox[mm]"{/if} href="{$v.url}">{$v.name}</a></td>
<td>{if $v.usecount>0}
<a class="link-general" href="search.php?q={$v.type}%2F{$v.name}&stype=full&Date_Day=&Date_Month=&Date_Year=&submit=Search">{$v.usecount}</a>
{else}
0
{/if}
</td>
<td>{$v.size}</td>
<td>{$v.mtime}</td>
<td>
<a class="link-delete" href="{$mmbaseurl}&deletefile={$v.type}-{$v.name}"><span class="ti-trash"></span> {$plang.delete}</a>
</td>
</tr>
{/foreach}
{/if}
</tbody>
</table>
</div>
<!-- paginator -->
<p class="paginator">
<div class="paginator-left">
{$plang.page}: {$paginator.current} / {$paginator.total}</br>
</div>
<div class="paginator-right">
<ul class="pagination pagination-sm">
{foreach name=pagelist from=$paginator.pages item=page}
{if $paginator.current==$page}
<li class="page-item disabled">
<a class="page-link" href="#" tabindex="-1">{$page}</a>
</li>
{else}
<li class="page-item"><a class="page-link" href="{$mmbaseurl}&page={$page}">{$page}</a></li>
{/if}
<!-- {if $smarty.foreach.pagelist.last==false} - {/if} -->
{/foreach}
</ul>
</div>
</p>
</br>
</br>
<p>
<label>
{$plang.selected}:
<select name='action' class="form-control gallery_select">
<option value='-'>{$plang.selectaction}</option>
<{foreach from=$dwgalleries item=v}
<option value='atg-{$v.name}'>{$plang.addtogallery} '{$v.name}'</option>
{/foreach}
</select>
</label>
<input type="submit" name="mm-addto" class="btn btn-primary" value="{$plang.go}" style="margin-bottom:0.2rem"/>
</p>
<p>
<label>{$plang.newgallery}:
<input type="text" name="mm-newgallery-name" class="form-control input_gray"/>
</label>
<input type="submit" name="mm-newgallery" class="btn btn-primary" value="{$plang.add}" style="margin-bottom:0.2rem"/>
</p>
</div>
</div>
</div>
</div>
{/html_form}