1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 01:19:44 +01:00

TinyMce/MediaManager fixes.

This commit is contained in:
CaMer0n 2012-07-07 22:04:49 +00:00
parent d3c7570d4b
commit 9efef2bc8c
7 changed files with 51 additions and 44 deletions

View File

@ -491,13 +491,13 @@ class media_admin_ui extends e_admin_ui
{
/*
if($this->getQuery('bbcode'))
{
//TODO this is not really used when jquery is running.
e107::getJS()->headerInline("
/* Send the generated IMG bbcode back to the textarea/window */
// Send the generated IMG bbcode back to the textarea/window
function saveBB()
{
@ -517,6 +517,7 @@ class media_admin_ui extends e_admin_ui
");
}
*/
$this->getResponse()->setIframeMod(); // disable header/footer menus etc.
if(!$this->getQuery('for'))
@ -619,6 +620,8 @@ class media_admin_ui extends e_admin_ui
<table class='adminedit'>
<tbody><tr><td>
";
$tag = ($bbcodeMode) ? "" : $this->getQuery('tagid');
$text .= e107::getMedia()->mediaSelect($this->getQuery('for'),$this->getQuery('tagid'),$bbcodeMode); // eg. news, news-thumbnail
@ -715,10 +718,10 @@ class media_admin_ui extends e_admin_ui
</div>";
// TODO to eventually be hidden.
$text .= "bbcode: <input type='text' style='width:800px' id='bbcode_holder' name='bbcode_holder' value='' />
<br />html: <input type='text' style='width:800px' id='html_holder' name='html_holder' value='' />
<br />src: <input type='text' style='width:600px' id='src' name='src' value='' />
<br />path: <input type='text' style='width:600px' id='path' name='path' value='' />
$text .= "bbcode: <input type='text' readonly='readonly' style='border:0px; width:700px' id='bbcode_holder' name='bbcode_holder' value='' />
<input title='html' type='hidden' style='width:800px' id='html_holder' name='html_holder' value='' />
<input title='src' type='hidden' style='width:600px' id='src' name='src' value='' />
<input title='path' type='hidden' style='width:600px' id='path' name='path' value='' />
";
}

View File

@ -1995,12 +1995,12 @@ class admin_newspost
$val = (strstr($tp->post_toForm($_POST['news_body']), "[img]http") ? $tp->post_toForm($_POST['news_body']) : str_replace("[img]../", "[img]", $tp->post_toForm($_POST['news_body'])));
$text .= "<div id='news-body-container'>";
$text .= $frm->bbarea('news_body', $val, 'news', 'helpb');
$text .= $frm->bbarea('news_body', $val, 'news', 'news');
$text .= "</div><div id='news-extended-container'>";
$val = (strstr($tp->post_toForm($_POST['news_extended']), "[img]http") ? $tp->post_toForm($_POST['news_extended']) : str_replace("[img]../", "[img]", $tp->post_toForm($_POST['news_extended'])));
$text .= $frm->bbarea('news_extended', $val, 'extended', 'helpc','large');
$text .= $frm->bbarea('news_extended', $val, 'extended', 'news','large');
$text .= "</div>
</div></td></tr>";

View File

@ -45,12 +45,9 @@ class bb_h extends e_bb_base
}
if($safe)
{
return '[h'.$h.'|'.eHelper::buildAttr($safe).']'.$code_text.'[/h'.$h.']';
return '[h='.$h.'|'.eHelper::buildAttr($safe).']'.$code_text.'[/h]';
}
return '[h'.$h.']'.$code_text.'[/h'.$h.']';
// IMPORTANT: Using '[h=2]' with a non-matching closing tag etc will cause major issues with TinyMce.
// It is cleaner to use [h2], [h3] etc. TODO - Batch BBcodes. ;-)
return '[h='.$h.']'.$code_text.'[/h]';
}

View File

