From 9ab93214b2c29ff2f32a51669fa41a7cbc8116ba Mon Sep 17 00:00:00 2001 From: Cameron Date: Thu, 7 Mar 2013 22:42:09 -0800 Subject: [PATCH] Tinymce enhancements. --- e107_handlers/form_handler.php | 23 ++- .../tinymce/plugins/e107bbcode/dialog.php | 169 ++++++++++++++++++ .../plugins/e107bbcode/editor_plugin.js | 29 +++ .../plugins/e107bbcode/img/bootstrap.png | Bin 0 -> 2388 bytes e107_plugins/tinymce/templates/mainadmin.xml | 2 +- e107_plugins/tinymce/wysiwyg.php | 15 +- e107_web/js/core/mediaManager.js | 2 +- 7 files changed, 232 insertions(+), 8 deletions(-) create mode 100644 e107_plugins/tinymce/plugins/e107bbcode/dialog.php create mode 100644 e107_plugins/tinymce/plugins/e107bbcode/img/bootstrap.png diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index ca4cce612..c87240031 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -993,14 +993,21 @@ class e_form return $this->radio_multi($name, $value, $checked, $options); } + $labelFound = vartrue($options['label']); + unset($options['label']); // label attribute not valid in html5 + $options = $this->format_options('radio', $name, $options); $options['checked'] = $checked; //comes as separate argument just for convenience // $options['class'] = 'inline'; $text = ""; - if(vartrue($options['label'])) // Bootstrap compatible markup + + + + if($labelFound) // Bootstrap compatible markup { $text .= ""; + $text .= $labelFound.""; } return $text; @@ -2567,6 +2574,16 @@ class e_form case 'method': // Custom Function $method = $attributes['field']; // prevents table alias in method names. ie. u.my_method. $value = call_user_func_array(array($this, $method), array($value, 'read', $parms)); + + // Inline Editing. + if(!vartrue($attributes['noedit']) && vartrue($parms['editable'])) // avoid bad markup, better solution coming up + { + $mode = preg_replace('/[^\w]/', '', vartrue($_GET['mode'], '')); + $methodParms = call_user_func_array(array($this, $method), array($value, 'inline', $parms)); + $source = str_replace('"',"'",json_encode($methodParms)); + $value = "".$value.""; + } + break; case 'hidden': diff --git a/e107_plugins/tinymce/plugins/e107bbcode/dialog.php b/e107_plugins/tinymce/plugins/e107bbcode/dialog.php new file mode 100644 index 000000000..ea47475db --- /dev/null +++ b/e107_plugins/tinymce/plugins/e107bbcode/dialog.php @@ -0,0 +1,169 @@ +' + buttonText + ''; + // alert(html); + tinyMCEPopup.editor.execCommand('mceInsertContent', false, html); + tinyMCEPopup.close(); + }); + + $('#e-cancel').click(function () { + + tinyMCEPopup.close(); + }); + +}); + + +",'jquery'); + + +class e_bootstrap +{ + + function init() + { + $ns = e107::getRender(); + + $text = ' + '; + + $text .= '
+
'.$this->buttonForm().'
'; + + // $text = '
Wow
'; + + $text .= '
'; + + echo $text; + + } + + + + + + + function buttonForm() + { + $frm = e107::getForm(); + + $buttonTypes = array(''=>'Default', 'primary'=>"Primary", 'success'=>"Success", 'info'=>"Info", 'warning'=>"Warning",'danger'=>"Danger",'inverse'=>"Inverse"); + $buttonSizes = array(''=>'Default', 'btn-mini'=>"Mini", 'btn-small'=>"Small", 'btn-large' => "Large"); + + $butSelect = ""; + $butSelect .= "
"; + foreach($buttonTypes as $type=>$diz) + { + + $label = ''; + $butSelect .= $frm->radio('buttonType', $type, false, array('label'=>$label)); + + } + $butSelect .= "
"; + + $butSize = "
"; + + foreach($buttonSizes as $size=>$label) + { + $selected = ($size == '') ? true : false; + $butSize .= $frm->radio('buttonSize', $size, $selected, array('label'=>$label)); + } + $butSize .= "
"; + + + + $text = " + + + + + + + + + + + + + + + + + + + +
Button Style".$butSelect."
Button Size

".$butSize."

Button Text

".$frm->text('buttonText',$value,50)."

Button Url

".$frm->text('buttonUrl','',255)."

