Skip to content

Commit

Permalink
Merge branch '5.1-dev' into 5.0-tags-rebuild
Browse files Browse the repository at this point in the history
  • Loading branch information
LadySolveig committed Jan 10, 2024
2 parents 3d4f0d6 + 72942f6 commit dc0e140
Show file tree
Hide file tree
Showing 27 changed files with 760 additions and 175 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO `#__extensions` (`package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `locked`, `manifest_cache`, `params`, `custom_data`, `ordering`, `state`) VALUES
(0, 'plg_schemaorg_article', 'plugin', 'article', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO "#__extensions" ("package_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "locked", "manifest_cache", "params", "custom_data", "ordering", "state") VALUES
(0, 'plg_schemaorg_article', 'plugin', 'article', 'schemaorg', 0, 1, 1, 0, 0, '', '{}', '', 0, 0);
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

namespace Joomla\Component\Finder\Administrator\Controller;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Finder\Administrator\Helper\FinderHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -53,21 +50,6 @@ public function display($cachable = false, $urlparams = [])
$layout = $this->input->get('layout', 'index', 'word');
$filterId = $this->input->get('filter_id', null, 'int');

if ($view === 'index') {
$pluginEnabled = PluginHelper::isEnabled('content', 'finder');

if (!$pluginEnabled) {
$finderPluginId = FinderHelper::getFinderPluginId();
$link = HTMLHelper::_(
'link',
'#plugin' . $finderPluginId . 'Modal',
Text::_('COM_FINDER_CONTENT_PLUGIN'),
'class="alert-link" data-bs-toggle="modal" id="title-' . $finderPluginId . '"'
);
$this->app->enqueueMessage(Text::sprintf('COM_FINDER_INDEX_PLUGIN_CONTENT_NOT_ENABLED_LINK', $link), 'warning');
}
}

// Check for edit form.
if ($view === 'filter' && $layout === 'edit' && !$this->checkEditId('com_finder.edit.filter', $filterId)) {
// Somehow the person just went to the form - we don't allow that.
Expand Down
52 changes: 26 additions & 26 deletions administrator/components/com_finder/tmpl/index/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Multilanguage;
use Joomla\CMS\Language\Text;
Expand All @@ -24,38 +25,37 @@
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('multiselect')
->useScript('table.columns');
->useScript('table.columns')
->useScript('joomla.dialog-autocreate');

// Show warning that the content - finder plugin is disabled
if ($this->finderPluginId) {
$popupOptions = [
'popupType' => 'iframe',
'textHeader' => Text::_('COM_FINDER_EDIT_PLUGIN_SETTINGS'),
'src' => Route::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id=' . $this->finderPluginId . '&tmpl=component&layout=modal', false),
];
$link = HTMLHelper::_(
'link',
'#',
Text::_('COM_FINDER_CONTENT_PLUGIN'),
[
'class' => 'alert-link',
'data-joomla-dialog' => $this->escape(json_encode($popupOptions, JSON_UNESCAPED_SLASHES)),
'data-checkin-url' => Route::_('index.php?option=com_plugins&task=plugins.checkin&format=json&cid[]=' . $this->finderPluginId),
'data-close-on-message' => '',
'data-reload-on-close' => '',
],
);
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_FINDER_INDEX_PLUGIN_CONTENT_NOT_ENABLED_LINK', $link), 'warning');
}

?>
<form action="<?php echo Route::_('index.php?option=com_finder&view=index'); ?>" method="post" name="adminForm" id="adminForm">
<div class="row">
<div class="col-md-12">
<div id="j-main-container" class="j-main-container">
<?php echo LayoutHelper::render('joomla.searchtools.default', ['view' => $this]); ?>
<?php if ($this->finderPluginId) : ?>
<?php $link = Route::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id=' . $this->finderPluginId . '&tmpl=component&layout=modal'); ?>
<?php echo HTMLHelper::_(
'bootstrap.renderModal',
'plugin' . $this->finderPluginId . 'Modal',
[
'url' => $link,
'title' => Text::_('COM_FINDER_EDIT_PLUGIN_SETTINGS'),
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'closeButton' => false,
'backdrop' => 'static',
'keyboard' => false,
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"'
. ' onclick="Joomla.iframeButtonClick({iframeSelector: \'#plugin' . $this->finderPluginId . 'Modal\', buttonSelector: \'#closeBtn\'})">'
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
. '<button type="button" class="btn btn-primary" data-bs-dismiss="modal" onclick="Joomla.iframeButtonClick({iframeSelector: \'#plugin' . $this->finderPluginId . 'Modal\', buttonSelector: \'#saveBtn\'})">'
. Text::_("JSAVE") . '</button>'
. '<button type="button" class="btn btn-success" onclick="Joomla.iframeButtonClick({iframeSelector: \'#plugin' . $this->finderPluginId . 'Modal\', buttonSelector: \'#applyBtn\'}); return false;">'
. Text::_("JAPPLY") . '</button>'
]
); ?>
<?php endif; ?>
<?php if (empty($this->items)) : ?>
<div class="alert alert-info">
<span class="icon-info-circle" aria-hidden="true"></span><span class="visually-hidden"><?php echo Text::_('INFO'); ?></span>
Expand Down
49 changes: 25 additions & 24 deletions administrator/components/com_finder/tmpl/index/emptystate.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Layout\LayoutHelper;
Expand All @@ -27,28 +28,28 @@

echo LayoutHelper::render('joomla.content.emptystate', $displayData);

if ($this->finderPluginId) : ?>
<?php $link = Route::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id=' . $this->finderPluginId . '&tmpl=component&layout=modal'); ?>
<?php echo HTMLHelper::_(
'bootstrap.renderModal',
'plugin' . $this->finderPluginId . 'Modal',
// Show warning that the content - finder plugin is disabled
if ($this->finderPluginId) {
/** @var \Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('joomla.dialog-autocreate');

$popupOptions = [
'popupType' => 'iframe',
'textHeader' => Text::_('COM_FINDER_EDIT_PLUGIN_SETTINGS'),
'src' => Route::_('index.php?option=com_plugins&client_id=0&task=plugin.edit&extension_id=' . $this->finderPluginId . '&tmpl=component&layout=modal', false),
];
$link = HTMLHelper::_(
'link',
'#',
Text::_('COM_FINDER_CONTENT_PLUGIN'),
[
'url' => $link,
'title' => Text::_('COM_FINDER_EDIT_PLUGIN_SETTINGS'),
'height' => '400px',
'width' => '800px',
'bodyHeight' => '70',
'modalWidth' => '80',
'closeButton' => false,
'backdrop' => 'static',
'keyboard' => false,
'footer' => '<button type="button" class="btn btn-secondary" data-bs-dismiss="modal"'
. ' onclick="Joomla.iframeButtonClick({iframeSelector: \'#plugin' . $this->finderPluginId . 'Modal\', buttonSelector: \'#closeBtn\'})">'
. Text::_('JLIB_HTML_BEHAVIOR_CLOSE') . '</button>'
. '<button type="button" class="btn btn-primary" data-bs-dismiss="modal" onclick="Joomla.iframeButtonClick({iframeSelector: \'#plugin' . $this->finderPluginId . 'Modal\', buttonSelector: \'#saveBtn\'})">'
. Text::_("JSAVE") . '</button>'
. '<button type="button" class="btn btn-success" onclick="Joomla.iframeButtonClick({iframeSelector: \'#plugin' . $this->finderPluginId . 'Modal\', buttonSelector: \'#applyBtn\'}); return false;">'
. Text::_("JAPPLY") . '</button>'
]
); ?>
<?php endif;
'class' => 'alert-link',
'data-joomla-dialog' => $this->escape(json_encode($popupOptions, JSON_UNESCAPED_SLASHES)),
'data-checkin-url' => Route::_('index.php?option=com_plugins&task=plugins.checkin&format=json&cid[]=' . $this->finderPluginId),
'data-close-on-message' => '',
'data-reload-on-close' => '',
],
);
Factory::getApplication()->enqueueMessage(Text::sprintf('COM_FINDER_INDEX_PLUGIN_CONTENT_NOT_ENABLED_LINK', $link), 'warning');
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
namespace Joomla\Component\Plugins\Administrator\Controller;

use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Router\Route;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand All @@ -23,4 +25,53 @@
*/
class PluginController extends FormController
{
/**
* Method to cancel an edit.
*
* @param string $key The name of the primary key of the URL variable.
*
* @return boolean True if access level checks pass, false otherwise.
*
* @since __DEPLOY_VERSION__
*/
public function cancel($key = null)
{
$result = parent::cancel($key);

// When editing in modal then redirect to modalreturn layout
if ($result && $this->input->get('layout') === 'modal') {
$id = $this->input->get('extension_id');
$return = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($id, 'extension_id')
. '&layout=modalreturn&from-task=cancel';

$this->setRedirect(Route::_($return, false));
}

return $result;
}

/**
* Function that allows child controller access to model data
* after the data has been saved.
*
* @param BaseDatabaseModel $model The data model object.
* @param array $validData The validated data.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
protected function postSaveHook(BaseDatabaseModel $model, $validData = [])
{
parent::postSaveHook($model, $validData);

// When editing in modal then redirect to modalreturn layout
if ($this->input->get('layout') === 'modal' && $this->task === 'save') {
$id = $model->getState('plugin.id', '');
$return = 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($id, 'extension_id')
. '&layout=modalreturn&from-task=save';

$this->setRedirect(Route::_($return, false));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,23 @@ public function display($tpl = null)
$this->item = $this->get('Item');
$this->form = $this->get('Form');

if ($this->getLayout() === 'modalreturn') {
parent::display($tpl);

return;
}

// Check for errors.
if (\count($errors = $this->get('Errors'))) {
throw new GenericDataException(implode("\n", $errors), 500);
}

$this->addToolbar();
if ($this->getLayout() !== 'modal') {
$this->addToolbar();
} else {
$this->addModalToolbar();
}

parent::display($tpl);
}

Expand Down Expand Up @@ -115,4 +126,30 @@ protected function addToolbar()
$toolbar->inlinehelp();
$toolbar->help($help->key, false, $url);
}

/**
* Add the modal toolbar.
*
* @return void
*
* @since __DEPLOY_VERSION__
*
* @throws \Exception
*/
protected function addModalToolbar()
{
$canDo = ContentHelper::getActions('com_plugins');
$toolbar = Toolbar::getInstance();

ToolbarHelper::title(Text::sprintf('COM_PLUGINS_MANAGER_PLUGIN', Text::_($this->item->name)), 'plug plugin');

// If not checked out, can save the item.
if ($canDo->get('core.edit')) {
$toolbar->apply('plugin.apply');

$toolbar->save('plugin.save');
}

$toolbar->cancel('plugin.cancel');
}
}
7 changes: 3 additions & 4 deletions administrator/components/com_plugins/tmpl/plugin/modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@
defined('_JEXEC') or die;

?>
<button id="applyBtn" type="button" class="hidden" onclick="Joomla.submitbutton('plugin.apply');"></button>
<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>

<div class="subhead noshadow mb-3">
<?php echo $this->document->getToolbar('toolbar')->render(); ?>
</div>
<div class="container-popup">
<?php $this->setLayout('edit'); ?>
<?php echo $this->loadTemplate(); ?>
Expand Down
45 changes: 45 additions & 0 deletions administrator/components/com_plugins/tmpl/plugin/modalreturn.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

/**
* @package Joomla.Administrator
* @subpackage com_content
*
* @copyright (C) 2023 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;

$icon = 'icon-check';
$title = $this->item ? Text::_($this->item->name) : '';
$content = $this->item ? $this->item->folder . '/' . $this->item->element : '';
$data = ['contentType' => 'com_plugins.plugin'];

if ($this->item && $this->item->extension_id) {
$data['id'] = $this->item->extension_id;
$data['title'] = $title;
$data['type'] = $this->item->folder;
$data['name'] = $this->item->element;
}

// Add Content select script
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = $this->document->getWebAssetManager();
$wa->useScript('modal-content-select');

// The data for Content select script
$this->document->addScriptOptions('content-select-on-load', $data, false);

?>

<div class="px-4 py-5 my-5 text-center">
<span class="fa-8x mb-4 <?php echo $icon; ?>" aria-hidden="true"></span>
<h1 class="display-5 fw-bold"><?php echo $title; ?></h1>
<div class="col-lg-6 mx-auto">
<p class="lead mb-4">
<?php echo $content; ?>
</p>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@

namespace Joomla\Component\Redirect\Administrator\Controller;

use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Router\Route;
use Joomla\Component\Redirect\Administrator\Helper\RedirectHelper;

// phpcs:disable PSR1.Files.SideEffects
\defined('_JEXEC') or die;
Expand Down Expand Up @@ -51,33 +48,6 @@ public function display($cachable = false, $urlparams = false)
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');

if ($view === 'links') {
$pluginEnabled = PluginHelper::isEnabled('system', 'redirect');
$collectUrlsEnabled = RedirectHelper::collectUrlsEnabled();

// Show messages about the enabled plugin and if the plugin should collect URLs
if ($pluginEnabled && $collectUrlsEnabled) {
$this->app->enqueueMessage(Text::sprintf('COM_REDIRECT_COLLECT_URLS_ENABLED', Text::_('COM_REDIRECT_PLUGIN_ENABLED')), 'notice');
} else {
$redirectPluginId = RedirectHelper::getRedirectPluginId();
$link = HTMLHelper::_(
'link',
'#plugin' . $redirectPluginId . 'Modal',
Text::_('COM_REDIRECT_SYSTEM_PLUGIN'),
'class="alert-link" data-bs-toggle="modal" id="title-' . $redirectPluginId . '"'
);

if ($pluginEnabled && !$collectUrlsEnabled) {
$this->app->enqueueMessage(
Text::sprintf('COM_REDIRECT_COLLECT_MODAL_URLS_DISABLED', Text::_('COM_REDIRECT_PLUGIN_ENABLED'), $link),
'notice'
);
} else {
$this->app->enqueueMessage(Text::sprintf('COM_REDIRECT_PLUGIN_MODAL_DISABLED', $link), 'error');
}
}
}

// Check for edit form.
if ($view == 'link' && $layout == 'edit' && !$this->checkEditId('com_redirect.edit.link', $id)) {
// Somehow the person just went to the form - we don't allow that.
Expand Down

0 comments on commit dc0e140

Please sign in to comment.