From 0f4e91cfc7ce44a0b3225cedaf72d8286e230e66 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Fri, 12 Jun 2015 00:00:24 +0300 Subject: [PATCH 01/15] Page Break button as native tinyMCE plugin --- .../en-GB/en-GB.plg_editors_tinymce.ini | 4 ++- .../tinymce/plugins/joomlabreak/plugin.min.js | 25 +++++++++++++++++++ plugins/editors/tinymce/tinymce.php | 13 ++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 media/editors/tinymce/plugins/joomlabreak/plugin.min.js diff --git a/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini b/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini index bb9bf4a1a47c3..fcb1d2ccd4572 100644 --- a/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini +++ b/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini @@ -130,4 +130,6 @@ PLG_TINY_TEMPLATE_LAYOUT1_DESC="HTML layout." PLG_TINY_TEMPLATE_LAYOUT1_TITLE="Layout" PLG_TINY_TEMPLATE_SNIPPET1_DESC="Simple HTML snippet." PLG_TINY_TEMPLATE_SNIPPET1_TITLE="Simple Snippet" -PLG_TINY_XML_DESCRIPTION="TinyMCE is a platform independent web based JavaScript HTML WYSIWYG Editor." \ No newline at end of file +PLG_TINY_XML_DESCRIPTION="TinyMCE is a platform independent web based JavaScript HTML WYSIWYG Editor." + +PLG_TINY_READMORE_ALREADY_EXISTS="There is already a Read more ... link that has been inserted. Only one link is permitted. Use {pagebreak} to split the page up further." \ No newline at end of file diff --git a/media/editors/tinymce/plugins/joomlabreak/plugin.min.js b/media/editors/tinymce/plugins/joomlabreak/plugin.min.js new file mode 100644 index 0000000000000..c5c2688837f2f --- /dev/null +++ b/media/editors/tinymce/plugins/joomlabreak/plugin.min.js @@ -0,0 +1,25 @@ +tinymce.PluginManager.add("joomlabreak", function(a) { + a.addCommand("mceJoomlaBreak", function() { + var myRe = /"); + } + }), a.addButton("joomlabreak", { + text: 'Joomla!', + icon: 'pagebreak', + title: "Joomla Page break", + cmd: "mceJoomlaBreak" + }), a.addMenuItem("joomlabreak", { + text: "Joomla Page break", + icon: "pagebreak", + cmd: "mceJoomlaBreak", + context: "insert" + }) +}); diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 95b86c2243240..63d28c882fa46 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -248,6 +248,7 @@ public function onInit() $toolbar2_add = array(); $toolbar3_add = array(); $toolbar4_add = array(); + $toolbar5_add = array(); $elements = array(); $plugins = array( 'autolink', @@ -602,6 +603,8 @@ public function onInit() $toolbar4_add[] = $custom_button; } + $toolbar5_add[] = 'joomlabreak'; + // Prepare config variables $plugins = implode(',', $plugins); $elements = implode(',', $elements); @@ -611,6 +614,7 @@ public function onInit() $toolbar2 = implode(' ', $toolbar2_add); $toolbar3 = implode(' ', $toolbar3_add); $toolbar4 = implode(' ', $toolbar4_add); + $toolbar5 = implode(' ', $toolbar5_add); // See if mobileVersion is activated $mobileVersion = $this->params->get('mobile', 0); @@ -654,6 +658,7 @@ public function onInit() schema: \"html5\", menubar: false, toolbar1: \"bold italics underline strikethrough | undo redo | bullist numlist\", + toolbar5: \"$toolbar5\", // Cleanup/Output inline_styles : true, gecko_spellcheck : true, @@ -667,6 +672,8 @@ public function onInit() $content_css document_base_url : \"" . JUri::root() . "\" }); + var hrExists = \"" . + JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\"; "; break; @@ -700,6 +707,7 @@ public function onInit() // Toolbar toolbar1: \"$toolbar1\", toolbar2: \"$toolbar2\", + toolbar5: \"$toolbar5\", removed_menuitems: \"newdocument\", // URL relative_urls : $relative_urls, @@ -714,6 +722,8 @@ public function onInit() width : \"$html_width\", }); + var hrExists = \"" . + JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\"; "; break; @@ -746,6 +756,7 @@ public function onInit() toolbar2: \"$toolbar2\", toolbar3: \"$toolbar3\", toolbar4: \"$toolbar4\", + toolbar5: \"$toolbar5\", removed_menuitems: \"newdocument\", // URL relative_urls : $relative_urls, @@ -778,6 +789,8 @@ public function onInit() width : \"$html_width\", }); + var hrExists = \"" . + JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\"; "; break; } From 45717799bdfc332f480d97fce1c914d3ec8d8721 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Fri, 12 Jun 2015 00:20:06 +0300 Subject: [PATCH 02/15] string order --- administrator/language/en-GB/en-GB.plg_editors_tinymce.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini b/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini index fcb1d2ccd4572..d241f5fe64d3f 100644 --- a/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini +++ b/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini @@ -126,10 +126,9 @@ PLG_TINY_FIELD_VISUALBLOCKS_DESC="See the outline of HTML block elements." PLG_TINY_FIELD_VISUALBLOCKS_LABEL="Visualblocks" PLG_TINY_FIELD_WORDCOUNT_DESC="Turn on/off Wordcount." PLG_TINY_FIELD_WORDCOUNT_LABEL="Wordcount" +PLG_TINY_READMORE_ALREADY_EXISTS="There is already a Read more ... link that has been inserted. Only one link is permitted. Use {pagebreak} to split the page up further." PLG_TINY_TEMPLATE_LAYOUT1_DESC="HTML layout." PLG_TINY_TEMPLATE_LAYOUT1_TITLE="Layout" PLG_TINY_TEMPLATE_SNIPPET1_DESC="Simple HTML snippet." PLG_TINY_TEMPLATE_SNIPPET1_TITLE="Simple Snippet" PLG_TINY_XML_DESCRIPTION="TinyMCE is a platform independent web based JavaScript HTML WYSIWYG Editor." - -PLG_TINY_READMORE_ALREADY_EXISTS="There is already a Read more ... link that has been inserted. Only one link is permitted. Use {pagebreak} to split the page up further." \ No newline at end of file From 3cf83cd31560d03646163bc627fb7dd613083cda Mon Sep 17 00:00:00 2001 From: dgt41 Date: Fri, 12 Jun 2015 02:45:04 +0300 Subject: [PATCH 03/15] All the buttons Still needs: Correct Strings functionality to auto clos the modal for article and page break --- .../tinymce/plugins/example/dialog.html | 8 --- .../plugins/joomlaarticle/plugin.min.js | 38 ++++++++++++++ .../tinymce/plugins/joomlabreak/plugin.min.js | 4 +- .../tinymce/plugins/joomlaimage/plugin.min.js | 50 +++++++++++++++++++ .../tinymce/plugins/joomlapager/plugin.min.js | 38 ++++++++++++++ plugins/editors/tinymce/tinymce.php | 25 ++++++++-- 6 files changed, 150 insertions(+), 13 deletions(-) delete mode 100644 media/editors/tinymce/plugins/example/dialog.html create mode 100644 media/editors/tinymce/plugins/joomlaarticle/plugin.min.js create mode 100644 media/editors/tinymce/plugins/joomlaimage/plugin.min.js create mode 100644 media/editors/tinymce/plugins/joomlapager/plugin.min.js diff --git a/media/editors/tinymce/plugins/example/dialog.html b/media/editors/tinymce/plugins/example/dialog.html deleted file mode 100644 index 565f06f5e0e98..0000000000000 --- a/media/editors/tinymce/plugins/example/dialog.html +++ /dev/null @@ -1,8 +0,0 @@ - - - -

Custom dialog

- Input some text: - - - \ No newline at end of file diff --git a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js new file mode 100644 index 0000000000000..06ef34cee9f1e --- /dev/null +++ b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js @@ -0,0 +1,38 @@ +tinymce.PluginManager.add("joomlaarticle", function(a, b) { + a.addButton("joomlaarticle", { + text: "Joomla", + icon: "new", + onclick: function() { + if (imgLink) { + a.windowManager.open({ + title : "Joomla Select Article", + url : 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&' + toc + '=1', + width : 900, + height : 600, + buttons: [{ + text : "Close", + onclick: "close" + }] + }) + } + } + }), a.addMenuItem("joomlaarticle", { + text: "Joomla Select Article", + context: "insert", + icon: "new", + onclick: function() { + if (imgLink) { + a.windowManager.open({ + title : "Joomla Select Article", + url : 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&' + toc + '=1', + width : 900, + height : 600, + buttons: [{ + text : "Close", + onclick: "close" + }] + }) + } + } + }) +}); \ No newline at end of file diff --git a/media/editors/tinymce/plugins/joomlabreak/plugin.min.js b/media/editors/tinymce/plugins/joomlabreak/plugin.min.js index c5c2688837f2f..dbafeb2f2e768 100644 --- a/media/editors/tinymce/plugins/joomlabreak/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlabreak/plugin.min.js @@ -14,10 +14,10 @@ tinymce.PluginManager.add("joomlabreak", function(a) { }), a.addButton("joomlabreak", { text: 'Joomla!', icon: 'pagebreak', - title: "Joomla Page break", + title: "Joomla Read More", cmd: "mceJoomlaBreak" }), a.addMenuItem("joomlabreak", { - text: "Joomla Page break", + text: "Joomla Read More", icon: "pagebreak", cmd: "mceJoomlaBreak", context: "insert" diff --git a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js new file mode 100644 index 0000000000000..d2ba5116cde36 --- /dev/null +++ b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js @@ -0,0 +1,50 @@ +tinymce.PluginManager.add("joomlaimage", function(a, b) { + a.addButton("joomlaimage", { + text: "Joomla", + icon: "image", + onclick: function() { + if (imgLink) { + a.windowManager.open({ + title : "Change or upload image", + url : imgLink + a.getContainer().id, + width : 900, + height : 600, + buttons: [{ + text : "Insert", + onclick: function () { + var b = a.windowManager.getWindows()[0]; + a.insertContent("\"\""), b.close() + } + }, { + text : "Close", + onclick: "close" + }] + }) + } + } + }), a.addMenuItem("joomlaimage", { + text: "Joomla Insert image", + context: "insert", + icon: "image", + onclick: function() { + if (imgLink) { + a.windowManager.open({ + title : "Change or upload image", + url : imgLink + a.getContainer().id, + width : 900, + height : 600, + buttons: [{ + text : "Insert", + onclick: function () { + var b = a.windowManager.getWindows()[0]; + a.insertContent("\"\""), b.close() + } + }, { + text : "Close", + onclick: "close" + }] + }) + } + } + }) +}); \ No newline at end of file diff --git a/media/editors/tinymce/plugins/joomlapager/plugin.min.js b/media/editors/tinymce/plugins/joomlapager/plugin.min.js new file mode 100644 index 0000000000000..769573b054ef1 --- /dev/null +++ b/media/editors/tinymce/plugins/joomlapager/plugin.min.js @@ -0,0 +1,38 @@ +tinymce.PluginManager.add("joomlapager", function(a, b) { + a.addButton("joomlapager", { + text: "Joomla", + icon: "copy", + onclick: function() { + if (imgLink) { + a.windowManager.open({ + title : "Joomla Page Break", + url : "index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=" + a.getContainer().id, + width : 900, + height : 600, + buttons: [{ + text : "Close", + onclick: "close" + }] + }) + } + } + }), a.addMenuItem("joomlapager", { + text: "Joomla Page Break", + context: "insert", + icon: "copy", + onclick: function() { + if (imgLink) { + a.windowManager.open({ + title : "Joomla Page Break", + url : "index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=" + a.getContainer().id, + width : 900, + height : 600, + buttons: [{ + text : "Close", + onclick: "close" + }] + }) + } + } + }) +}); \ No newline at end of file diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 63d28c882fa46..f7ffd60c4488e 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -604,6 +604,9 @@ public function onInit() } $toolbar5_add[] = 'joomlabreak'; + $toolbar5_add[] = 'joomlaimage'; + $toolbar5_add[] = 'joomlapager'; + $toolbar5_add[] = 'joomlaarticle'; // Prepare config variables $plugins = implode(',', $plugins); @@ -623,6 +626,19 @@ public function onInit() JUri::root() . $this->_basePath . "/tinymce.min.js\">\n"; + // User check for images ACL + $asset = $this->app->scope; + $user = JFactory::getUser(); + + if ( $user->authorise('core.edit', $this->app->scope) + || $user->authorise('core.create', $this->app->scope) + || (count($user->getAuthorisedCategories($this->app->scope, 'core.create')) > 0) + || (count($user->getAuthorisedCategories($this->app->scope, 'core.edit')) > 0)) + { + $author = $user->id; + $link = JUri::root(true). 'index.php?option=com_media&view=images&tmpl=component&asset=' . $asset . '&author='.$author . '&e_name='; + } + /** * Shrink the buttons if not on a mobile or if mobile view is off. * If mobile view is on force into simple mode and enlarge the buttons @@ -659,6 +675,7 @@ public function onInit() menubar: false, toolbar1: \"bold italics underline strikethrough | undo redo | bullist numlist\", toolbar5: \"$toolbar5\", + plugins : \"joomlabreak, joomlaimage, joomlaarticle, joomlapager\", // Cleanup/Output inline_styles : true, gecko_spellcheck : true, @@ -703,7 +720,7 @@ public function onInit() $smallButtons invalid_elements : \"$invalid_elements\", // Plugins - plugins : \"table link image code hr charmap autolink lists importcss\", + plugins : \"table link image code hr charmap autolink lists importcss, joomlabreak, joomlaimage\", // Toolbar toolbar1: \"$toolbar1\", toolbar2: \"$toolbar2\", @@ -750,7 +767,7 @@ public function onInit() $smallButtons invalid_elements : \"$invalid_elements\", // Plugins - plugins : \"$plugins\", + plugins : \"$plugins, joomlabreak, joomlaimage, joomlapager, joomlaarticle\", // Toolbar toolbar1: \"$toolbar1\", toolbar2: \"$toolbar2\", @@ -790,7 +807,9 @@ public function onInit() }); var hrExists = \"" . - JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\"; + JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\", + imgLink = \"$link\", + toc = \"" . JSession::getFormToken() . "\"; "; break; } From 1ae850b069c13584d494afdbe2d6dead9c75d1d0 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Fri, 12 Jun 2015 03:02:35 +0300 Subject: [PATCH 04/15] disable old buttons use simple for testing buttons Extended for testing menu --- plugins/editors/tinymce/tinymce.php | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index f7ffd60c4488e..5a89bc18e71ef 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -636,7 +636,7 @@ public function onInit() || (count($user->getAuthorisedCategories($this->app->scope, 'core.edit')) > 0)) { $author = $user->id; - $link = JUri::root(true). 'index.php?option=com_media&view=images&tmpl=component&asset=' . $asset . '&author='.$author . '&e_name='; + $link = JUri::root(true). 'index.php?option=com_media&view=images&tmpl=component&asset=' . $asset . '&author=' . $author . '&e_name='; } /** @@ -673,9 +673,8 @@ public function onInit() theme : \"$theme\", schema: \"html5\", menubar: false, - toolbar1: \"bold italics underline strikethrough | undo redo | bullist numlist\", - toolbar5: \"$toolbar5\", - plugins : \"joomlabreak, joomlaimage, joomlaarticle, joomlapager\", + toolbar1: \"bold italics underline strikethrough | undo redo | bullist numlist | $toolbar5 | code \", + plugins : \"code, joomlabreak, joomlaimage, joomlaarticle, joomlapager\", // Cleanup/Output inline_styles : true, gecko_spellcheck : true, @@ -689,8 +688,10 @@ public function onInit() $content_css document_base_url : \"" . JUri::root() . "\" }); - var hrExists = \"" . - JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\"; + var hrExists = \"" . + JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\", + imgLink = \"$link\", + toc = \"" . JSession::getFormToken() . "\"; "; break; @@ -740,7 +741,9 @@ public function onInit() }); var hrExists = \"" . - JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\"; + JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\", + imgLink = \"$link\", + toc = \"" . JSession::getFormToken() . "\"; "; break; @@ -891,7 +894,7 @@ function jInsertEditorText( text, editor ) * * @return string */ - public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null) + public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = false, $id = null, $asset = null, $author = null) { if (empty($id)) { From 17e553f5d05f1adb295b65d901f10a9f825eef1c Mon Sep 17 00:00:00 2001 From: dgt41 Date: Fri, 12 Jun 2015 12:04:38 +0300 Subject: [PATCH 05/15] JS work arounds --- .../views/article/tmpl/pagebreak.php | 4 ++-- .../plugins/joomlaarticle/plugin.min.js | 5 +++-- .../tinymce/plugins/joomlabreak/plugin.min.js | 2 +- .../tinymce/plugins/joomlaimage/plugin.min.js | 5 +++-- plugins/editors/tinymce/tinymce.php | 19 +++++++++++++++++-- 5 files changed, 26 insertions(+), 9 deletions(-) diff --git a/administrator/components/com_content/views/article/tmpl/pagebreak.php b/administrator/components/com_content/views/article/tmpl/pagebreak.php index 1a868afc5f80a..d6150e0e61e46 100644 --- a/administrator/components/com_content/views/article/tmpl/pagebreak.php +++ b/administrator/components/com_content/views/article/tmpl/pagebreak.php @@ -24,8 +24,8 @@ $script .= 'alt = "alt=\""+alt+"\" ";' . "\n\t"; $script .= '}' . "\n\t"; $script .= 'var tag = "
";' . "\n\t"; -$script .= 'window.parent.jInsertEditorText(tag, ' . json_encode($this->eName) . ');' . "\n\t"; -$script .= 'window.parent.jModalClose();' . "\n\t"; +$script .= 'tinymce.activeEditor.insertContent(tag);' . "\n\t"; +$script .= 'tinymce.activeEditor.windowManager.close();' . "\n\t"; $script .= 'return false;' . "\n"; $script .= '}' . "\n"; diff --git a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js index 06ef34cee9f1e..26b15f31554b9 100644 --- a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js @@ -1,6 +1,7 @@ tinymce.PluginManager.add("joomlaarticle", function(a, b) { a.addButton("joomlaarticle", { - text: "Joomla", + text: 'Joomla!', + title: "Joomla Insert Article", icon: "new", onclick: function() { if (imgLink) { @@ -17,7 +18,7 @@ tinymce.PluginManager.add("joomlaarticle", function(a, b) { } } }), a.addMenuItem("joomlaarticle", { - text: "Joomla Select Article", + text: "Joomla Insert Article", context: "insert", icon: "new", onclick: function() { diff --git a/media/editors/tinymce/plugins/joomlabreak/plugin.min.js b/media/editors/tinymce/plugins/joomlabreak/plugin.min.js index dbafeb2f2e768..575470e907a40 100644 --- a/media/editors/tinymce/plugins/joomlabreak/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlabreak/plugin.min.js @@ -13,8 +13,8 @@ tinymce.PluginManager.add("joomlabreak", function(a) { } }), a.addButton("joomlabreak", { text: 'Joomla!', - icon: 'pagebreak', title: "Joomla Read More", + icon: 'pagebreak', cmd: "mceJoomlaBreak" }), a.addMenuItem("joomlabreak", { text: "Joomla Read More", diff --git a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js index d2ba5116cde36..f2270293f4e04 100644 --- a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js @@ -1,6 +1,7 @@ tinymce.PluginManager.add("joomlaimage", function(a, b) { a.addButton("joomlaimage", { - text: "Joomla", + text: 'Joomla!', + title: "Joomla Insert Image", icon: "image", onclick: function() { if (imgLink) { @@ -23,7 +24,7 @@ tinymce.PluginManager.add("joomlaimage", function(a, b) { } } }), a.addMenuItem("joomlaimage", { - text: "Joomla Insert image", + title: "Joomla Insert Image", context: "insert", icon: "image", onclick: function() { diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 5a89bc18e71ef..069dbf5d898a2 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -924,10 +924,25 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $editor = '
'; $editor .= JLayoutHelper::render('joomla.tinymce.textarea', $textarea); - $editor .= $this->_displayButtons($id, $buttons, $asset, $author); - $editor .= $this->_toogleButton($id); +// $editor .= $this->_displayButtons($id, $buttons, $asset, $author); +// $editor .= $this->_toogleButton($id); $editor .= '
'; + // Article + JFactory::getDocument()->addScriptDeclaration(" + function jSelectArticle(id, title, catid, object, link, lang) + { + var hreflang = ''; + if (lang !== '') + { + var hreflang = ' hreflang = \"' + lang + '\"'; + } + var tag = '' + title + ''; + tinymce.activeEditor.insertContent(tag); + tinymce.activeEditor.windowManager.close(); + } + "); + return $editor; } From 37dc4d01cfc5495009943bd86affc9c8bd871515 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 00:17:43 +0300 Subject: [PATCH 06/15] page break --- media/editors/tinymce/plugins/joomlapager/index.html | 9 +++++++++ .../tinymce/plugins/joomlapager/plugin.min.js | 12 +++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 media/editors/tinymce/plugins/joomlapager/index.html diff --git a/media/editors/tinymce/plugins/joomlapager/index.html b/media/editors/tinymce/plugins/joomlapager/index.html new file mode 100644 index 0000000000000..aed37a437867d --- /dev/null +++ b/media/editors/tinymce/plugins/joomlapager/index.html @@ -0,0 +1,9 @@ + + + +

Page Break

+ The title of the page: + The alternative title of the page: + + + \ No newline at end of file diff --git a/media/editors/tinymce/plugins/joomlapager/plugin.min.js b/media/editors/tinymce/plugins/joomlapager/plugin.min.js index 769573b054ef1..8c450e1299d4e 100644 --- a/media/editors/tinymce/plugins/joomlapager/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlapager/plugin.min.js @@ -6,10 +6,16 @@ tinymce.PluginManager.add("joomlapager", function(a, b) { if (imgLink) { a.windowManager.open({ title : "Joomla Page Break", - url : "index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=" + a.getContainer().id, - width : 900, - height : 600, + url : b + "/index.html", + width : 300, + height : 200, buttons: [{ + text : "Insert", + onclick: function () { + var b = a.windowManager.getWindows()[0]; + a.insertContent("
"), b.close() + } + }, { text : "Close", onclick: "close" }] From e0a258bdb092167d16caecf3dda64427541bbeb9 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 02:50:40 +0300 Subject: [PATCH 07/15] Respect the other buttons --- .../views/article/tmpl/pagebreak.php | 4 +- .../com_media/views/images/tmpl/default.php | 2 + .../tinymce/plugins/example/dialog.html | 0 .../plugins/joomlaarticle/plugin.min.js | 6 +-- .../tinymce/plugins/joomlaimage/plugin.min.js | 2 +- .../{joomlabreak => joomlamore}/plugin.min.js | 14 ++--- .../tinymce/plugins/joomlapager/index.html | 8 +-- .../tinymce/plugins/joomlapager/plugin.min.js | 34 ++++++++---- plugins/editors/tinymce/tinymce.php | 53 ++++++++++++++++--- 9 files changed, 88 insertions(+), 35 deletions(-) create mode 100644 media/editors/tinymce/plugins/example/dialog.html rename media/editors/tinymce/plugins/{joomlabreak => joomlamore}/plugin.min.js (59%) diff --git a/administrator/components/com_content/views/article/tmpl/pagebreak.php b/administrator/components/com_content/views/article/tmpl/pagebreak.php index d6150e0e61e46..1a868afc5f80a 100644 --- a/administrator/components/com_content/views/article/tmpl/pagebreak.php +++ b/administrator/components/com_content/views/article/tmpl/pagebreak.php @@ -24,8 +24,8 @@ $script .= 'alt = "alt=\""+alt+"\" ";' . "\n\t"; $script .= '}' . "\n\t"; $script .= 'var tag = "
";' . "\n\t"; -$script .= 'tinymce.activeEditor.insertContent(tag);' . "\n\t"; -$script .= 'tinymce.activeEditor.windowManager.close();' . "\n\t"; +$script .= 'window.parent.jInsertEditorText(tag, ' . json_encode($this->eName) . ');' . "\n\t"; +$script .= 'window.parent.jModalClose();' . "\n\t"; $script .= 'return false;' . "\n"; $script .= '}' . "\n"; diff --git a/administrator/components/com_media/views/images/tmpl/default.php b/administrator/components/com_media/views/images/tmpl/default.php index 71faee78f26e6..7e3734b725750 100644 --- a/administrator/components/com_media/views/images/tmpl/default.php +++ b/administrator/components/com_media/views/images/tmpl/default.php @@ -36,10 +36,12 @@ + getCmd('tiny') != 1):?>
+ diff --git a/media/editors/tinymce/plugins/example/dialog.html b/media/editors/tinymce/plugins/example/dialog.html new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js index 26b15f31554b9..7bf52261eda2c 100644 --- a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js @@ -1,8 +1,8 @@ tinymce.PluginManager.add("joomlaarticle", function(a, b) { a.addButton("joomlaarticle", { - text: 'Joomla!', + text: 'J Article', title: "Joomla Insert Article", - icon: "new", + icon: "newdocument", onclick: function() { if (imgLink) { a.windowManager.open({ @@ -20,7 +20,7 @@ tinymce.PluginManager.add("joomlaarticle", function(a, b) { }), a.addMenuItem("joomlaarticle", { text: "Joomla Insert Article", context: "insert", - icon: "new", + icon: "newdocument", onclick: function() { if (imgLink) { a.windowManager.open({ diff --git a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js index f2270293f4e04..4953c5f6fae40 100644 --- a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js @@ -1,6 +1,6 @@ tinymce.PluginManager.add("joomlaimage", function(a, b) { a.addButton("joomlaimage", { - text: 'Joomla!', + text: 'J Image', title: "Joomla Insert Image", icon: "image", onclick: function() { diff --git a/media/editors/tinymce/plugins/joomlabreak/plugin.min.js b/media/editors/tinymce/plugins/joomlamore/plugin.min.js similarity index 59% rename from media/editors/tinymce/plugins/joomlabreak/plugin.min.js rename to media/editors/tinymce/plugins/joomlamore/plugin.min.js index 575470e907a40..57abea2ea5114 100644 --- a/media/editors/tinymce/plugins/joomlabreak/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlamore/plugin.min.js @@ -1,5 +1,5 @@ -tinymce.PluginManager.add("joomlabreak", function(a) { - a.addCommand("mceJoomlaBreak", function() { +tinymce.PluginManager.add("joomlamore", function(a) { + a.addCommand("mceJoomlaMore", function() { var myRe = /"); } - }), a.addButton("joomlabreak", { - text: 'Joomla!', + }), a.addButton("joomlamore", { + text: 'J Read More', title: "Joomla Read More", icon: 'pagebreak', - cmd: "mceJoomlaBreak" - }), a.addMenuItem("joomlabreak", { + cmd: "mceJoomlaMore" + }), a.addMenuItem("joomlamore", { text: "Joomla Read More", icon: "pagebreak", - cmd: "mceJoomlaBreak", + cmd: "mceJoomlaMore", context: "insert" }) }); diff --git a/media/editors/tinymce/plugins/joomlapager/index.html b/media/editors/tinymce/plugins/joomlapager/index.html index aed37a437867d..7b6a40c4053c1 100644 --- a/media/editors/tinymce/plugins/joomlapager/index.html +++ b/media/editors/tinymce/plugins/joomlapager/index.html @@ -1,9 +1,9 @@ -

Page Break

- The title of the page: - The alternative title of the page: - +

The title: +

+

The alternative: +

\ No newline at end of file diff --git a/media/editors/tinymce/plugins/joomlapager/plugin.min.js b/media/editors/tinymce/plugins/joomlapager/plugin.min.js index 8c450e1299d4e..381685d7f636c 100644 --- a/media/editors/tinymce/plugins/joomlapager/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlapager/plugin.min.js @@ -1,9 +1,9 @@ tinymce.PluginManager.add("joomlapager", function(a, b) { a.addButton("joomlapager", { - text: "Joomla", + text: "J Page Break", + title: "Joomla Page Break", icon: "copy", onclick: function() { - if (imgLink) { a.windowManager.open({ title : "Joomla Page Break", url : b + "/index.html", @@ -13,32 +13,44 @@ tinymce.PluginManager.add("joomlapager", function(a, b) { text : "Insert", onclick: function () { var b = a.windowManager.getWindows()[0]; - a.insertContent("
"), b.close() + a.insertContent('
'), + b.close() } - }, { - text : "Close", - onclick: "close" - }] + }, + { + text : "Close", + onclick: "close" + }] }) } - } - }), a.addMenuItem("joomlapager", { + }), + a.addMenuItem("joomlapager", { text: "Joomla Page Break", context: "insert", icon: "copy", onclick: function() { - if (imgLink) { a.windowManager.open({ title : "Joomla Page Break", url : "index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=" + a.getContainer().id, width : 900, height : 600, buttons: [{ + text : "Insert", + onclick: function () { + var b = a.windowManager.getWindows()[0]; + a.insertContent('
'), + b.close() + } + }, + { text : "Close", onclick: "close" }] }) - } } }) }); \ No newline at end of file diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 069dbf5d898a2..a404a519245b9 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -603,7 +603,7 @@ public function onInit() $toolbar4_add[] = $custom_button; } - $toolbar5_add[] = 'joomlabreak'; + $toolbar5_add[] = 'joomlamore'; $toolbar5_add[] = 'joomlaimage'; $toolbar5_add[] = 'joomlapager'; $toolbar5_add[] = 'joomlaarticle'; @@ -636,7 +636,7 @@ public function onInit() || (count($user->getAuthorisedCategories($this->app->scope, 'core.edit')) > 0)) { $author = $user->id; - $link = JUri::root(true). 'index.php?option=com_media&view=images&tmpl=component&asset=' . $asset . '&author=' . $author . '&e_name='; + $link = JUri::root(true). 'index.php?option=com_media&view=images&tmpl=component&asset=' . $asset . '&author=' . $author . '&tiny=1&e_name='; } /** @@ -674,7 +674,7 @@ public function onInit() schema: \"html5\", menubar: false, toolbar1: \"bold italics underline strikethrough | undo redo | bullist numlist | $toolbar5 | code \", - plugins : \"code, joomlabreak, joomlaimage, joomlaarticle, joomlapager\", + plugins : \"code, joomlamore, joomlaimage, joomlaarticle, joomlapager\", // Cleanup/Output inline_styles : true, gecko_spellcheck : true, @@ -721,7 +721,7 @@ public function onInit() $smallButtons invalid_elements : \"$invalid_elements\", // Plugins - plugins : \"table link image code hr charmap autolink lists importcss, joomlabreak, joomlaimage\", + plugins : \"table link image code hr charmap autolink lists importcss, joomlamore, joomlaimage\", // Toolbar toolbar1: \"$toolbar1\", toolbar2: \"$toolbar2\", @@ -770,7 +770,7 @@ public function onInit() $smallButtons invalid_elements : \"$invalid_elements\", // Plugins - plugins : \"$plugins, joomlabreak, joomlaimage, joomlapager, joomlaarticle\", + plugins : \"$plugins, joomlamore, joomlaimage, joomlapager, joomlaarticle\", // Toolbar toolbar1: \"$toolbar1\", toolbar2: \"$toolbar2\", @@ -924,7 +924,7 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $editor = '
'; $editor .= JLayoutHelper::render('joomla.tinymce.textarea', $textarea); -// $editor .= $this->_displayButtons($id, $buttons, $asset, $author); + $editor .= $this->_displayButtons($id, $buttons, $asset, $author); // $editor .= $this->_toogleButton($id); $editor .= '
'; @@ -982,12 +982,51 @@ private function _displayButtons($name, $buttons, $asset, $author) { $buttons = $this->_subject->getButtons($name, $buttons, $asset, $author); - $return .= JLayoutHelper::render('joomla.editors.buttons', $buttons); + foreach ($buttons as $button) + { + $but[] = get_object_vars($button); + } + + foreach ($but as $butt) + { + if (in_array($butt['text'], array('Article', 'Page Break', 'Read More', 'Image', 'Toggle'))) + { + $but = $this->removeElementWithValue($but, "text", $butt['text']); + } + else + { + $nbutt[] = json_decode(json_encode($butt), FALSE); + } + } + + + if ((isset($nbutt) && is_array($nbutt)) || + (isset($nbutt) && (is_bool($nbutt) && $nbutt))) + { + $return .= JLayoutHelper::render('joomla.editors.buttons', $nbutt); + } } return $return; } + /** + * Array helper funtion to remove specific arrays by key-value + * + * @param $array array the parent array + * @param $key string the key + * @param $value string the value + * + * @return mixed + */ + private function removeElementWithValue($array, $key, $value){ + foreach($array as $subKey => $subArray){ + if($subArray[$key] == $value){ + unset($array[$subKey]); + } + } + return $array; + } /** * Get the toggle editor button * From 2f2b0d3b3b2e2869ac78abe4b6688d91d8c078e5 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 03:01:21 +0300 Subject: [PATCH 08/15] house keeping --- media/editors/tinymce/plugins/example/dialog.html | 8 ++++++++ .../tinymce/plugins/joomlaarticle/plugin.min.js | 13 ++++++++++++- plugins/editors/tinymce/tinymce.php | 15 --------------- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/media/editors/tinymce/plugins/example/dialog.html b/media/editors/tinymce/plugins/example/dialog.html index e69de29bb2d1d..4630d405a638a 100644 --- a/media/editors/tinymce/plugins/example/dialog.html +++ b/media/editors/tinymce/plugins/example/dialog.html @@ -0,0 +1,8 @@ + + + +

Custom dialog

+ Input some text: + + + diff --git a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js index 7bf52261eda2c..8a0a7b2eea1fc 100644 --- a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js @@ -36,4 +36,15 @@ tinymce.PluginManager.add("joomlaarticle", function(a, b) { } } }) -}); \ No newline at end of file +}); +function jSelectArticle(id, title, catid, object, link, lang) +{ + var hreflang = ''; + if (lang !== '') + { + var hreflang = ' hreflang = \"' + lang + '\"'; + } + var tag = '' + title + ''; + tinymce.activeEditor.insertContent(tag); + tinymce.activeEditor.windowManager.close(); +} \ No newline at end of file diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index a404a519245b9..3da49ea01b6ad 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -928,21 +928,6 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons // $editor .= $this->_toogleButton($id); $editor .= ''; - // Article - JFactory::getDocument()->addScriptDeclaration(" - function jSelectArticle(id, title, catid, object, link, lang) - { - var hreflang = ''; - if (lang !== '') - { - var hreflang = ' hreflang = \"' + lang + '\"'; - } - var tag = '' + title + ''; - tinymce.activeEditor.insertContent(tag); - tinymce.activeEditor.windowManager.close(); - } - "); - return $editor; } From eb1964600a97b29051f437d1e37fa863c18b9ba4 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 03:55:53 +0300 Subject: [PATCH 09/15] Jobject needs to be --- plugins/editors/tinymce/tinymce.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 3da49ea01b6ad..3a4732503cd38 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -980,7 +980,16 @@ private function _displayButtons($name, $buttons, $asset, $author) } else { - $nbutt[] = json_decode(json_encode($butt), FALSE); + + $butt2 = new JObject; + $butt2->modal = $butt['modal']; + $butt2->class = $butt['class']; + $butt2->link = $butt['link']; + $butt2->text = $butt['text']; + $butt2->name = $butt['name']; + $butt2->options = $butt['options']; + + $nbutt[] = $butt2; } } From 2888db7867ad9c90f0dc70b6d4e118732e51f232 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 05:05:00 +0300 Subject: [PATCH 10/15] toolbar sanity --- plugins/editors/tinymce/tinymce.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 3a4732503cd38..632abc1f51351 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -607,9 +607,10 @@ public function onInit() $toolbar5_add[] = 'joomlaimage'; $toolbar5_add[] = 'joomlapager'; $toolbar5_add[] = 'joomlaarticle'; + $toolbar5_add[] = '| code'; // Prepare config variables - $plugins = implode(',', $plugins); + $plugins = implode(' ', $plugins); $elements = implode(',', $elements); // Prepare config variables @@ -673,7 +674,7 @@ public function onInit() theme : \"$theme\", schema: \"html5\", menubar: false, - toolbar1: \"bold italics underline strikethrough | undo redo | bullist numlist | $toolbar5 | code \", + toolbar1: \"bold italics underline strikethrough | undo redo | bullist numlist | $toolbar5\", plugins : \"code, joomlamore, joomlaimage, joomlaarticle, joomlapager\", // Cleanup/Output inline_styles : true, @@ -721,11 +722,11 @@ public function onInit() $smallButtons invalid_elements : \"$invalid_elements\", // Plugins - plugins : \"table link image code hr charmap autolink lists importcss, joomlamore, joomlaimage\", + plugins : \"table link image code hr charmap autolink lists importcss code joomlamore joomlaimage joomlaarticle joomlapager\", // Toolbar toolbar1: \"$toolbar1\", toolbar2: \"$toolbar2\", - toolbar5: \"$toolbar5\", + toolbar3: \"$toolbar5\", removed_menuitems: \"newdocument\", // URL relative_urls : $relative_urls, @@ -770,13 +771,12 @@ public function onInit() $smallButtons invalid_elements : \"$invalid_elements\", // Plugins - plugins : \"$plugins, joomlamore, joomlaimage, joomlapager, joomlaarticle\", + plugins : \"$plugins, code joomlamore joomlaimage joomlaarticle joomlapager\", // Toolbar toolbar1: \"$toolbar1\", toolbar2: \"$toolbar2\", toolbar3: \"$toolbar3\", - toolbar4: \"$toolbar4\", - toolbar5: \"$toolbar5\", + toolbar4: \"$toolbar4 | $toolbar5\", removed_menuitems: \"newdocument\", // URL relative_urls : $relative_urls, From c640fbdb1da7e9658f086aaf267618a7ed434d3f Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 05:42:17 +0300 Subject: [PATCH 11/15] CS --- .../tinymce/plugins/joomlapager/plugin.min.js | 78 +++++++++---------- plugins/editors/tinymce/tinymce.php | 28 +++---- 2 files changed, 50 insertions(+), 56 deletions(-) diff --git a/media/editors/tinymce/plugins/joomlapager/plugin.min.js b/media/editors/tinymce/plugins/joomlapager/plugin.min.js index 381685d7f636c..b4a4611c0be9c 100644 --- a/media/editors/tinymce/plugins/joomlapager/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlapager/plugin.min.js @@ -3,54 +3,46 @@ tinymce.PluginManager.add("joomlapager", function(a, b) { text: "J Page Break", title: "Joomla Page Break", icon: "copy", - onclick: function() { - a.windowManager.open({ - title : "Joomla Page Break", - url : b + "/index.html", - width : 300, - height : 200, - buttons: [{ - text : "Insert", - onclick: function () { - var b = a.windowManager.getWindows()[0]; - a.insertContent('
'), - b.close() - } - }, + onclick: function () { + a.windowManager.open({ + title : 'Page Break', + body : [{ + type : 'textbox', + name : 'title', + label: 'Title:' + }, { - text : "Close", - onclick: "close" - }] - }) - } + type : 'textbox', + name : 'id', + label: 'Alternative:' + }], + onsubmit: function (e) { + a.insertContent('
'); + } + }); + } }), a.addMenuItem("joomlapager", { - text: "Joomla Page Break", - context: "insert", + text: "J Page Break", + title: "Joomla Page Break", icon: "copy", - onclick: function() { - a.windowManager.open({ - title : "Joomla Page Break", - url : "index.php?option=com_content&view=article&layout=pagebreak&tmpl=component&e_name=" + a.getContainer().id, - width : 900, - height : 600, - buttons: [{ - text : "Insert", - onclick: function () { - var b = a.windowManager.getWindows()[0]; - a.insertContent('
'), - b.close() - } - }, + onclick: function () { + a.windowManager.open({ + title : 'Page Break', + body : [{ + type : 'textbox', + name : 'title', + label: 'Title:' + }, { - text : "Close", - onclick: "close" - }] - }) + type : 'textbox', + name : 'id', + label: 'Alternative:' + }], + onsubmit: function (e) { + a.insertContent('
'); + } + }); } }) }); \ No newline at end of file diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 632abc1f51351..f8f2eacce6369 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -637,7 +637,9 @@ public function onInit() || (count($user->getAuthorisedCategories($this->app->scope, 'core.edit')) > 0)) { $author = $user->id; - $link = JUri::root(true). 'index.php?option=com_media&view=images&tmpl=component&asset=' . $asset . '&author=' . $author . '&tiny=1&e_name='; + $link = JUri::root(true) . + 'index.php?option=com_media&view=images&tmpl=component&asset=' . + $asset . '&author=' . $author . '&tiny=1&e_name='; } /** @@ -925,7 +927,6 @@ public function onDisplay($name, $content, $width, $height, $col, $row, $buttons $editor = '
'; $editor .= JLayoutHelper::render('joomla.tinymce.textarea', $textarea); $editor .= $this->_displayButtons($id, $buttons, $asset, $author); -// $editor .= $this->_toogleButton($id); $editor .= '
'; return $editor; @@ -980,7 +981,6 @@ private function _displayButtons($name, $buttons, $asset, $author) } else { - $butt2 = new JObject; $butt2->modal = $butt['modal']; $butt2->class = $butt['class']; @@ -993,9 +993,7 @@ private function _displayButtons($name, $buttons, $asset, $author) } } - - if ((isset($nbutt) && is_array($nbutt)) || - (isset($nbutt) && (is_bool($nbutt) && $nbutt))) + if ((isset($nbutt) && is_array($nbutt)) || (isset($nbutt) && (is_bool($nbutt) && $nbutt))) { $return .= JLayoutHelper::render('joomla.editors.buttons', $nbutt); } @@ -1007,20 +1005,24 @@ private function _displayButtons($name, $buttons, $asset, $author) /** * Array helper funtion to remove specific arrays by key-value * - * @param $array array the parent array - * @param $key string the key - * @param $value string the value + * @param array $array the parent array + * @param string $key the key + * @param string $value the value * - * @return mixed + * @return array */ - private function removeElementWithValue($array, $key, $value){ - foreach($array as $subKey => $subArray){ - if($subArray[$key] == $value){ + private function removeElementWithValue($array, $key, $value) + { + foreach ($array as $subKey => $subArray) + { + if ($subArray[$key] == $value) + { unset($array[$subKey]); } } return $array; } + /** * Get the toggle editor button * From d680301a7df67e36ecca97fcb67dc7e20e1e5ba4 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 06:31:11 +0300 Subject: [PATCH 12/15] Should work on all laguages --- .../tinymce/plugins/joomlapager/index.html | 9 --------- plugins/editors/tinymce/tinymce.php | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 12 deletions(-) delete mode 100644 media/editors/tinymce/plugins/joomlapager/index.html diff --git a/media/editors/tinymce/plugins/joomlapager/index.html b/media/editors/tinymce/plugins/joomlapager/index.html deleted file mode 100644 index 7b6a40c4053c1..0000000000000 --- a/media/editors/tinymce/plugins/joomlapager/index.html +++ /dev/null @@ -1,9 +0,0 @@ - - - -

The title: -

-

The alternative: -

- - \ No newline at end of file diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index f8f2eacce6369..e0081eece64b9 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -973,9 +973,20 @@ private function _displayButtons($name, $buttons, $asset, $author) $but[] = get_object_vars($button); } + // Load the lang strings for the buttons + $lang = JFactory::getLanguage(); + $lang->load('plg_editors-xtd_article', JPATH_ADMINISTRATOR, $lang->getTag(), true); + $lang->load('plg_editors-xtd_image', JPATH_ADMINISTRATOR, $lang->getTag(), true); + $lang->load('plg_editors-xtd_pagebreak', JPATH_ADMINISTRATOR, $lang->getTag(), true); + $lang->load('plg_editors-xtd_readmore', JPATH_ADMINISTRATOR, $lang->getTag(), true); + $trArticle = JText::_('PLG_ARTICLE_BUTTON_ARTICLE'); + $trBreak = JText::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK'); + $trImage = JText::_('PLG_IMAGE_BUTTON_IMAGE'); + $trMore = JText::_('PLG_READMORE_BUTTON_READMORE'); + foreach ($but as $butt) { - if (in_array($butt['text'], array('Article', 'Page Break', 'Read More', 'Image', 'Toggle'))) + if (in_array($butt['text'], array($trArticle, $trBreak, $trImage, $trMore))) { $but = $this->removeElementWithValue($but, "text", $butt['text']); } @@ -987,8 +998,10 @@ private function _displayButtons($name, $buttons, $asset, $author) $butt2->link = $butt['link']; $butt2->text = $butt['text']; $butt2->name = $butt['name']; - $butt2->options = $butt['options']; - + if (isset($butt['options'])) + { + $butt2->options = $butt['options']; + } $nbutt[] = $butt2; } } From ad740583ee5e9e0debf9b0b04106d2ffc85104a2 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 13:16:16 +0300 Subject: [PATCH 13/15] naming vars --- .../plugins/joomlaarticle/plugin.min.js | 10 ++++----- .../tinymce/plugins/joomlaimage/plugin.min.js | 22 +++++++++---------- .../tinymce/plugins/joomlamore/plugin.min.js | 12 +++++----- .../tinymce/plugins/joomlapager/plugin.min.js | 14 ++++++------ 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js index 8a0a7b2eea1fc..eded1b3144297 100644 --- a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js @@ -1,11 +1,11 @@ -tinymce.PluginManager.add("joomlaarticle", function(a, b) { - a.addButton("joomlaarticle", { +tinymce.PluginManager.add("joomlaarticle", function(editor, url) { + editor.addButton("joomlaarticle", { text: 'J Article', title: "Joomla Insert Article", icon: "newdocument", onclick: function() { if (imgLink) { - a.windowManager.open({ + editor.windowManager.open({ title : "Joomla Select Article", url : 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&' + toc + '=1', width : 900, @@ -17,13 +17,13 @@ tinymce.PluginManager.add("joomlaarticle", function(a, b) { }) } } - }), a.addMenuItem("joomlaarticle", { + }), editor.addMenuItem("joomlaarticle", { text: "Joomla Insert Article", context: "insert", icon: "newdocument", onclick: function() { if (imgLink) { - a.windowManager.open({ + editor.windowManager.open({ title : "Joomla Select Article", url : 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&' + toc + '=1', width : 900, diff --git a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js index 4953c5f6fae40..f5ea9ce44478c 100644 --- a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js @@ -1,20 +1,20 @@ -tinymce.PluginManager.add("joomlaimage", function(a, b) { - a.addButton("joomlaimage", { +tinymce.PluginManager.add("joomlaimage", function(editor, url) { + editor.addButton("joomlaimage", { text: 'J Image', title: "Joomla Insert Image", icon: "image", onclick: function() { if (imgLink) { - a.windowManager.open({ + editor.windowManager.open({ title : "Change or upload image", - url : imgLink + a.getContainer().id, + url : imgLink + editor.getContainer().id, width : 900, height : 600, buttons: [{ text : "Insert", onclick: function () { - var b = a.windowManager.getWindows()[0]; - a.insertContent("\"\""), b.close() + var url = editor.windowManager.getWindows()[0]; + editor.insertContent("\"\""), url.close() } }, { text : "Close", @@ -23,22 +23,22 @@ tinymce.PluginManager.add("joomlaimage", function(a, b) { }) } } - }), a.addMenuItem("joomlaimage", { + }), editor.addMenuItem("joomlaimage", { title: "Joomla Insert Image", context: "insert", icon: "image", onclick: function() { if (imgLink) { - a.windowManager.open({ + editor.windowManager.open({ title : "Change or upload image", - url : imgLink + a.getContainer().id, + url : imgLink + editor.getContainer().id, width : 900, height : 600, buttons: [{ text : "Insert", onclick: function () { - var b = a.windowManager.getWindows()[0]; - a.insertContent("\"\""), b.close() + var url = editor.windowManager.getWindows()[0]; + editor.insertContent("\"\""), url.close() } }, { text : "Close", diff --git a/media/editors/tinymce/plugins/joomlamore/plugin.min.js b/media/editors/tinymce/plugins/joomlamore/plugin.min.js index 57abea2ea5114..cbf3789c28c22 100644 --- a/media/editors/tinymce/plugins/joomlamore/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlamore/plugin.min.js @@ -1,7 +1,7 @@ -tinymce.PluginManager.add("joomlamore", function(a) { - a.addCommand("mceJoomlaMore", function() { +tinymce.PluginManager.add("joomlamore", function(editor) { + editor.addCommand("mceJoomlaMore", function() { var myRe = /"); + editor.insertContent("
"); } - }), a.addButton("joomlamore", { + }), editor.addButton("joomlamore", { text: 'J Read More', title: "Joomla Read More", icon: 'pagebreak', cmd: "mceJoomlaMore" - }), a.addMenuItem("joomlamore", { + }), editor.addMenuItem("joomlamore", { text: "Joomla Read More", icon: "pagebreak", cmd: "mceJoomlaMore", diff --git a/media/editors/tinymce/plugins/joomlapager/plugin.min.js b/media/editors/tinymce/plugins/joomlapager/plugin.min.js index b4a4611c0be9c..98f60e0eaf962 100644 --- a/media/editors/tinymce/plugins/joomlapager/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlapager/plugin.min.js @@ -1,10 +1,10 @@ -tinymce.PluginManager.add("joomlapager", function(a, b) { - a.addButton("joomlapager", { +tinymce.PluginManager.add("joomlapager", function(editor, url) { + editor.addButton("joomlapager", { text: "J Page Break", title: "Joomla Page Break", icon: "copy", onclick: function () { - a.windowManager.open({ + editor.windowManager.open({ title : 'Page Break', body : [{ type : 'textbox', @@ -17,17 +17,17 @@ tinymce.PluginManager.add("joomlapager", function(a, b) { label: 'Alternative:' }], onsubmit: function (e) { - a.insertContent('
'); + editor.insertContent('
'); } }); } }), - a.addMenuItem("joomlapager", { + editor.addMenuItem("joomlapager", { text: "J Page Break", title: "Joomla Page Break", icon: "copy", onclick: function () { - a.windowManager.open({ + editor.windowManager.open({ title : 'Page Break', body : [{ type : 'textbox', @@ -40,7 +40,7 @@ tinymce.PluginManager.add("joomlapager", function(a, b) { label: 'Alternative:' }], onsubmit: function (e) { - a.insertContent('
'); + editor.insertContent('
'); } }); } From 53661eeb83a5ff003d60b2df3a8acc54a4947cb8 Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 13:22:04 +0300 Subject: [PATCH 14/15] Drop the menus --- .../plugins/joomlaarticle/plugin.min.js | 18 -------------- .../tinymce/plugins/joomlaimage/plugin.min.js | 24 ------------------- .../tinymce/plugins/joomlapager/plugin.min.js | 23 ------------------ 3 files changed, 65 deletions(-) diff --git a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js index eded1b3144297..ca60b29a04624 100644 --- a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js @@ -17,24 +17,6 @@ tinymce.PluginManager.add("joomlaarticle", function(editor, url) { }) } } - }), editor.addMenuItem("joomlaarticle", { - text: "Joomla Insert Article", - context: "insert", - icon: "newdocument", - onclick: function() { - if (imgLink) { - editor.windowManager.open({ - title : "Joomla Select Article", - url : 'index.php?option=com_content&view=articles&layout=modal&tmpl=component&' + toc + '=1', - width : 900, - height : 600, - buttons: [{ - text : "Close", - onclick: "close" - }] - }) - } - } }) }); function jSelectArticle(id, title, catid, object, link, lang) diff --git a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js index f5ea9ce44478c..ac24584dea927 100644 --- a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js @@ -23,29 +23,5 @@ tinymce.PluginManager.add("joomlaimage", function(editor, url) { }) } } - }), editor.addMenuItem("joomlaimage", { - title: "Joomla Insert Image", - context: "insert", - icon: "image", - onclick: function() { - if (imgLink) { - editor.windowManager.open({ - title : "Change or upload image", - url : imgLink + editor.getContainer().id, - width : 900, - height : 600, - buttons: [{ - text : "Insert", - onclick: function () { - var url = editor.windowManager.getWindows()[0]; - editor.insertContent("\"\""), url.close() - } - }, { - text : "Close", - onclick: "close" - }] - }) - } - } }) }); \ No newline at end of file diff --git a/media/editors/tinymce/plugins/joomlapager/plugin.min.js b/media/editors/tinymce/plugins/joomlapager/plugin.min.js index 98f60e0eaf962..877853197e2c9 100644 --- a/media/editors/tinymce/plugins/joomlapager/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlapager/plugin.min.js @@ -21,28 +21,5 @@ tinymce.PluginManager.add("joomlapager", function(editor, url) { } }); } - }), - editor.addMenuItem("joomlapager", { - text: "J Page Break", - title: "Joomla Page Break", - icon: "copy", - onclick: function () { - editor.windowManager.open({ - title : 'Page Break', - body : [{ - type : 'textbox', - name : 'title', - label: 'Title:' - }, - { - type : 'textbox', - name : 'id', - label: 'Alternative:' - }], - onsubmit: function (e) { - editor.insertContent('
'); - } - }); - } }) }); \ No newline at end of file From 5a3b6d027163afdd5b4b4ae6c8addd2e9ded908d Mon Sep 17 00:00:00 2001 From: dgt41 Date: Sat, 13 Jun 2015 13:32:42 +0300 Subject: [PATCH 15/15] Remove duplicate strings --- .../language/en-GB/en-GB.plg_editors_tinymce.ini | 3 +-- media/editors/tinymce/plugins/example/dialog.html | 2 +- .../tinymce/plugins/joomlaarticle/plugin.min.js | 3 ++- .../tinymce/plugins/joomlaimage/plugin.min.js | 2 +- .../tinymce/plugins/joomlapager/plugin.min.js | 2 +- plugins/editors/tinymce/tinymce.php | 14 ++++++++------ 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini b/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini index d241f5fe64d3f..bb9bf4a1a47c3 100644 --- a/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini +++ b/administrator/language/en-GB/en-GB.plg_editors_tinymce.ini @@ -126,9 +126,8 @@ PLG_TINY_FIELD_VISUALBLOCKS_DESC="See the outline of HTML block elements." PLG_TINY_FIELD_VISUALBLOCKS_LABEL="Visualblocks" PLG_TINY_FIELD_WORDCOUNT_DESC="Turn on/off Wordcount." PLG_TINY_FIELD_WORDCOUNT_LABEL="Wordcount" -PLG_TINY_READMORE_ALREADY_EXISTS="There is already a Read more ... link that has been inserted. Only one link is permitted. Use {pagebreak} to split the page up further." PLG_TINY_TEMPLATE_LAYOUT1_DESC="HTML layout." PLG_TINY_TEMPLATE_LAYOUT1_TITLE="Layout" PLG_TINY_TEMPLATE_SNIPPET1_DESC="Simple HTML snippet." PLG_TINY_TEMPLATE_SNIPPET1_TITLE="Simple Snippet" -PLG_TINY_XML_DESCRIPTION="TinyMCE is a platform independent web based JavaScript HTML WYSIWYG Editor." +PLG_TINY_XML_DESCRIPTION="TinyMCE is a platform independent web based JavaScript HTML WYSIWYG Editor." \ No newline at end of file diff --git a/media/editors/tinymce/plugins/example/dialog.html b/media/editors/tinymce/plugins/example/dialog.html index 4630d405a638a..565f06f5e0e98 100644 --- a/media/editors/tinymce/plugins/example/dialog.html +++ b/media/editors/tinymce/plugins/example/dialog.html @@ -5,4 +5,4 @@

Custom dialog

Input some text: - + \ No newline at end of file diff --git a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js index ca60b29a04624..258929b574223 100644 --- a/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js @@ -19,6 +19,7 @@ tinymce.PluginManager.add("joomlaarticle", function(editor, url) { } }) }); + function jSelectArticle(id, title, catid, object, link, lang) { var hreflang = ''; @@ -29,4 +30,4 @@ function jSelectArticle(id, title, catid, object, link, lang) var tag = '' + title + ''; tinymce.activeEditor.insertContent(tag); tinymce.activeEditor.windowManager.close(); -} \ No newline at end of file +} diff --git a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js index ac24584dea927..1dd3537f54801 100644 --- a/media/editors/tinymce/plugins/joomlaimage/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js @@ -24,4 +24,4 @@ tinymce.PluginManager.add("joomlaimage", function(editor, url) { } } }) -}); \ No newline at end of file +}); diff --git a/media/editors/tinymce/plugins/joomlapager/plugin.min.js b/media/editors/tinymce/plugins/joomlapager/plugin.min.js index 877853197e2c9..a0582bd96bc1f 100644 --- a/media/editors/tinymce/plugins/joomlapager/plugin.min.js +++ b/media/editors/tinymce/plugins/joomlapager/plugin.min.js @@ -22,4 +22,4 @@ tinymce.PluginManager.add("joomlapager", function(editor, url) { }); } }) -}); \ No newline at end of file +}); diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index e0081eece64b9..a1620c3218ad1 100644 --- a/plugins/editors/tinymce/tinymce.php +++ b/plugins/editors/tinymce/tinymce.php @@ -660,6 +660,11 @@ public function onInit() $mode = 0; } + // We need a string for the alert of read more + $lang = JFactory::getLanguage(); + $lang->load('plg_editors-xtd_readmore', JPATH_ADMINISTRATOR, $lang->getTag(), true); + $alertText = JText::_('PLG_READMORE_ALREADY_EXISTS'); + switch ($mode) { case 0: /* Simple mode*/ @@ -691,8 +696,7 @@ public function onInit() $content_css document_base_url : \"" . JUri::root() . "\" }); - var hrExists = \"" . - JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\", + var hrExists = \"" . $alertText . "\", imgLink = \"$link\", toc = \"" . JSession::getFormToken() . "\"; "; @@ -743,8 +747,7 @@ public function onInit() width : \"$html_width\", }); - var hrExists = \"" . - JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\", + var hrExists = \"" . $alertText . "\", imgLink = \"$link\", toc = \"" . JSession::getFormToken() . "\"; "; @@ -811,8 +814,7 @@ public function onInit() width : \"$html_width\", }); - var hrExists = \"" . - JText::_('PLG_TINY_READMORE_ALREADY_EXISTS') . "\", + var hrExists = \"" . $alertText . "\", imgLink = \"$link\", toc = \"" . JSession::getFormToken() . "\"; ";