From 9efef2bc8c5aee960133bd4dfb8922aadb42c448 Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Sat, 7 Jul 2012 22:04:49 +0000 Subject: [PATCH] TinyMce/MediaManager fixes. --- e107_admin/image.php | 15 ++++++----- e107_admin/newspost.php | 4 +-- e107_core/bbcodes/bb_h.php | 7 ++--- e107_files/jslib/core/mediaManager.js | 27 ++++++++++--------- e107_handlers/bbcode_handler.php | 17 +++++++----- e107_handlers/form_handler.php | 22 +++++++-------- .../tinymce/plugins/ibrowser/ibrowser.php | 3 ++- 7 files changed, 51 insertions(+), 44 deletions(-) diff --git a/e107_admin/image.php b/e107_admin/image.php index 680238bd9..ddf2ec897 100644 --- a/e107_admin/image.php +++ b/e107_admin/image.php @@ -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 "; diff --git a/e107_core/bbcodes/bb_h.php b/e107_core/bbcodes/bb_h.php index a7f24c37c..0df1cf85e 100644 --- a/e107_core/bbcodes/bb_h.php +++ b/e107_core/bbcodes/bb_h.php @@ -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]'; } diff --git a/e107_files/jslib/core/mediaManager.js b/e107_files/jslib/core/mediaManager.js index 0e3e1a569..14547e522 100644 --- a/e107_files/jslib/core/mediaManager.js +++ b/e107_files/jslib/core/mediaManager.js @@ -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 diff --git a/e107_handlers/bbcode_handler.php b/e107_handlers/bbcode_handler.php index 0f9b49acf..bfe76d24f 100644 --- a/e107_handlers/bbcode_handler.php +++ b/e107_handlers/bbcode_handler.php @@ -517,9 +517,12 @@ class e_bbcode array( "\n[/list]", ''), array( "\n[*]", '
  • '), array( "\n[*]", '
  • '), - array( "[h2]", '

    '), // e107 bbcode markup - array( "[h2]", '

    '), - array( "[/h2]", '

    '), + array( "[h=2]", '

    '), // e107 bbcode markup + array( "[h=2]", '

    '), + array( "[/h]", '

    '), + array( "[h=3]", '

    '), // e107 bbcode markup + array( "[h=3]", '

    '), + array( "[/h]", '

    '), array( "[b]", ''), // Tinymce markup array( "[b]", ''), // e107 bbcode markup array( "[/b]", ''), @@ -529,7 +532,7 @@ class e_bbcode array( "[block]", '
    '), array( "[/block]", '
    '), array( "[table]\n", '
  • "; + + $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 "; // TODO to eventually be hidden. - $text .= "bbcode: -
    html: -
    src: -
    path: + $text .= "bbcode: + + + "; } diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index 9392edf9e..74ea29d3e 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -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 .= "
    "; - $text .= $frm->bbarea('news_body', $val, 'news', 'helpb'); + $text .= $frm->bbarea('news_body', $val, 'news', 'news'); $text .= "
    "; $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 .= "
    '), - array( "[/table]\n", '
    '), + array( "[/table]\n", ''), array( "[table]\n", ''), array( "[tbody]\n", ''), array( "[tr]", ''), @@ -545,7 +548,8 @@ class e_bbcode array( "[/td]", ''), array( "[blockquote]", '
    '), array( "[blockquote]", '
    '), - array( "[/blockquote]",'
    '), + array( "[/blockquote]",'
    ') + ); foreach($convert as $arr) @@ -563,12 +567,13 @@ class e_bbcode $text = preg_replace('/(.*?)<\/span>/i',"[u]$1[/u]",$text); // $text = preg_replace('//i', "[table $1]",$text); $text = preg_replace('/
    /i', "[tbody]\n",$text); $text = preg_replace('/','width:px;height:px;'); + $blank = array('','width:px;height:px;',"

    ","

    "); $text = str_replace($blank,"",$text); // Cleanup return str_replace($srch,$repl,$text); diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index fe2788897..2cf5a486b 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -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 = "

    @@ -742,6 +740,8 @@ class e_form $ret .= "
    \n"; + $_SESSION['media_category'] = $mediaCat; // used by TinyMce. + return $ret; // Quick fix - hide TinyMCE links if not installed, dups are handled by JS handler diff --git a/e107_plugins/tinymce/plugins/ibrowser/ibrowser.php b/e107_plugins/tinymce/plugins/ibrowser/ibrowser.php index 6a1f0029a..3d69eee1f 100644 --- a/e107_plugins/tinymce/plugins/ibrowser/ibrowser.php +++ b/e107_plugins/tinymce/plugins/ibrowser/ibrowser.php @@ -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;