Skip to content

Commit

Permalink
Merge branch '4.0-dev' into ToggleEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
infograf768 committed Feb 27, 2019
2 parents be617b4 + db4b3e1 commit 8074f53
Show file tree
Hide file tree
Showing 103 changed files with 1,211 additions and 776 deletions.
8 changes: 4 additions & 4 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ pipeline:
- bash libraries/vendor/joomla/test-system/src/drone-run.sh "$(pwd)"

analysis3x:
image: rips/rips-cli
image: rips/rips-cli:1.2.1
secrets: [rips_username, rips_password]
when:
branch: staging
Expand All @@ -91,10 +91,10 @@ pipeline:
- export RIPS_USERNAME=$RIPS_USERNAME
- export RIPS_PASSWORD=$RIPS_PASSWORD
- if [ $DRONE_REPO_OWNER != 'joomla' ]; then echo "The analysis check only run on the main repos"; exit 0; fi
- rips-cli rips:scan:start -a 1 -t 1 -p $(pwd) -t 1 -T $DRONE_REPO_OWNER-$DRONE_BRANCH || { echo "Please contact the security team at security@joomla.org"; exit 1; }
- rips-cli rips:scan:start -a 1 -t 1 -R -k -p $(pwd) -t 1 -T $DRONE_REPO_OWNER-$DRONE_BRANCH || { echo "Please contact the security team at security@joomla.org"; exit 1; }

analysis4x:
image: rips/rips-cli
image: rips/rips-cli:1.2.1
secrets: [rips_username, rips_password]
when:
branch: 4.0-dev
Expand All @@ -103,7 +103,7 @@ pipeline:
- export RIPS_USERNAME=$RIPS_USERNAME
- export RIPS_PASSWORD=$RIPS_PASSWORD
- if [ $DRONE_REPO_OWNER != 'joomla' ]; then echo "The analysis check only run on the main repos"; exit 0; fi
- rips-cli rips:scan:start -a 3 -t 1 -p $(pwd) -t 1 -T $DRONE_REPO_OWNER-$DRONE_BRANCH || { echo "Please contact the security team at security@joomla.org"; exit 1; }
- rips-cli rips:scan:start -a 3 -t 1 -R -k -p $(pwd) -t 1 -T $DRONE_REPO_OWNER-$DRONE_BRANCH || { echo "Please contact the security team at security@joomla.org"; exit 1; }

branches:
exclude: [ l10n_* ]
Expand Down
12 changes: 4 additions & 8 deletions administrator/components/com_admin/View/Profile/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,10 @@ protected function addToolbar()

ToolbarHelper::title(Text::_('COM_ADMIN_VIEW_PROFILE_TITLE'), 'user user-profile');

ToolbarHelper::saveGroup(
[
['apply', 'profile.apply'],
['save', 'profile.save']
],
'btn-success'
);

