-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
New Feature: Implements a modal to edit the Redirect plugin settings when needed #16844
Changes from 1 commit
4a8b5f8
cb243fc
6f1d7aa
df1de20
6f5fc46
f8485f2
dcd5da9
e3cfcc8
7bb7af1
2dd79fc
34dc757
5adcaee
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,26 @@ | ||
<?php | ||
/** | ||
* @package Joomla.Administrator | ||
* @subpackage com_plugins | ||
* | ||
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
defined('_JEXEC') or die; | ||
|
||
// This code is needed for proper check out in case of modal close | ||
JFactory::getDocument()->addScriptDeclaration(' | ||
window.parent.jQuery(".modal").on("hidden", function () { | ||
if (typeof window.parent.jQuery("#plugin' . $this->item->extension_id . 'Modal iframe").contents().find("#closeBtn") !== "undefined") { | ||
window.parent.jQuery("#plugin' . $this->item->extension_id . 'Modal iframe").contents().find("#closeBtn").click(); | ||
} | ||
}); | ||
'); | ||
?> | ||
<button id="saveBtn" type="button" class="hidden" onclick="Joomla.submitbutton('plugin.save');"></button> | ||
<button id="closeBtn" type="button" class="hidden" onclick="Joomla.submitbutton('plugin.cancel');"></button> | ||
|
||
<?php | ||
$this->setLayout('edit'); | ||
echo $this->loadTemplate(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,27 @@ | |
<form action="<?php echo JRoute::_('index.php?option=com_redirect&view=links'); ?>" method="post" name="adminForm" id="adminForm"> | ||
<div id="j-main-container"> | ||
<?php echo JLayoutHelper::render('joomla.searchtools.default', array('view' => $this)); ?> | ||
<?php | ||
if ($this->redirectPluginId) | ||
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. please use opening and closing 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. That is just insane. It's a complete block of code, why would you want to open and close tags for every single line? 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. Just copy: <?php if ($this->redirectPluginId) : ?>
<?php $link = JRoute::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id=' . $this->redirectPluginId . '&tmpl=component&layout=modal'); ?>
<?php echo JHtml::_(
'bootstrap.renderModal',
'plugin' . $this->redirectPluginId . 'Modal',
array(
'url' => $link,
'title' => JText::_('COM_REDIRECT_EDIT_PLUGIN_SETTINGS'),
'height' => '400px',
'modalWidth' => '60',
'footer' => '<button class="btn" data-dismiss="modal" aria-hidden="true">'
. JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</button>'
. '<button class="btn btn-success" data-dismiss="modal" aria-hidden="true" onclick="jQuery(\'#plugin' . $this->redirectPluginId . 'Modal iframe\').contents().find(\'#saveBtn\').click();">'
. JText::_("JSAVE") . '</button>'
)
); ?>
<?php endif; ?>
|
||
{ | ||
$link = JRoute::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id=' . $this->redirectPluginId . '&tmpl=component&layout=modal'); | ||
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. why use 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. No reason, just copy and paste :) |
||
|
||
echo JHtml::_( | ||
'bootstrap.renderModal', | ||
'plugin' . $this->redirectPluginId . 'Modal', | ||
array( | ||
'url' => $link, | ||
'title' => JText::_('COM_REDIRECT_EDIT_PLUGIN_SETTINGS'), | ||
'height' => '400px', | ||
'modalWidth' => '60', | ||
'footer' => '<button class="btn" data-dismiss="modal" aria-hidden="true">' | ||
. JText::_("JLIB_HTML_BEHAVIOR_CLOSE") . '</button>' | ||
. '<button class="btn btn-success" data-dismiss="modal" aria-hidden="true" onclick="jQuery(\'#plugin' . $this->redirectPluginId . 'Modal iframe\').contents().find(\'#saveBtn\').click();">' | ||
. JText::_("JSAVE") . '</button>' | ||
) | ||
); | ||
} | ||
?> | ||
<?php if (empty($this->items)) : ?> | ||
<div class="alert alert-no-items"> | ||
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,12 +20,18 @@ class RedirectViewLinks extends JViewLegacy | |
|
||
protected $collect_urls_enabled; | ||
|
||
protected $redirectPluginId = 0; | ||
|
||
protected $items; | ||
|
||
protected $pagination; | ||
|
||
protected $state; | ||
|
||
public $filterForm; | ||
|
||
public $activeFilters; | ||
|
||
/** | ||
* Display the view. | ||
* | ||
|
@@ -34,12 +40,14 @@ class RedirectViewLinks extends JViewLegacy | |
* @return mixed False if unsuccessful, otherwise void. | ||
* | ||
* @since 1.6 | ||
* | ||
* @throws Exception | ||
*/ | ||
public function display($tpl = null) | ||
{ | ||
// Set variables | ||
$app = JFactory::getApplication(); | ||
$this->enabled = RedirectHelper::isEnabled(); | ||
$this->enabled = JPluginHelper::isEnabled('system', 'redirect'); | ||
$this->collect_urls_enabled = RedirectHelper::collectUrlsEnabled(); | ||
$this->items = $this->get('Items'); | ||
$this->pagination = $this->get('Pagination'); | ||
|
@@ -58,20 +66,30 @@ public function display($tpl = null) | |
{ | ||
$app->enqueueMessage(JText::_('COM_REDIRECT_PLUGIN_ENABLED') . ' ' . JText::_('COM_REDIRECT_COLLECT_URLS_ENABLED'), 'notice'); | ||
} | ||
elseif ($this->enabled && !$this->collect_urls_enabled) | ||
{ | ||
$link = JRoute::_('index.php?option=com_plugins&task=plugin.edit&extension_id=' . RedirectHelper::getRedirectPluginId()); | ||
$app->enqueueMessage(JText::_('COM_REDIRECT_PLUGIN_ENABLED') . JText::sprintf('COM_REDIRECT_COLLECT_URLS_DISABLED', $link), 'notice'); | ||
} | ||
else | ||
{ | ||
$link = JRoute::_('index.php?option=com_plugins&task=plugin.edit&extension_id=' . RedirectHelper::getRedirectPluginId()); | ||
$app->enqueueMessage(JText::sprintf('COM_REDIRECT_PLUGIN_DISABLED', $link), 'error'); | ||
$this->redirectPluginId = RedirectHelper::getRedirectPluginId(); | ||
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. since you already added the 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. You cannot do that because when the plugin is disabled the function will return an empty array. 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. Right! Forget that |
||
|
||
$link = JHtml::_( | ||
'link', | ||
'#plugin' . $this->redirectPluginId . 'Modal', | ||
JText::_('COM_REDIRECT_SYSTEM_PLUGIN'), | ||
'role="button" class="btn label" data-toggle="modal" title="' . JText::_('COM_REDIRECT_SYSTEM_PLUGIN') . '" id="title-' . $this->redirectPluginId . '"' | ||
); | ||
|
||
if ($this->enabled && !$this->collect_urls_enabled) | ||
{ | ||
$app->enqueueMessage(JText::_('COM_REDIRECT_PLUGIN_ENABLED') . JText::sprintf('COM_REDIRECT_COLLECT_URLS_DISABLED', $link), 'notice'); | ||
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. Add a space between sentences. |
||
} | ||
else | ||
{ | ||
$app->enqueueMessage(JText::sprintf('COM_REDIRECT_PLUGIN_DISABLED', $link), 'error'); | ||
} | ||
} | ||
|
||
$this->addToolbar(); | ||
|
||
parent::display($tpl); | ||
return parent::display($tpl); | ||
} | ||
|
||
/** | ||
|
@@ -129,6 +147,8 @@ protected function addToolbar() | |
|
||
$title = JText::_('JTOOLBAR_BULK_IMPORT'); | ||
|
||
JHtml::_('bootstrap.modal', 'collapseModal'); | ||
|
||
// Instantiate a new JLayoutFile instance and render the batch button | ||
$layout = new JLayoutFile('toolbar.batch'); | ||
|
||
|
@@ -155,6 +175,5 @@ protected function addToolbar() | |
} | ||
|
||
JToolbarHelper::help('JHELP_COMPONENTS_REDIRECT_MANAGER'); | ||
|
||
} | ||
} |
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.
2017