@ -7,6 +7,8 @@ $(document).ready(function()
var newval = $('#bbcode_holder').val();
// alert(newval);
var target = $(this).attr('data-target');
if(!target){return true; }
//('#' + target, window.top.document).insertAtCaret(newVal);
// $('#' + target, window.parent.document).append(newval); //FIXME caret!!
@ -102,7 +104,7 @@ $(document).ready(function()
$(".e-media-select").live("click", function(){
console.log(this);
// console.log(this);
@ -113,28 +115,27 @@ $(document).ready(function()
var bbcode = $(this).attr('data-bbcode');
$(this).addClass("media-select-active");
$(this).closest("img").addClass("active");
$(this).closest("img").addClass("active");
// TinyMce?
$('input#' + target, window.top.document).attr('value',path); // set new value
if(bbcode)
if(bbcode) // not needed for Tinymce
{
bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']';
$('textarea#' + target, window.top.document).attr('value',bbpath);
// $('input#' + target, window.top.document).attr('value',path); // set new value
// bbpath = '['+bbcode+']'+ path + '[/' + bbcode + ']';
// $('textarea#' + target, window.top.document).attr('value',bbpath);
}
$('img#' + target + "_prev", window.top.document).attr('src',preview); // set new value
$('div#' + target + "_prev", window.top.document).html(preview); // set new value
$('span#' + target + "_prev", window.top.document).html(preview); // set new value
$('#src').attr('value',src); // working old
$('#preview').attr('src',preview); // working old
$('#path').attr('value',path); // working old
$('#src').attr('src',src); // working old
$('img#' + target + "_prev", window.top.document).attr('src',preview); // set new value
$('div#' + target + "_prev", window.top.document).html(preview); // set new value
$('span#' + target + "_prev", window.top.document).html(preview); // set new value
eMediaAttribute(this);
// $(this).parent('#src').attr('value',preview); // set new value

View File

@ -517,9 +517,12 @@ class e_bbcode
array( "\n[/list]", '</ul>'),
array( "\n[*]", '<li>'),
array( "\n[*]", '<li class="bbcode bbcode-list">'),
array( "[h2]", '<h2 class="bbcode-center" style="text-align: center;">'), // e107 bbcode markup
array( "[h2]", '<h2>'),
array( "[/h2]", '</h2>'),
array( "[h=2]", '<h2 class="bbcode-center" style="text-align: center;">'), // e107 bbcode markup
array( "[h=2]", '<h2>'),
array( "[/h]", '</h2>'),
array( "[h=3]", '<h3 class="bbcode-center" style="text-align: center;">'), // e107 bbcode markup
array( "[h=3]", '<h3>'),
array( "[/h]", '</h3>'),
array( "[b]", '<strong>'), // Tinymce markup
array( "[b]", '<strong class="bbcode bold bbcode-b">'), // e107 bbcode markup
array( "[/b]", '</strong>'),
@ -529,7 +532,7 @@ class e_bbcode
array( "[block]", '<div>'),
array( "[/block]", '</div>'),
array( "[table]\n", '<table>'),
array( "[/table]\n", '</table>'),
array( "[/table]\n", '</table>'),
array( "[table]\n", '<table class="bbcode-table">'),
array( "[tbody]\n", '<tbody class="bbcode-tbody">'),
array( "[tr]", '<tr class="bbcode-tr">'),
@ -545,7 +548,8 @@ class e_bbcode
array( "[/td]", '</td>'),
array( "[blockquote]", '<blockquote>'),
array( "[blockquote]", '<blockquote class="indent bbcode-blockquote">'),
array( "[/blockquote]",'</blockquote>'),
array( "[/blockquote]",'</blockquote>')
);
foreach($convert as $arr)
@ -563,12 +567,13 @@ class e_bbcode
$text = preg_replace('/<span (?:class="bbcode underline bbcode-u" )?style="text-decoration: underline;">(.*?)<\/span>/i',"[u]$1[/u]",$text);
// $text = preg_replace('/<table([^"]*)>/i', "[table $1]",$text);
$text = preg_replace('/<table style="([^"]*)"([\w ="]*)?>/i', "[table style=$1]\n",$text);
$text = preg_replace('/<table([\w :\-_;="]*)?>/i', "[table]\n",$text);
$text = preg_replace('/<tbody([\w ="]*)?>/i', "[tbody]\n",$text);
$text = preg_replace('/<code([\w :\-_;="]*)?>/i', "[code]\n",$text);
$blank = array('</li>','width:px;height:px;');
$blank = array('</li>','width:px;height:px;',"</p>","<p>");
$text = str_replace($blank,"",$text); // Cleanup
return str_replace($srch,$repl,$text);

View File

@ -697,9 +697,10 @@ class e_form
/**
* Bbcode Area. Name, value, template, form-id, size, options array eg. counter
* IMPORTANT: $$mediaCat is also used is the media-manager category identifier
*/
function bbarea($name, $value, $template = '', $help_tagid='', $size = 'large', $options = array())
{
function bbarea($name, $value, $template = '', $mediaCat='_common', $size = 'large', $options = array())
{
//size - large|medium|small
//width should be explicit set by current admin theme
switch($size)
@ -720,17 +721,14 @@ class e_form
}
// auto-height support
$options['class'] = 'tbox bbarea '.($size ? ' '.$size : '').' e-wysiwyg e-autoheight';
$bbbar = '';
$options['class'] = 'tbox bbarea '.($size ? ' '.$size : '').' e-wysiwyg e-autoheight';
$bbbar = '';
// FIXME - see ren_help.php
// require_once(e_HANDLER."ren_help.php"); // Ren-help no longer required.
// $bbbar = display_help($help_tagid, $template, 'addtext', 'help', $size);
$help_tagid = $this->name2id($name)."--preview"; // not really needed, but a unique name is always welcome
$options['other'] = "onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'";
$help_tagid = $this->name2id($name)."--preview";
$options['other'] = "onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);'";
$counter = vartrue($options['counter'],false);
$counter = vartrue($options['counter'],false);
$ret = "
<div class='bbarea {$size}'>
@ -742,6 +740,8 @@ class e_form
$ret .= "</div>\n";
$_SESSION['media_category'] = $mediaCat; // used by TinyMce.
return $ret;
// Quick fix - hide TinyMCE links if not installed, dups are handled by JS handler

View File

@ -22,7 +22,8 @@
// unset $tinyMCE_imglib_include
require_once("../../../../class2.php");
header("Location: ".e_ADMIN_ABS.'image.php?mode=main&action=dialog&for=news&tagid=news-thumbnail&iframe=1&bbcode=1');
header("Location: ".e_ADMIN_ABS.'image.php?mode=main&action=dialog&for='.$_SESSION['media_category'].'&tagid=&iframe=1&bbcode=1');
exit;