Skip to content

Commit

Permalink
Merge branch '4.0-dev' into fix#23850
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 committed Feb 22, 2019
2 parents 1c36d06 + feeb6b9 commit 548dd57
Show file tree
Hide file tree
Showing 22 changed files with 91 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ CREATE TABLE IF NOT EXISTS `#__workflow_stages` (
--

INSERT INTO `#__workflow_stages` (`id`, `asset_id`, `ordering`, `workflow_id`, `published`, `title`, `description`, `condition`, `default`) VALUES
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 0),
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 1),
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 1),
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 0),
(3, 0, 3, 1, 1, 'JTRASHED', '', -2, 0),
(4, 0, 4, 1, 1, 'JARCHIVED', '', 2, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ CREATE INDEX "#__workflow_stages_idx_default" ON "#__workflow_stages" ("default"
--

INSERT INTO "#__workflow_stages" ("id", "asset_id", "ordering", "workflow_id", "published", "title", "description", "condition", "default") VALUES
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 0),
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 1),
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 1),
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 0),
(3, 0, 3, 1, 1, 'JTRASHED', '', -2, 0),
(4, 0, 4, 1, 1, 'JARCHIVED', '', 2, 0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -349,11 +349,11 @@ protected function getInput()
{
$data = $this->getLayoutData();

$data['options'] = $this->getOptions();
$data['allowCustom'] = $this->allowAdd;
$data['customFields'] = (boolean) $this->element['custom-fields-enabled'];
$data['customFieldsCatId'] = (string) $this->element['custom-fields-cat-id'];
$data['customFieldsSection'] = (string) $this->element['custom-fields-section'];
$data['options'] = $this->getOptions();
$data['allowCustom'] = $this->allowAdd;
$data['refreshPage'] = (boolean) $this->element['refresh-enabled'];
$data['refreshCatId'] = (string) $this->element['refresh-cat-id'];
$data['refreshSection'] = (string) $this->element['refresh-section'];

$renderer = $this->getRenderer($this->layout);
$renderer->setComponent('com_categories');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,15 @@
$html[] = HTMLHelper::_('select.genericlist', $options, $name, trim($attr), 'value', 'text', $value, $id);
}

if ($customFields === true)
if ($refreshPage === true)
{
$attr2 .= ' data-custom-fields-catid="' . $customFieldsCatId . '" data-custom-fields-section="' . $customFieldsSection . '"';
$attr2 .= ' data-refresh-catid="' . $refreshCatId . '" data-refresh-section="' . $refreshSection . '"';
$attr2 .= ' onchange="Joomla.categoryHasChanged(this)"';

HTMLHelper::_('script', 'layouts/joomla/form/field/category-change.min.js', ['version' => 'auto', 'relative' => true], ['defer' => true]);

// Pass the element id to the javascript
Factory::getDocument()->addScriptOptions('category-change', $id);
}
else
{
Expand All @@ -134,10 +139,6 @@

Factory::getDocument()->getWebAssetManager()->enableAsset('choicesjs');

// Pass the element id to the javascript
\Joomla\CMS\Factory::getDocument()->addScriptOptions('category-change', $id);

HTMLHelper::_('script', 'layouts/joomla/form/field/category-change.min.js', ['version' => 'auto', 'relative' => true], ['defer' => true]);
HTMLHelper::_('webcomponent', 'system/fields/joomla-field-fancy-select.min.js', ['version' => 'auto', 'relative' => true]);
?>

Expand Down
59 changes: 46 additions & 13 deletions administrator/components/com_content/Model/ArticleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,44 @@ public function getForm($data = array(), $loadData = true)
}
else
{
// For new articles we load the potential state + associations
if ($formField = $form->getField('catid'))
{
$assignedCatids = (int) ($data['catid'] ?? $form->getValue('catid'));

$assignedCatids = is_array($assignedCatids)
? (int) reset($assignedCatids)
: (int) $assignedCatids;

// Try to get the category from the html code of the field
if (empty($assignedCatids))
{
$assignedCatids = $formField->getAttribute('default', null);

// Choose the first category available
$xml = new \DOMDocument;
libxml_use_internal_errors(true);
$xml->loadHTML($formField->__get('input'));
libxml_clear_errors();
libxml_use_internal_errors(false);
$options = $xml->getElementsByTagName('option');

if (!$assignedCatids && $firstChoice = $options->item(0))
{
$assignedCatids = $firstChoice->getAttribute('value');
}
}

// Activate the reload of the form when category is changed
$form->setFieldAttribute('catid', 'refresh-enabled', true);
$form->setFieldAttribute('catid', 'refresh-cat-id', $assignedCatids);
$form->setFieldAttribute('catid', 'refresh-section', 'article');

$workflow = $this->getWorkflowByCategory($assignedCatids);

$form->setFieldAttribute('transition', 'workflow_stage', (int) $workflow->stage_id);
}

// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.create');
}
Expand Down Expand Up @@ -912,15 +950,10 @@ public function save($data)

// B/C state
$data['state'] = (int) $workflow->condition;

// No transition for new articles
if (isset($data['transition']))
{
unset($data['transition']);
}
}
// Calculate new status depending on transition
elseif (!empty($data['transition']))