ToolbarHelper::apply('profile.apply');
ToolbarHelper::divider();
ToolbarHelper::save('profile.save');
ToolbarHelper::divider();
ToolbarHelper::cancel('profile.cancel', 'JTOOLBAR_CLOSE');
ToolbarHelper::divider();
ToolbarHelper::help('JHELP_ADMIN_USER_PROFILE_EDIT');
Expand Down
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 @@ -97,7 +97,7 @@ protected function addToolbar()
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || count($user->getAuthorisedCategories('com_banners', 'core.create')) > 0))
{
$toolbarButtons[] = ['apply', 'banner.apply'];
ToolbarHelper::apply('banner.apply');
$toolbarButtons[] = ['save', 'banner.save'];

if ($canDo->get('core.create'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function addToolbar()
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create')))
{
$toolbarButtons[] = ['apply', 'client.apply'];
ToolbarHelper::apply('client.apply');
$toolbarButtons[] = ['save', 'client.save'];
}

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 @@ -186,9 +186,9 @@ protected function addToolbar()
// For new records, check the create permission.
if ($isNew && (count($user->getAuthorisedCategories($component, 'core.create')) > 0))
{
ToolbarHelper::apply('category.apply');
ToolbarHelper::saveGroup(
[
['apply', 'category.apply'],
['save', 'category.save'],
['save2new', 'category.save2new']
],
Expand All @@ -209,7 +209,8 @@ protected function addToolbar()
// Can't save the record if it's checked out and editable
if (!$checkedOut && $itemEditable)
{
$toolbarButtons[] = ['apply', 'category.apply'];
ToolbarHelper::apply('category.apply');

$toolbarButtons[] = ['save', 'category.save'];

if ($canDo->get('core.create'))
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
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,9 @@ public function display($tpl = null)
protected function addToolbar()
{
ToolbarHelper::title(Text::_('COM_CONFIG_GLOBAL_CONFIGURATION'), 'equalizer config');
ToolbarHelper::saveGroup(
[
['apply', 'application.apply'],
['save', 'application.save']
],
'btn-success'
);
ToolbarHelper::apply('application.apply');
ToolbarHelper::divider();
ToolbarHelper::save('application.save');
ToolbarHelper::divider();
ToolbarHelper::cancel('application.cancel', 'JTOOLBAR_CLOSE');
ToolbarHelper::divider();
Expand Down
10 changes: 3 additions & 7 deletions administrator/components/com_config/View/Component/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,9 @@ public function display($tpl = null)
protected function addToolbar()
{
ToolbarHelper::title(Text::_($this->component->option . '_configuration'), 'equalizer config');
ToolbarHelper::saveGroup(
[
['apply', 'component.apply'],
['save', 'component.save']
],
'btn-success'
);
ToolbarHelper::apply('component.apply');
ToolbarHelper::divider();
ToolbarHelper::save('component.save');
ToolbarHelper::divider();
ToolbarHelper::cancel('component.cancel', 'JTOOLBAR_CLOSE');
ToolbarHelper::divider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@ protected function addToolbar()
// For new records, check the create permission.
if ($isNew && (count($user->getAuthorisedCategories('com_contact', 'core.create')) > 0))
{
ToolbarHelper::apply('contact.apply');

ToolbarHelper::saveGroup(
[
['apply', 'contact.apply'],
['save', 'contact.save'],
['save2new', 'contact.save2new']
],
Expand All @@ -134,7 +135,8 @@ protected function addToolbar()
// Can't save the record if it's checked out and editable
if (!$checkedOut && $itemEditable)
{
$toolbarButtons[] = ['apply', 'contact.apply'];
ToolbarHelper::apply('contact.apply');

$toolbarButtons[] = ['save', 'contact.save'];

// We can save this record, but check the create permission to see if we can return to make a new one.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ protected function addToolbar()

if ($user->authorise('core.admin', 'com_contact') || $user->authorise('core.options', 'com_contact'))
{
$toolbar->preferences('com_menus');
$toolbar->preferences('com_contact');
}

$toolbar->help('JHELP_COMPONENTS_CONTACTS_CONTACTS');
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
14 changes: 10 additions & 4 deletions administrator/components/com_content/View/Article/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,16 @@ protected function addToolbar()
'pencil-2 article-add'
);

$saveGroup = $toolbar->dropdownButton('save-group');

// For new records, check the create permission.
if ($isNew && (count($user->getAuthorisedCategories('com_content', 'core.create')) > 0))
{
$apply = $toolbar->apply('article.apply');

$saveGroup = $toolbar->dropdownButton('save-group');

$saveGroup->configure(
function (Toolbar $childBar)
{
$childBar->apply('article.apply');
$childBar->save('article.save');
$childBar->save2new('article.save2new');
}
Expand All @@ -157,13 +158,18 @@ function (Toolbar $childBar)
// Since it's an existing record, check the edit permission, or fall back to edit own if the owner.
$itemEditable = $canDo->get('core.edit') || ($canDo->get('core.edit.own') && $this->item->created_by == $userId);

if (!$checkedOut && $itemEditable)
{
$toolbar->apply('article.apply');
}
$saveGroup = $toolbar->dropdownButton('save-group');

$saveGroup->configure(
function (Toolbar $childBar) use ($checkedOut, $itemEditable, $canDo)
{
// 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.
Expand Down

0 comments on commit 8074f53

Please sign in to comment.