-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3.7.0: New Feature=>editor-xtd to insert menu items links in content #11721
Changes from all commits
d95c1f9
1b99f11
c80b339
ac71720
aef16e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES | ||
(459, 'plg_editors-xtd_menu', 'plugin', 'menu', 'editors-xtd', 0, 1, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state") VALUES | ||
(459, 'plg_editors-xtd_menu', 'plugin', 'menu', 'editors-xtd', 0, 1, 1, 0, '', '', '', '', 0, '1970-01-01 00:00:00', 0, 0); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
SET IDENTITY_INSERT [#__extensions] ON; | ||
|
||
INSERT INTO [#__extensions] ([extension_id], [name], [type], [element], [folder], [client_id], [enabled], [access], [protected], [manifest_cache], [params], [custom_data], [system_data], [checked_out], [checked_out_time], [ordering], [state]) | ||
SELECT 459, 'plg_editors-xtd_menu', 'plugin', 'menu', 'editors-xtd', 0, 1, 1, 0, '', '', '', '', 0, '1900-01-01 00:00:00', 0, 0; | ||
|
||
SET IDENTITY_INSERT [#__extensions] OFF; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
; Joomla! Project | ||
; Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved. | ||
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_EDITORS-XTD_MENU="Button - Menu" | ||
PLG_EDITORS-XTD_MENU_BUTTON_MENU="Menu" | ||
PLG_EDITORS-XTD_MENU_XML_DESCRIPTION="Displays a button to make it possible to insert menu item links into an Article. Displays a popup allowing you to choose the menu item." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
; Joomla! Project | ||
; Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved. | ||
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php | ||
; Note : All ini files need to be saved as UTF-8 | ||
|
||
PLG_EDITORS-XTD_MENU="Button - Menu" | ||
PLG_EDITORS-XTD_MENU_XML_DESCRIPTION="Displays a button to make it possible to insert menu item links into an Article. Displays a popup allowing you to choose the menu item." |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Plugin | ||
* @subpackage Editors-xtd.menu | ||
* | ||
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* Editor menu buton | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
class PlgButtonMenu extends JPlugin | ||
{ | ||
/** | ||
* Load the language file on instantiation. | ||
* | ||
* @var boolean | ||
* @since __DEPLOY_VERSION__ | ||
*/ | ||
protected $autoloadLanguage = true; | ||
|
||
/** | ||
* Display the button | ||
* | ||
* @param string $name The name of the button to add | ||
* | ||
* @since __DEPLOY_VERSION__ | ||
* @return array | ||
*/ | ||
public function onDisplay($name) | ||
{ | ||
/* | ||
* Javascript to insert the link | ||
* View element calls jSelectMenuItem when a menu item is clicked | ||
* jSelectMenuItem creates the link tag, sends it to the editor, | ||
* and closes the select frame. | ||
*/ | ||
$js = " | ||
function jSelectMenuItem(id, title, tree, object, uri, language) | ||
{ | ||
var thislang = ''; | ||
if (language !== '') | ||
{ | ||
var thislang = '&lang='; | ||
} | ||
var tag = '<a href=\"' + uri + thislang + language + '\">' + title + '</a>'; | ||
jInsertEditorText(tag, '" . $name . "'); | ||
jModalClose(); | ||
}"; | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @infograf768 this script should be on the modal view, so it can be overridden if someone decides to change the view.
Check the xtd-modules and the modules/modal.php: $editor = JFactory::getApplication()->input->get('editor', '', 'cmd');
JFactory::getDocument()->addScriptDeclaration('
moduleIns = function(type, name) {
window.parent.jInsertEditorText("{loadmodule " + type + "," + name + "}", "' . $editor . '");
window.parent.jModalClose();
};
modulePosIns = function(position) {
window.parent.jInsertEditorText("{loadposition " + position + "}", "' . $editor . '");
window.parent.jModalClose();
};'); There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I based this proposal on the editors-xtd_article as a good soldier. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @infograf768 Actually I tried to do that with #10794 but I messed up things there There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I propose therefore to let the js in the xtd (in both) as anyway it will be used only when the editor is in use and the plugin is enabled, which imho is better. |
||
$doc = JFactory::getDocument(); | ||
$doc->addScriptDeclaration($js); | ||
|
||
/* | ||
* Use the built-in element view to select the menu item. | ||
* Currently uses blank class. | ||
*/ | ||
$link = 'index.php?option=com_menus&view=items&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1'; | ||
|
||
$button = new JObject; | ||
$button->modal = true; | ||
$button->class = 'btn'; | ||
$button->link = $link; | ||
$button->text = JText::_('PLG_EDITORS-XTD_MENU_BUTTON_MENU'); | ||
$button->name = 'share-alt'; | ||
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}"; | ||
|
||
return $button; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<extension version="3.7" type="plugin" group="editors-xtd" method="upgrade"> | ||
<name>plg_editors-xtd_menu</name> | ||
<author>Joomla! Project</author> | ||
<creationDate>August 2016</creationDate> | ||
<copyright>Copyright (C) 2005 - 2016 Open Source Matters. All rights reserved.</copyright> | ||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> | ||
<authorEmail>[email protected]</authorEmail> | ||
<authorUrl>www.joomla.org</authorUrl> | ||
<version>__DEPLOY_VERSION__</version> | ||
<description>PLG_EDITORS-XTD_MENU_XML_DESCRIPTION</description> | ||
<files> | ||
<filename plugin="menu">menu.php</filename> | ||
</files> | ||
<languages> | ||
<language tag="en-GB">en-GB.plg_editors-xtd_menu.ini</language> | ||
<language tag="en-GB">en-GB.plg_editors-xtd_menu.sys.ini</language> | ||
</languages> | ||
</extension> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't the orderering be "5"? (look at the other editor-xtd plugins sql)
(same for all other sql)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I based my update sql on the last editors-xtd_module added to core.
Example:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok then