diff --git a/administrator/components/com_content/View/Article/HtmlView.php b/administrator/components/com_content/View/Article/HtmlView.php
index 6c3df783d4fa0..e81ca50de1389 100644
--- a/administrator/components/com_content/View/Article/HtmlView.php
+++ b/administrator/components/com_content/View/Article/HtmlView.php
@@ -11,10 +11,12 @@
defined('_JEXEC') or die;
+use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
use Joomla\CMS\Toolbar\Toolbar;
use Joomla\CMS\Toolbar\ToolbarHelper;
use Joomla\CMS\Language\Text;
+use Joomla\CMS\Session\Session;
use Joomla\CMS\Helper\ContentHelper;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
@@ -69,6 +71,7 @@ class HtmlView extends BaseHtmlView
*
* @return mixed A string if successful, otherwise an Error object.
*
+ * @throws \Exception
* @since 1.6
*/
public function display($tpl = null)
@@ -113,6 +116,7 @@ public function display($tpl = null)
*
* @return void
*
+ * @throws \Exception
* @since 1.6
*/
protected function addToolbar()
@@ -139,13 +143,13 @@ protected function addToolbar()
if ($isNew && (count($user->getAuthorisedCategories('com_content', 'core.create')) > 0))
{
$saveGroup->configure(
- function (Toolbar $childBar)
- {
- $childBar->apply('article.apply');
- $childBar->save('article.save');
- $childBar->save2new('article.save2new');
- }
- );
+ function (Toolbar $childBar)
+ {
+ $childBar->apply('article.apply');
+ $childBar->save('article.save');
+ $childBar->save2new('article.save2new');
+ }
+ );
}
else
{
@@ -153,28 +157,28 @@ function (Toolbar $childBar)
$itemEditable = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId);
$saveGroup->configure(
- function (Toolbar $childBar) use ($checkedOut, $itemEditable, $canDo)
+ function (Toolbar $childBar) use ($checkedOut, $itemEditable, $canDo)
+ {
+ // Can't save the record if it's checked out and editable
+ if (!$checkedOut && $itemEditable)
{
- // Can't save the record if it's checked out and editable
- if (!$checkedOut && $itemEditable)
- {
- $childBar->apply('article.apply');
- $childBar->save('article.save');
-
- // We can save this record, but check the create permission to see if we can return to make a new one.
- if ($canDo->get('core.create'))
- {
- $childBar->save2new('article.save2new');
- }
- }
+ $childBar->apply('article.apply');
+ $childBar->save('article.save');
- // If checked out, we can still save
+ // We can save this record, but check the create permission to see if we can return to make a new one.
if ($canDo->get('core.create'))
{
- $childBar->save2copy('article.save2copy');
+ $childBar->save2new('article.save2new');
}
}
- );
+
+ // If checked out, we can still save
+ if ($canDo->get('core.create'))
+ {
+ $childBar->save2copy('article.save2copy');
+ }
+ }
+ );
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $itemEditable)
{
@@ -187,6 +191,63 @@ function (Toolbar $childBar) use ($checkedOut, $itemEditable, $canDo)
$toolbar->preview($url, Text::_('JGLOBAL_PREVIEW'))
->bodyHeight(80)
->modalWidth(90);
+
+ // Add necessary code for a new menu item modal
+
+ // Setup variables for display
+ $linkSuffix = '&layout=modal&client_id=0&tmpl=component&' . Session::getFormToken() . '=1';
+ $linkItem = 'index.php?option=com_menus&view=item' . $linkSuffix;
+
+ if (isset($this->element['language']))
+ {
+ $linkItem .= '&forcedLanguage=' . $this->element['language'];
+ }
+
+ $urlNew = $linkItem . '&task=item.add';
+ $modalId = 'jform_request_id';
+
+ // Add button to open the modal
+ ToolbarHelper::modal('ModalNewItem_' . $modalId, 'icon-new', 'New Menu Item');
+
+ // Add the modal field script to the document head.
+ HTMLHelper::_('jquery.framework');
+ HTMLHelper::_('script', 'system/fields/modal-fields.min.js', array('version' => 'auto', 'relative' => true));
+
+ // Load the language files
+ $language = Factory::getLanguage();
+ $language->load('com_menus', JPATH_ADMINISTRATOR, 'en-GB');
+ $language->load('com_menus', JPATH_ADMINISTRATOR, $language->getDefault());
+ $language->load('com_menus', JPATH_ADMINISTRATOR);
+
+ // Add the modal html to the document
+ echo HTMLHelper::_(
+ 'bootstrap.renderModal',
+ 'ModalNewItem_' . $modalId,
+ array(
+ 'title' => Text::_('COM_MENUS_NEW_MENUITEM'),
+ 'backdrop' => 'static',
+ 'keyboard' => false,
+ 'closeButton' => false,
+ 'url' => $urlNew,
+ 'height' => '400px',
+ 'width' => '800px',
+ 'bodyHeight' => 70,
+ 'modalWidth' => 80,
+ 'footer' => ''
+ . Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . ''
+ . ''
+ . Text::_('JSAVE') . ''
+ . ''
+ . Text::_('JAPPLY') . ''
+ )
+ );
+
+
+ echo '';
+ echo '';
}
}