diff --git a/administrator/components/com_menus/models/fields/modal/menu.php b/administrator/components/com_menus/models/fields/modal/menu.php
index 5b3694e4167a5..bc316da8b6391 100644
--- a/administrator/components/com_menus/models/fields/modal/menu.php
+++ b/administrator/components/com_menus/models/fields/modal/menu.php
@@ -34,8 +34,10 @@ class JFormFieldModal_Menu extends JFormField
*/
protected function getInput()
{
- $allowEdit = ((string) $this->element['edit'] == 'true') ? true : false;
- $allowClear = ((string) $this->element['clear'] != 'false') ? true : false;
+ $allowNew = ((string) $this->element['new'] == 'true');
+ $allowEdit = ((string) $this->element['edit'] == 'true');
+ $allowClear = ((string) $this->element['clear'] != 'false');
+ $allowSelect = ((string) $this->element['select'] != 'false');
// Load language
JFactory::getLanguage()->load('com_menus', JPATH_ADMINISTRATOR);
@@ -43,102 +45,50 @@ protected function getInput()
// The active article id field.
$value = (int) $this->value > 0 ? (int) $this->value : '';
- // Build the script.
- $script = array();
+ // Create the modal id.
+ $modalId = 'Item_' . $this->id;
- // Select button script
- $script[] = ' function jSelectMenu_' . $this->id . '(id, title, object) {';
- $script[] = ' document.getElementById("' . $this->id . '_id").value = id;';
- $script[] = ' document.getElementById("' . $this->id . '_name").value = title;';
+ // Add the modal field script to the document head.
+ JHtml::_('jquery.framework');
+ JHtml::_('script', 'system/modal-fields.js', false, true);
- if ($allowEdit)
- {
- $script[] = ' if (id == "' . $value . '") {';
- $script[] = ' jQuery("#' . $this->id . '_edit").removeClass("hidden");';
- $script[] = ' } else {';
- $script[] = ' jQuery("#' . $this->id . '_edit").addClass("hidden");';
- $script[] = ' }';
- }
-
- if ($allowClear)
- {
- $script[] = ' jQuery("#' . $this->id . '_clear").removeClass("hidden");';
- }
-
- $script[] = ' jQuery("#menuSelect' . $this->id . 'Modal").modal("hide");';
-
- if ($this->required)
- {
- $script[] = ' document.formvalidator.validate(document.getElementById("' . $this->id . '_id"));';
- $script[] = ' document.formvalidator.validate(document.getElementById("' . $this->id . '_name"));';
- }
-
- $script[] = ' }';
-
- // Edit button script
- $script[] = ' function jEditMenu_' . $value . '(title) {';
- $script[] = ' document.getElementById("' . $this->id . '_name").value = title;';
- $script[] = ' }';
-
- // Clear button script
- static $scriptClear;
-
- if ($allowClear && !$scriptClear)
+ // Script to proxy the select modal function to the modal-fields.js file.
+ if ($allowSelect)
{
- $scriptClear = true;
+ static $scriptSelect = null;
- if (isset($this->element['language']))
- {
- $clearField = JText::_('COM_MENUS_SELECT_A_MENUITEM', true);
- }
- elseif ((string) $this->element->option['value'] == '')
+ if (is_null($scriptSelect))
{
- $clearField = JText::_($this->element->option, true);
- }
- else
- {
- $clearField = JText::_('JDEFAULT', true);
+ $scriptSelect = array();
}
- $clearField = htmlspecialchars($clearField, ENT_QUOTES, 'UTF-8');
+ if (!isset($scriptSelect[$this->id]))
+ {
+ JFactory::getDocument()->addScriptDeclaration("
+ function jSelectMenu_" . $this->id . "(id, title, object) {
+ window.processModalSelect('Item', '" . $this->id . "', id, title, '', object);
+ }
+ ");
- $script[] = ' function jClearMenu(id) {';
- $script[] = ' document.getElementById(id + "_id").value = "";';
- $script[] = ' document.getElementById(id + "_name").value = "' . $clearField . '";';
- $script[] = ' jQuery("#"+id + "_clear").addClass("hidden");';
- $script[] = ' if (document.getElementById(id + "_edit")) {';
- $script[] = ' jQuery("#"+id + "_edit").addClass("hidden");';
- $script[] = ' }';
- $script[] = ' return false;';
- $script[] = ' }';
+ $scriptSelect[$this->id] = true;
+ }
}
- // Add the script to the document head.
- JFactory::getDocument()->addScriptDeclaration(implode("\n", $script));
-
// Setup variables for display.
- $html = array();
-
- $linkItems = 'index.php?option=com_menus&view=items&layout=modal&tmpl=component'
- . '&function=jSelectMenu_' . $this->id;
-
- $linkItem = 'index.php?option=com_menus&view=item&layout=modal&tmpl=component'
- . '&task=item.edit'
- . '&function=jEditMenu_' . $value;
+ $linkItems = 'index.php?option=com_menus&view=items&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';
+ $linkItem = 'index.php?option=com_menus&view=item&layout=modal&tmpl=component&' . JSession::getFormToken() . '=1';
+ $modalTitle = JText::_('COM_MENUS_CHANGE_MENUITEM');
if (isset($this->element['language']))
{
- $linkItems .= '&forcedLanguage=' . $this->element['language'];
- $linkItem .= '&forcedLanguage=' . $this->element['language'];
- $modalTitle = JText::_('COM_MENUS_CHANGE_MENUITEM') . ' — ' . $this->element['label'];
- }
- else
- {
- $modalTitle = JText::_('COM_MENUS_CHANGE_MENUITEM');
+ $linkItems .= '&forcedLanguage=' . $this->element['language'];
+ $linkItem .= '&forcedLanguage=' . $this->element['language'];
+ $modalTitle .= ' — ' . $this->element['label'];
}
- $urlSelect = $linkItems . '&' . JSession::getFormToken() . '=1';
- $urlEdit = $linkItem . '&id=' . $value . '&' . JSession::getFormToken() . '=1';
+ $urlSelect = $linkItems . '&function=jSelectMenu_' . $this->id;
+ $urlEdit = $linkItem . '&task=item.edit&id=\' + document.getElementById("' . $this->id . '_id").value + \'';
+ $urlNew = $linkItem . '&task=item.add';
if ($value)
{
@@ -160,113 +110,151 @@ protected function getInput()
}
}
- if (empty($title))
- {
- if (isset($this->element['language']))
- {
- $title = JText::_('COM_MENUS_SELECT_A_MENUITEM', true);
- }
- elseif ((string) $this->element->option['value'] == '')
- {
- $title = JText::_($this->element->option, true);
- }
- else
- {
- $title = JText::_('JDEFAULT');
- }
- }
-
- $title = htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
+ $title = empty($title) ? JText::_('COM_MENUS_SELECT_A_MENUITEM') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');
- // The current menuitem display field.
- $html[] = '';
- $html[] = '';
+ // The current menu item display field.
+ $html = '';
+ $html .= '';
// Select menu item button
- $html[] = ''
- . ' ' . JText::_('JSELECT')
- . '';
+ if ($allowSelect)
+ {
+ $html .= ''
+ . ' ' . JText::_('JSELECT')
+ . '';
+ }
- // Edit menuitem button
+ // New menu item button
+ if ($allowNew)
+ {
+ $html .= ''
+ . ' ' . JText::_('JACTION_CREATE')
+ . '';
+ }
+
+ // Edit menu item button
if ($allowEdit)
{
- $html[] = ''
. ' ' . JText::_('JACTION_EDIT')
. '';
}
- // Clear menu button
+ // Clear menu item button
if ($allowClear)
{
- $html[] = '';
+ . '';
}
- $html[] = '';
+ $html .= '';
- // Select menuitem modal
- $html[] = JHtml::_(
- 'bootstrap.renderModal',
- 'menuSelect' . $this->id . 'Modal',
- array(
- 'title' => $modalTitle,
- 'url' => $urlSelect,
- 'height' => '400px',
- 'width' => '800px',
- 'bodyHeight' => '70',
- 'modalWidth' => '80',
- 'footer' => '',
- )
- );
+ // Select menu item modal
+ if ($allowSelect)
+ {
+ $html .= JHtml::_(
+ 'bootstrap.renderModal',
+ 'ModalSelect' . $modalId,
+ array(
+ 'title' => $modalTitle,
+ 'url' => $urlSelect,
+ 'height' => '400px',
+ 'width' => '800px',
+ 'bodyHeight' => '70',
+ 'modalWidth' => '80',
+ 'footer' => '' . JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '',
+ )
+ );
+ }
- // Edit menuitem modal
- $html[] = JHtml::_(
- 'bootstrap.renderModal',
- 'menuEdit' . $value . 'Modal',
- array(
- 'title' => JText::_('COM_MENUS_EDIT_MENUITEM'),
- 'backdrop' => 'static',
- 'keyboard' => false,
- 'closeButton' => false,
- 'url' => $urlEdit,
- 'height' => '400px',
- 'width' => '800px',
- 'bodyHeight' => '70',
- 'modalWidth' => '80',
- 'footer' => ''
- . ''
- . '',
- )
- );
+ // New menu item modal
+ if ($allowNew)
+ {
+ $html .= JHtml::_(
+ 'bootstrap.renderModal',
+ 'ModalNew' . $modalId,
+ array(
+ 'title' => JText::_('COM_MENUS_NEW_MENUITEM'),
+ 'backdrop' => 'static',
+ 'keyboard' => false,
+ 'closeButton' => false,
+ 'url' => $urlNew,
+ 'height' => '400px',
+ 'width' => '800px',
+ 'bodyHeight' => '70',
+ 'modalWidth' => '80',
+ 'footer' => ''
+ . JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . ''
+ . ''
+ . JText::_("JSAVE") . ''
+ . ''
+ . JText::_("JAPPLY") . '',
+ )
+ );
+ }
+
+ // Edit menu item modal
+ if ($allowEdit)
+ {
+ $html .= JHtml::_(
+ 'bootstrap.renderModal',
+ 'ModalEdit' . $modalId,
+ array(
+ 'title' => JText::_('COM_MENUS_EDIT_MENUITEM'),
+ 'backdrop' => 'static',
+ 'keyboard' => false,
+ 'closeButton' => false,
+ 'url' => $urlEdit,
+ 'height' => '400px',
+ 'width' => '800px',
+ 'bodyHeight' => '70',
+ 'modalWidth' => '80',
+ 'footer' => ''
+ . JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . ''
+ . ''
+ . JText::_("JSAVE") . ''
+ . ''
+ . JText::_("JAPPLY") . '',
+ )
+ );
+ }
// Note: class='required' for client side validation.
$class = $this->required ? ' class="required modal-value"' : '';
- $html[] = '';
+ $html .= '';
- return implode("\n", $html);
+ return $html;
}
/**
diff --git a/administrator/components/com_menus/models/forms/item_alias.xml b/administrator/components/com_menus/models/forms/item_alias.xml
index a8782062c68ef..c184b2a675ed6 100644
--- a/administrator/components/com_menus/models/forms/item_alias.xml
+++ b/administrator/components/com_menus/models/forms/item_alias.xml
@@ -9,8 +9,10 @@
description="COM_MENUS_ITEM_FIELD_ALIAS_MENU_DESC"
label="COM_MENUS_ITEM_FIELD_ALIAS_MENU_LABEL"
required="true"
+ select="true"
+ new="true"
edit="true"
- clear="false"
+ clear="true"
/>
diff --git a/administrator/components/com_menus/models/item.php b/administrator/components/com_menus/models/item.php
index 79cdaef8f6151..1c5f319b9a181 100644
--- a/administrator/components/com_menus/models/item.php
+++ b/administrator/components/com_menus/models/item.php
@@ -1169,6 +1169,8 @@ protected function preprocessForm(JForm $form, $data, $group = 'content')
$field->addAttribute('language', $tag);
$field->addAttribute('label', $language->title);
$field->addAttribute('translate_label', 'false');
+ $field->addAttribute('select', 'true');
+ $field->addAttribute('new', 'true');
$field->addAttribute('edit', 'true');
$field->addAttribute('clear', 'true');
$option = $field->addChild('option', 'COM_MENUS_ITEM_FIELD_ASSOCIATION_NO_VALUE');
diff --git a/administrator/components/com_menus/views/item/tmpl/edit.php b/administrator/components/com_menus/views/item/tmpl/edit.php
index 3accaa72e5404..169f313ed3e3f 100644
--- a/administrator/components/com_menus/views/item/tmpl/edit.php
+++ b/administrator/components/com_menus/views/item/tmpl/edit.php
@@ -62,6 +62,7 @@
{
Joomla.submitform(task, document.getElementById('item-form'));
+ // @deprecated 4.0 The following js is not needed since __DEPLOY_VERSION__.
if (task !== 'item.apply')
{
window.parent.jQuery('#menuEdit" . (int) $this->item->id . "Modal').modal('hide');
@@ -175,6 +176,7 @@
+
form->getInput('component_id'); ?>
diff --git a/administrator/components/com_menus/views/item/tmpl/modal.php b/administrator/components/com_menus/views/item/tmpl/modal.php
index bbdaafcae09b8..601b697378e59 100644
--- a/administrator/components/com_menus/views/item/tmpl/modal.php
+++ b/administrator/components/com_menus/views/item/tmpl/modal.php
@@ -11,6 +11,7 @@
JHtml::_('bootstrap.tooltip', '.hasTooltip', array('placement' => 'bottom'));
+// @deprecated 4.0 the function parameter, the inline js and the buttons are not needed since __DEPLOY_VERSION__.
$function = JFactory::getApplication()->input->getCmd('function', 'jEditMenu_' . (int) $this->item->id);
// Function to update input title when changed
diff --git a/administrator/components/com_menus/views/item/view.html.php b/administrator/components/com_menus/views/item/view.html.php
index c72ce91f9d3f3..0ef4930352d49 100644
--- a/administrator/components/com_menus/views/item/view.html.php
+++ b/administrator/components/com_menus/views/item/view.html.php
@@ -72,6 +72,20 @@ public function display($tpl = null)
}
if ($this->getLayout() == 'modal')
+ {
+ // If we are forcing a language in modal (used for associations).
+ if ($forcedLanguage = JFactory::getApplication()->input->get('forcedLanguage', '', 'cmd'))
+ {
+ // Set the language field to the forcedLanguage and disable changing it.
+ $this->form->setValue('language', null, $forcedLanguage);
+ $this->form->setFieldAttribute('language', 'readonly', 'true');
+
+ // Only allow to select categories with All language or with the forced language.
+ $this->form->setFieldAttribute('parent_id', 'language', '*,' . $forcedLanguage);
+ }
+ }
+ // If not in associations modal, block the language change if in edit modal, language not All and associations enabled.
+ elseif ($this->item->id && $this->form->getValue('language', null, '*') != '*' && JLanguageAssociations::isEnabled())
{
$this->form->setFieldAttribute('language', 'readonly', 'true');
}
diff --git a/administrator/language/en-GB/en-GB.com_menus.ini b/administrator/language/en-GB/en-GB.com_menus.ini
index 8e66fd037198d..ff8b82f02420a 100644
--- a/administrator/language/en-GB/en-GB.com_menus.ini
+++ b/administrator/language/en-GB/en-GB.com_menus.ini
@@ -170,6 +170,7 @@ COM_MENUS_N_ITEMS_UNPUBLISHED="%d menu items successfully unpublished."
COM_MENUS_N_ITEMS_UNPUBLISHED_1="%d menu item successfully unpublished."
COM_MENUS_N_MENUS_DELETED="%d menu types successfully deleted."
COM_MENUS_N_MENUS_DELETED_1="Menu type successfully deleted."
+COM_MENUS_NEW_MENUITEM="New Menu Item"
COM_MENUS_NO_ITEM_SELECTED="No menu items selected."
COM_MENUS_NO_MENUS_SELECTED="No menu selected."
COM_MENUS_OPTION_SELECT_LEVEL="- Select Max Levels -"
diff --git a/components/com_users/views/login/tmpl/default.xml b/components/com_users/views/login/tmpl/default.xml
index 8ae276f8a6525..75d3b25983ae2 100644
--- a/components/com_users/views/login/tmpl/default.xml
+++ b/components/com_users/views/login/tmpl/default.xml
@@ -47,6 +47,8 @@
label="COM_USERS_FIELD_LOGIN_REDIRECTMENU_LABEL"
description="COM_USERS_FIELD_LOGIN_REDIRECTMENU_DESC"
showon="loginredirectchoice:1"
+ select="true"
+ new="true"
edit="true"
clear="true"
>
@@ -118,6 +120,8 @@
label="COM_USERS_FIELD_LOGOUT_REDIRECTMENU_LABEL"
description="COM_USERS_FIELD_LOGOUT_REDIRECTMENU_DESC"
showon="logoutredirectchoice:1"
+ select="true"
+ new="true"
edit="true"
clear="true"
>
diff --git a/components/com_users/views/login/tmpl/logout.xml b/components/com_users/views/login/tmpl/logout.xml
index 12f80c2ab0126..d82b092b92c8e 100644
--- a/components/com_users/views/login/tmpl/logout.xml
+++ b/components/com_users/views/login/tmpl/logout.xml
@@ -27,6 +27,8 @@
disable="separator,alias,heading,url"
label="JFIELD_LOGOUT_REDIRECT_PAGE_LABEL"
description="JFIELD_LOGOUT_REDIRECT_PAGE_DESC"
+ select="true"
+ new="true"
edit="true"
clear="true"
>
diff --git a/modules/mod_login/mod_login.xml b/modules/mod_login/mod_login.xml
index 29f398f743db4..93a3e213ea6af 100644
--- a/modules/mod_login/mod_login.xml
+++ b/modules/mod_login/mod_login.xml
@@ -50,6 +50,8 @@
label="MOD_LOGIN_FIELD_LOGIN_REDIRECTURL_LABEL"
description="MOD_LOGIN_FIELD_LOGIN_REDIRECTURL_DESC"
disable="separator,alias,heading,url"
+ select="true"
+ new="true"
edit="true"
clear="true"
>
@@ -62,6 +64,8 @@
label="MOD_LOGIN_FIELD_LOGOUT_REDIRECTURL_LABEL"
description="MOD_LOGIN_FIELD_LOGOUT_REDIRECTURL_DESC"
disable="separator,alias,heading,url"
+ select="true"
+ new="true"
edit="true"
clear="true"
>
diff --git a/modules/mod_menu/mod_menu.xml b/modules/mod_menu/mod_menu.xml
index 07b83f19f62ab..c850684f3e100 100644
--- a/modules/mod_menu/mod_menu.xml
+++ b/modules/mod_menu/mod_menu.xml
@@ -36,6 +36,8 @@
type="modal_menu"
label="MOD_MENU_FIELD_ACTIVE_LABEL"
description="MOD_MENU_FIELD_ACTIVE_DESC"
+ select="true"
+ new="true"
edit="true"
clear="true"
>