+ +
". $frm->admin_button('insertButton','save','other',"Insert") ." + +
"; + + + return $text; + + } + + +} + + +require_once(e_ADMIN."auth.php"); +//e107::lan('core','admin',TRUE); + + +$bootObj = new e_bootstrap; +$bootObj->init(); + + + + + +require_once(e_ADMIN."footer.php"); +exit; +// + + +?> \ No newline at end of file diff --git a/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js b/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js index a65c64b86..9b3546cfa 100644 --- a/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js +++ b/e107_plugins/tinymce/plugins/e107bbcode/editor_plugin.js @@ -8,6 +8,35 @@ (function() { tinymce.create('tinymce.plugins.e107BBCodePlugin', { init : function(ed, url) { + + ed.addCommand('mceBoot', function() { + ed.windowManager.open({ + file : url + '/dialog.php', + width : 900 , // + parseInt(ed.getLang('e107bbcode.delta_width', 0)), + height : 400, // + parseInt(ed.getLang('e107bbcode.delta_height', 0)), + inline : 1 + }, { + plugin_url : url, // Plugin absolute URL + some_custom_arg : 'custom arg' // Custom argument + }); + }); + + // Register button + ed.addButton('e107bbcode', { + title : 'example.desc', + cmd : 'mceBoot', + image : url + '/img/bootstrap.png' + }); + + // Add a node change handler, selects the button in the UI when a image is selected + ed.onNodeChange.add(function(ed, cm, n) { + cm.setActive('example', n.nodeName == 'IMG'); + }); + + + // ------------ + + var t = this, dialect = ed.getParam('bbcode_dialect', 'e107').toLowerCase(); ed.onBeforeSetContent.add(function(ed, o) { diff --git a/e107_plugins/tinymce/plugins/e107bbcode/img/bootstrap.png b/e107_plugins/tinymce/plugins/e107bbcode/img/bootstrap.png new file mode 100644 index 0000000000000000000000000000000000000000..faa225dfca87ab664e10cb2467f4e4536199adcd GIT binary patch literal 2388 zcmd^B{a+LJ9X~{#A3_LVcs?!=AdrX4^Ie|EBP1aaLMVujAvqwG<{E>8+A|_gd^EM5Zn~+Vwrs-KOf=waM7Jx50a_2G{K3z!lBqCu~-nP|4vqHf&Bb46@;J-z^i1^}g|C*X2##0anzYxnw9(D<1V z2=sbXP?N+aum$v3hqtCLh&A-to$kJkZo~s=)S$8lr3ic&;R1Vno&FHoqk`snQR*B~ z^C58FgxIKpz6q+?RtM_wAO=c!0V%a*-)PV;;eS-vS z^7=h^cWB<)W<$;X5aIH>F|$DhQFxx$>p^u=L?TC|I=M_IfnlRii@=CUrWeVK5|~;H zi&z8h?($)NViD{47OP(p8yN&&fbwj>g5HNP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73v!PXD9!$9qZgI1p=Q0(q8855BD+ zRbO_szWE0E*1liGe%}l*gqHO43i211t6p@$@FzEuw#McIO+n-9zyI(L2b;U2rgN^P0yIj?*`26Qtm*jPe}4EbN-v%vfG~~5&dAvGw`>n1 zy)f= Main Admin advhr,advlink,autosave,contextmenu,directionality,e107bbcode,emoticons,ibrowser,jqueryinlinepopups,paste,table,visualchars,wordcount,xhtmlxtras,youtube,fullscreen - link, unlink, bold, italic, underline, undo, redo,formatselect,justifyleft,justifycenter,justifyright,justifyfull, |, ibrowser, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, emoticons, youtube, fullscreen + link, unlink, bold, italic, underline, undo, redo,formatselect,justifyleft,justifycenter,justifyright,justifyfull, |, ibrowser, forecolor, removeformat, table, bullist, numlist, outdent, indent, cleanup, emoticons, youtube, e107bbcode, fullscreen object[*],embed[*] diff --git a/e107_plugins/tinymce/wysiwyg.php b/e107_plugins/tinymce/wysiwyg.php index bf22d55af..b30c808d6 100644 --- a/e107_plugins/tinymce/wysiwyg.php +++ b/e107_plugins/tinymce/wysiwyg.php @@ -212,7 +212,9 @@ class wysiwyg function getConfig($config=FALSE) - { + { + $tp = e107::getParser(); + if(getperms('0')) { $template = "mainadmin.xml"; @@ -249,6 +251,11 @@ class wysiwyg 'plugins' => $this->filter_plugins($config['tinymce_plugins']) ); + $content_css = vartrue($config['content_css'], "{e_WEB_ABS}js/bootstrap/css/bootstrap.min.css"); + $content_styles = array('Bootstrap Button' => 'btn btn-primary', 'Bootstrap Table' => 'table'); + + + $this->config += array( 'theme_advanced_buttons1' => $config['tinymce_buttons1'], @@ -257,7 +264,9 @@ class wysiwyg 'theme_advanced_buttons4' => vartrue($config['tinymce_buttons4']), 'theme_advanced_toolbar_location' => vartrue($config['theme_advanced_toolbar_location'],'top'), 'theme_advanced_toolbar_align' => 'left', - 'theme_advanced_blockformats' => 'p,h2,h3,blockquote,code', + 'theme_advanced_blockformats' => 'p,h2,h3,h4,h5,h6,blockquote,pre,code', + 'theme_advanced_styles' => str_replace(array("+")," ",http_build_query($content_styles)), //'Bootstrap Button=btn btn-primary;Bootstrap Table=table;border=border;fborder=fborder;tbox=tbox;caption=caption;fcaption=fcaption;forumheader=forumheader;forumheader3=forumheader3', + // 'theme_advanced_resize_vertical' => 'true', 'dialog_type' => "modal", // 'theme_advanced_source_editor_height' => '400', @@ -305,6 +314,7 @@ class wysiwyg 'auto_cleanup_word' => 'true', 'cleanup' => 'true', 'convert_fonts_to_spans' => 'true', + 'content_css' => $tp->replaceConstants($content_css), 'trim_span_elements' => 'true', 'inline_styles' => 'true', 'auto_resize' => 'false', @@ -322,7 +332,6 @@ class wysiwyg 'relative_urls' => 'false', //Media Manager prefers it like this. 'preformatted' => 'true', 'document_base_url' => SITEURL, - 'theme_advanced_styles' => 'border=border;fborder=fborder;tbox=tbox;caption=caption;fcaption=fcaption;forumheader=forumheader;forumheader3=forumheader3', 'verify_css_classes' => 'false' ); diff --git a/e107_web/js/core/mediaManager.js b/e107_web/js/core/mediaManager.js index f62a0df73..bc8ad4a14 100644 --- a/e107_web/js/core/mediaManager.js +++ b/e107_web/js/core/mediaManager.js @@ -86,7 +86,7 @@ $(document).ready(function() } // Set the Html / Wysiwyg Value. - var html = '\"\"'; + var html = '\"\"'; $('#html_holder').val(html); // Only Do width/height styling on bbcodes --