if (!empty($data['transition']))
{
// Check if the user is allowed to execute this transition
if (!$user->authorise('core.execute.transition', 'com_content.transition.' . (int) $data['transition']))
Expand Down Expand Up @@ -993,12 +1026,6 @@ public function save($data)
$this->featured($this->getState($this->getName() . '.id'), $data['featured']);
}

// Run the transition and update the workflow association
if (!empty($data['transition']))
{
$this->runTransition((int) $this->getState($this->getName() . '.id'), (int) $data['transition']);
}

// Let's check if we have workflow association (perhaps something went wrong before)
if (empty($stageId))
{
Expand Down Expand Up @@ -1035,6 +1062,12 @@ public function save($data)
$workflow->createAssociation($this->getState($this->getName() . '.id'), (int) $stageId);
}

// Run the transition and update the workflow association
if (!empty($data['transition']))
{
$this->runTransition((int) $this->getState($this->getName() . '.id'), (int) $data['transition']);
}

return true;
}

Expand Down
2 changes: 2 additions & 0 deletions administrator/components/com_cpanel/tmpl/cpanel/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\HTML\HTMLHelper;

$user = Factory::getUser();
?>

<div class="row">
<?php $iconmodules = ModuleHelper::getModules('icon');
if ($iconmodules) : ?>
<?php HTMLHelper::_('bootstrap.framework'); ?>
<div class="col-md-12">
<?php
// Display the submenu position modules
Expand Down
6 changes: 3 additions & 3 deletions administrator/components/com_fields/Helper/FieldsHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -333,9 +333,9 @@ public static function prepareForm($context, Form $form, $data)
/*
* Setting some parameters for the category field
*/
$form->setFieldAttribute('catid', 'custom-fields-enabled', true);
$form->setFieldAttribute('catid', 'custom-fields-cat-id', $assignedCatids);
$form->setFieldAttribute('catid', 'custom-fields-section', $section);
$form->setFieldAttribute('catid', 'refresh-enabled', true);
$form->setFieldAttribute('catid', 'refresh-cat-id', $assignedCatids);
$form->setFieldAttribute('catid', 'refresh-section', $section);
}

