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/joomlaarticle/plugin.min.js b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js new file mode 100644 index 0000000000000..258929b574223 --- /dev/null +++ b/media/editors/tinymce/plugins/joomlaarticle/plugin.min.js @@ -0,0 +1,33 @@ +tinymce.PluginManager.add("joomlaarticle", function(editor, url) { + editor.addButton("joomlaarticle", { + text: 'J Article', + title: "Joomla Insert Article", + 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) +{ + var hreflang = ''; + if (lang !== '') + { + var hreflang = ' hreflang = \"' + lang + '\"'; + } + var tag = '' + title + ''; + tinymce.activeEditor.insertContent(tag); + tinymce.activeEditor.windowManager.close(); +} 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..1dd3537f54801 --- /dev/null +++ b/media/editors/tinymce/plugins/joomlaimage/plugin.min.js @@ -0,0 +1,27 @@ +tinymce.PluginManager.add("joomlaimage", function(editor, url) { + editor.addButton("joomlaimage", { + text: 'J Image', + title: "Joomla Insert Image", + 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" + }] + }) + } + } + }) +}); diff --git a/media/editors/tinymce/plugins/joomlamore/plugin.min.js b/media/editors/tinymce/plugins/joomlamore/plugin.min.js new file mode 100644 index 0000000000000..cbf3789c28c22 --- /dev/null +++ b/media/editors/tinymce/plugins/joomlamore/plugin.min.js @@ -0,0 +1,25 @@ +tinymce.PluginManager.add("joomlamore", function(editor) { + editor.addCommand("mceJoomlaMore", function() { + var myRe = /"); + } + }), editor.addButton("joomlamore", { + text: 'J Read More', + title: "Joomla Read More", + icon: 'pagebreak', + cmd: "mceJoomlaMore" + }), editor.addMenuItem("joomlamore", { + text: "Joomla Read More", + icon: "pagebreak", + cmd: "mceJoomlaMore", + context: "insert" + }) +}); 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..a0582bd96bc1f --- /dev/null +++ b/media/editors/tinymce/plugins/joomlapager/plugin.min.js @@ -0,0 +1,25 @@ +tinymce.PluginManager.add("joomlapager", function(editor, url) { + editor.addButton("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('
'); + } + }); + } + }) +}); diff --git a/plugins/editors/tinymce/tinymce.php b/plugins/editors/tinymce/tinymce.php index 95b86c2243240..a1620c3218ad1 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,8 +603,14 @@ public function onInit() $toolbar4_add[] = $custom_button; } + $toolbar5_add[] = 'joomlamore'; + $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 @@ -611,6 +618,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); @@ -619,6 +627,21 @@ 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 . '&tiny=1&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 @@ -637,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*/ @@ -653,7 +681,8 @@ public function onInit() theme : \"$theme\", schema: \"html5\", menubar: false, - toolbar1: \"bold italics underline strikethrough | undo redo | bullist numlist\", + toolbar1: \"bold italics underline strikethrough | undo redo | bullist numlist | $toolbar5\", + plugins : \"code, joomlamore, joomlaimage, joomlaarticle, joomlapager\", // Cleanup/Output inline_styles : true, gecko_spellcheck : true, @@ -667,6 +696,9 @@ public function onInit() $content_css document_base_url : \"" . JUri::root() . "\" }); + var hrExists = \"" . $alertText . "\", + imgLink = \"$link\", + toc = \"" . JSession::getFormToken() . "\"; "; break; @@ -696,10 +728,11 @@ 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 code joomlamore joomlaimage joomlaarticle joomlapager\", // Toolbar toolbar1: \"$toolbar1\", toolbar2: \"$toolbar2\", + toolbar3: \"$toolbar5\", removed_menuitems: \"newdocument\", // URL relative_urls : $relative_urls, @@ -714,6 +747,9 @@ public function onInit() width : \"$html_width\", }); + var hrExists = \"" . $alertText . "\", + imgLink = \"$link\", + toc = \"" . JSession::getFormToken() . "\"; "; break; @@ -740,12 +776,12 @@ public function onInit() $smallButtons invalid_elements : \"$invalid_elements\", // Plugins - plugins : \"$plugins\", + plugins : \"$plugins, code joomlamore joomlaimage joomlaarticle joomlapager\", // Toolbar toolbar1: \"$toolbar1\", toolbar2: \"$toolbar2\", toolbar3: \"$toolbar3\", - toolbar4: \"$toolbar4\", + toolbar4: \"$toolbar4 | $toolbar5\", removed_menuitems: \"newdocument\", // URL relative_urls : $relative_urls, @@ -778,6 +814,9 @@ public function onInit() width : \"$html_width\", }); + var hrExists = \"" . $alertText . "\", + imgLink = \"$link\", + toc = \"" . JSession::getFormToken() . "\"; "; break; } @@ -859,7 +898,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)) { @@ -890,7 +929,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; @@ -932,12 +970,74 @@ 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); + } + + // 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($trArticle, $trBreak, $trImage, $trMore))) + { + $but = $this->removeElementWithValue($but, "text", $butt['text']); + } + else + { + $butt2 = new JObject; + $butt2->modal = $butt['modal']; + $butt2->class = $butt['class']; + $butt2->link = $butt['link']; + $butt2->text = $butt['text']; + $butt2->name = $butt['name']; + if (isset($butt['options'])) + { + $butt2->options = $butt['options']; + } + $nbutt[] = $butt2; + } + } + + 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 string $key the key + * @param string $value the value + * + * @return array + */ + 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 *