// Getting the fields
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,12 @@ public function save($data)
[
'title' => 'JUNPUBLISHED',
'condition' => Workflow::CONDITION_UNPUBLISHED,
'default' => 1,
'transition' => 'Unpublish'
],
[
'title' => 'JPUBLISHED',
'condition' => Workflow::CONDITION_PUBLISHED,
'default' => 1,
'transition' => 'Publish'
],
[
Expand Down
3 changes: 3 additions & 0 deletions administrator/modules/mod_feed/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@

use Joomla\CMS\Factory;
use Joomla\CMS\Filter\OutputFilter;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

HTMLHelper::_('bootstrap.framework');

// Check if feed URL has been set
if (empty ($rssurl))
{
Expand Down
3 changes: 2 additions & 1 deletion administrator/modules/mod_latest/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

HTMLHelper::_('bootstrap.framework');
?>
<table class="table" id="<?php echo str_replace(' ', '', $module->title) . $module->id; ?>">
<caption class="sr-only"><?php echo $module->title; ?></caption>
Expand Down Expand Up @@ -59,4 +60,4 @@
</tr>
<?php endif; ?>
</tbody>
</table>
</table>
1 change: 1 addition & 0 deletions administrator/modules/mod_logged/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

HTMLHelper::_('bootstrap.framework');
?>
<table class="table" id="<?php echo str_replace(' ', '', $module->title) . $module->id; ?>">
<caption class="sr-only"><?php echo $module->title; ?></caption>
Expand Down
1 change: 1 addition & 0 deletions administrator/modules/mod_multilangstatus/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\Router\Route;

HTMLHelper::_('bootstrap.framework');
HTMLHelper::_('script', 'mod_multilangstatus/admin-multilangstatus.min.js', array('version' => 'auto', 'relative' => true));
?>

Expand Down
3 changes: 2 additions & 1 deletion administrator/modules/mod_popular/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

HTMLHelper::_('bootstrap.framework');
?>
<table class="table" id="<?php echo str_replace(' ', '', $module->title) . $module->id; ?>">
<caption class="sr-only"><?php echo $module->title; ?></caption>
Expand Down Expand Up @@ -62,4 +63,4 @@
</tr>
<?php endif; ?>
</tbody>
</table>
</table>
1 change: 1 addition & 0 deletions administrator/modules/mod_sampledata/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;

HTMLHelper::_('bootstrap.framework');
HTMLHelper::_('script', 'mod_sampledata/sampledata-process.js', ['version' => 'auto', 'relative' => true]);

Text::script('MOD_SAMPLEDATA_CONFIRM_START');
Expand Down
3 changes: 2 additions & 1 deletion administrator/modules/mod_status/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,9 @@
use Joomla\CMS\Uri\Uri;
use Joomla\Module\Multilangstatus\Administrator\Helper\MultilangstatusAdminHelper;

$hideLinks = $app->input->getBool('hidemainmenu');
HTMLHelper::_('bootstrap.framework');

$hideLinks = $app->input->getBool('hidemainmenu');
?>
<div class="ml-auto">
<ul class="nav text-center">
Expand Down
1 change: 0 additions & 1 deletion administrator/templates/atum/component.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
$lang = Factory::getLanguage();

// Add JavaScript Frameworks
HTMLHelper::_('bootstrap.framework');
HTMLHelper::_('script', 'vendor/focus-visible/focus-visible.min.js', ['version' => 'auto', 'relative' => true]);

// Load template CSS file
Expand Down
1 change: 0 additions & 1 deletion administrator/templates/atum/error_full.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
$logoBlue = $this->baseurl . '/templates/' . $this->template . '/images/logo-blue.svg';

// Add JavaScript
HTMLHelper::_('bootstrap.framework');
HTMLHelper::_('script', 'vendor/focus-visible/focus-visible.min.js', ['version' => 'auto', 'relative' => true]);
HTMLHelper::_('script', 'vendor/css-vars-ponyfill/css-vars-ponyfill.min.js', ['version' => 'auto', 'relative' => true]);

Expand Down
2 changes: 0 additions & 2 deletions administrator/templates/atum/joomla.asset.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,8 @@
"name": "template.atum.base",
"dependencies": [
"core",
"jquery-noconflict",
"font-awesome",
"bootstrap.css",
"bootstrap.js.bundle",
"css-vars-ponyfill"
],
"js": []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
throw new Error('Category Id element not found');
}

if (element.getAttribute('data-custom-fields-catid') && element.value !== element.getAttribute('data-cat-id')) {
element.value = element.getAttribute('data-custom-fields-catid');
if (element.getAttribute('data-refresh-catid') && element.value !== element.getAttribute('data-cat-id')) {
element.value = element.getAttribute('data-refresh-catid');
} else {
// No custom fields
element.setAttribute('data-custom-fields-catid', element.value);
element.setAttribute('data-refresh-catid', element.value);
}

window.Joomla.categoryHasChanged = (el) => {
if (el.value === el.getAttribute('data-custom-fields-catid')) {
if (el.value === el.getAttribute('data-refresh-catid')) {
return;
}

Joomla.loadingLayer('show');
document.body.appendChild(document.createElement('joomla-core-loader'));

// Custom Fields
if (el.getAttribute('data-custom-fields-section')) {
document.querySelector('input[name=task]').value = `${el.getAttribute('data-custom-fields-section')}.reload`;
if (el.getAttribute('data-refresh-section')) {
document.querySelector('input[name=task]').value = `${el.getAttribute('data-refresh-section')}.reload`;
}

element.form.submit();
Expand Down
4 changes: 2 additions & 2 deletions installation/sql/mysql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2031,8 +2031,8 @@ CREATE TABLE IF NOT EXISTS `#__workflow_stages` (
--

INSERT INTO `#__workflow_stages` (`id`, `asset_id`, `ordering`, `workflow_id`, `published`, `title`, `description`, `condition`, `default`) VALUES
(1, 57, 1, 1, 1, 'JUNPUBLISHED', '', '0', 0),
(2, 58, 2, 1, 1, 'JPUBLISHED', '', '1', 1),
(1, 57, 1, 1, 1, 'JUNPUBLISHED', '', '0', 1),
(2, 58, 2, 1, 1, 'JPUBLISHED', '', '1', 0),
(3, 59, 3, 1, 1, 'JTRASHED', '', '-2', 0),
(4, 60, 4, 1, 1, 'JARCHIVED', '', '2', 0);

Expand Down
4 changes: 2 additions & 2 deletions installation/sql/postgresql/joomla.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2031,8 +2031,8 @@ CREATE INDEX "#__workflow_stages_idx_default" ON "#__workflow_stages" ("default"
--

INSERT INTO "#__workflow_stages" ("id", "asset_id", "ordering", "workflow_id", "published", "title", "description", "condition", "default") VALUES
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 0),
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 1),
(1, 0, 1, 1, 1, 'JUNPUBLISHED', '', 0, 1),
(2, 0, 2, 1, 1, 'JPUBLISHED', '', 1, 0),
(3, 0, 3, 1, 1, 'JTRASHED', '', -2, 0),
(4, 0, 4, 1, 1, 'JARCHIVED', '', 2, 0);

Expand Down
6 changes: 1 addition & 5 deletions layouts/joomla/edit/global.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
$saveHistory = ComponentHelper::getParams($component)->get('save_history', 0);

$fields = $displayData->get('fields') ?: array(
'transition',
array('parent', 'parent_id'),
array('published', 'state', 'enabled'),
array('category', 'catid'),
Expand All @@ -40,11 +41,6 @@
'version_note',
);

if (isset($displayData->get('item')->id) && ($displayData->get('item')->id !== null))
{
array_unshift($fields, 'transition');
}

$hiddenFields = $displayData->get('hidden_fields') ?: array();

if (!$saveHistory)
Expand Down

0 comments on commit 548dd57

Please sign in to comment.