Skip to content

Commit f05a062

Browse files
authored
[4.3] Migrate most components to the new toolbar api (#39537)
1 parent bd296af commit f05a062

File tree

98 files changed

+1343
-1222
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+1343
-1222
lines changed

administrator/components/com_actionlogs/src/View/Actionlogs/HtmlView.php

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,24 @@ public function display($tpl = null)
133133
protected function addToolbar()
134134
{
135135
ToolbarHelper::title(Text::_('COM_ACTIONLOGS_MANAGER_USERLOGS'), 'icon-list-2');
136+
$toolbar = Toolbar::getInstance();
136137

137-
ToolbarHelper::custom('actionlogs.exportSelectedLogs', 'download', '', 'COM_ACTIONLOGS_EXPORT_CSV', true);
138-
ToolbarHelper::custom('actionlogs.exportLogs', 'download', '', 'COM_ACTIONLOGS_EXPORT_ALL_CSV', false);
139-
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'actionlogs.delete');
140-
$bar = Toolbar::getInstance('toolbar');
141-
$bar->appendButton('Confirm', 'COM_ACTIONLOGS_PURGE_CONFIRM', 'delete', 'COM_ACTIONLOGS_TOOLBAR_PURGE', 'actionlogs.purge', false);
142-
ToolbarHelper::preferences('com_actionlogs');
143-
ToolbarHelper::help('User_Actions_Log');
138+
$toolbar->standardButton('download', 'COM_ACTIONLOGS_EXPORT_CSV', 'actionlogs.exportSelectedLogs')
139+
->icon('icon-download')
140+
->listCheck(true);
141+
142+
$toolbar->standardButton('download', 'COM_ACTIONLOGS_EXPORT_ALL_CSV', 'actionlogs.exportLogs')
143+
->icon('icon-download')
144+
->listCheck(false);
145+
146+
$toolbar->delete('actionlogs.delete')
147+
->message('JGLOBAL_CONFIRM_DELETE');
148+
149+
$toolbar->confirmButton('delete', 'COM_ACTIONLOGS_TOOLBAR_PURGE', 'actionlogs.purge')
150+
->message('COM_ACTIONLOGS_PURGE_CONFIRM')
151+
->listCheck(false);
152+
153+
$toolbar->preferences('com_actionlogs');
154+
$toolbar->help('User_Actions_Log');
144155
}
145156
}

administrator/components/com_admin/src/View/Sysinfo/HtmlView.php

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1717
use Joomla\CMS\Router\Route;
1818
use Joomla\CMS\Session\Session;
19+
use Joomla\CMS\Toolbar\Toolbar;
1920
use Joomla\CMS\Toolbar\ToolbarHelper;
2021
use Joomla\Component\Admin\Administrator\Model\SysinfoModel;
2122

@@ -111,16 +112,13 @@ public function display($tpl = null): void
111112
protected function addToolbar(): void
112113
{
113114
ToolbarHelper::title(Text::_('COM_ADMIN_SYSTEM_INFORMATION'), 'info-circle systeminfo');
114-
ToolbarHelper::link(
115-
Route::_('index.php?option=com_admin&view=sysinfo&format=text&' . Session::getFormToken() . '=1'),
116-
'COM_ADMIN_DOWNLOAD_SYSTEM_INFORMATION_TEXT',
117-
'download'
118-
);
119-
ToolbarHelper::link(
120-
Route::_('index.php?option=com_admin&view=sysinfo&format=json&' . Session::getFormToken() . '=1'),
121-
'COM_ADMIN_DOWNLOAD_SYSTEM_INFORMATION_JSON',
122-
'download'
123-
);
124-
ToolbarHelper::help('Site_System_Information');
115+
$toolbar = Toolbar::getInstance();
116+
$toolbar->linkButton('download', 'COM_ADMIN_DOWNLOAD_SYSTEM_INFORMATION_TEXT')
117+
->url(Route::_('index.php?option=com_admin&view=sysinfo&format=text&' . Session::getFormToken() . '=1'));
118+
119+
$toolbar->linkButton('download', 'COM_ADMIN_DOWNLOAD_SYSTEM_INFORMATION_JSON')
120+
->url(Route::_('index.php?option=com_admin&view=sysinfo&format=json&' . Session::getFormToken() . '=1'));
121+
122+
$toolbar->help('Site_System_Information');
125123
}
126124
}

administrator/components/com_associations/src/View/Association/HtmlView.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -359,29 +359,24 @@ protected function addToolbar(): void
359359
'language assoc'
360360
);
361361

362-
$bar = Toolbar::getInstance();
363-
364-
$bar->appendButton(
365-
'Custom',
366-
'<joomla-toolbar-button><button onclick="Joomla.submitbutton(\'reference\')" '
362+
$toolbar = Toolbar::getInstance();
363+
$toolbar->customButton('reference')
364+
->html('<joomla-toolbar-button><button onclick="Joomla.submitbutton(\'reference\')" '
367365
. 'class="btn btn-success"><span class="icon-save" aria-hidden="true"></span>'
368-
. Text::_('COM_ASSOCIATIONS_SAVE_REFERENCE') . '</button></joomla-toolbar-button>',
369-
'reference'
370-
);
366+
. Text::_('COM_ASSOCIATIONS_SAVE_REFERENCE') . '</button></joomla-toolbar-button>');
371367

372-
$bar->appendButton(
373-
'Custom',
374-
'<joomla-toolbar-button><button onclick="Joomla.submitbutton(\'target\')" '
368+
$toolbar->customButton('target')
369+
->html('<joomla-toolbar-button><button onclick="Joomla.submitbutton(\'target\')" '
375370
. 'class="btn btn-success"><span class="icon-save" aria-hidden="true"></span>'
376-
. Text::_('COM_ASSOCIATIONS_SAVE_TARGET') . '</button></joomla-toolbar-button>',
377-
'target'
378-
);
371+
. Text::_('COM_ASSOCIATIONS_SAVE_TARGET') . '</button></joomla-toolbar-button>');
379372

380373
if ($this->typeName === 'category' || $this->extensionName === 'com_menus' || $this->save2copy === true) {
381-
ToolbarHelper::custom('copy', 'copy.png', '', 'COM_ASSOCIATIONS_COPY_REFERENCE', false);
374+
$toolbar->standardButton('', 'COM_ASSOCIATIONS_COPY_REFERENCE', 'copy')
375+
->icon('icon-copy')
376+
->listCheck(false);
382377
}
383378

384-
ToolbarHelper::cancel('association.cancel', 'JTOOLBAR_CLOSE');
385-
ToolbarHelper::help('Multilingual_Associations:_Edit');
379+
$toolbar->cancel('association.cancel');
380+
$toolbar->help('Multilingual_Associations:_Edit');
386381
}
387382
}

administrator/components/com_associations/src/View/Associations/HtmlView.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Joomla\CMS\Language\Text;
1616
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
1717
use Joomla\CMS\Router\Route;
18+
use Joomla\CMS\Toolbar\Toolbar;
1819
use Joomla\CMS\Toolbar\ToolbarHelper;
1920
use Joomla\Component\Associations\Administrator\Helper\AssociationsHelper;
2021

@@ -217,15 +218,21 @@ protected function addToolbar()
217218
ToolbarHelper::title(Text::_('COM_ASSOCIATIONS_TITLE_LIST_SELECT'), 'language assoc');
218219
}
219220

221+
$toolbar = Toolbar::getInstance();
222+
220223
if ($user->authorise('core.admin', 'com_associations') || $user->authorise('core.options', 'com_associations')) {
221224
if (!isset($this->typeName)) {
222-
ToolbarHelper::custom('associations.purge', 'purge', '', 'COM_ASSOCIATIONS_PURGE', false, false);
223-
ToolbarHelper::custom('associations.clean', 'refresh', '', 'COM_ASSOCIATIONS_DELETE_ORPHANS', false, false);
225+
$toolbar->standardButton('', 'COM_ASSOCIATIONS_PURGE', 'associations.purge')
226+
->icon('icon-purge')
227+
->listCheck(false);
228+
$toolbar->standardButton('', 'COM_ASSOCIATIONS_DELETE_ORPHANS', 'associations.clean')
229+
->icon('icon-refresh')
230+
->listCheck(false);
224231
}
225232

226-
ToolbarHelper::preferences('com_associations');
233+
$toolbar->preferences('com_associations');
227234
}
228235

229-
ToolbarHelper::help('Multilingual_Associations');
236+
$toolbar->help('Multilingual_Associations');
230237
}
231238
}

administrator/components/com_banners/src/View/Banner/HtmlView.php

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Joomla\CMS\Language\Text;
1919
use Joomla\CMS\MVC\View\GenericDataException;
2020
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
21+
use Joomla\CMS\Toolbar\Toolbar;
2122
use Joomla\CMS\Toolbar\ToolbarHelper;
2223
use Joomla\Component\Banners\Administrator\Model\BannerModel;
2324

@@ -101,45 +102,49 @@ protected function addToolbar(): void
101102
$userId = $user->id;
102103
$isNew = ($this->item->id == 0);
103104
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $userId);
105+
$toolbar = Toolbar::getInstance();
104106

105107
// Since we don't track these assets at the item level, use the category id.
106108
$canDo = ContentHelper::getActions('com_banners', 'category', $this->item->catid);
107109

108110
ToolbarHelper::title($isNew ? Text::_('COM_BANNERS_MANAGER_BANNER_NEW') : Text::_('COM_BANNERS_MANAGER_BANNER_EDIT'), 'bookmark banners');
109111

110-
$toolbarButtons = [];
111-
112112
// If not checked out, can save the item.
113113
if (!$checkedOut && ($canDo->get('core.edit') || \count($user->getAuthorisedCategories('com_banners', 'core.create')) > 0)) {
114-
ToolbarHelper::apply('banner.apply');
115-
$toolbarButtons[] = ['save', 'banner.save'];
116-
117-
if ($canDo->get('core.create')) {
118-
$toolbarButtons[] = ['save2new', 'banner.save2new'];
119-
}
114+
$toolbar->apply('banner.apply');
120115
}
121116

122-
// If an existing item, can save to a copy.
123-
if (!$isNew && $canDo->get('core.create')) {
124-
$toolbarButtons[] = ['save2copy', 'banner.save2copy'];
125-
}
117+
$saveGroup = $toolbar->dropdownButton('save-group');
126118

127-
ToolbarHelper::saveGroup(
128-
$toolbarButtons,
129-
'btn-success'
119+
$saveGroup->configure(
120+
function (Toolbar $childBar) use ($checkedOut, $canDo, $user, $isNew) {
121+
// If not checked out, can save the item.
122+
if (!$checkedOut && ($canDo->get('core.edit') || \count($user->getAuthorisedCategories('com_banners', 'core.create')) > 0)) {
123+
$childBar->save('banner.save');
124+
125+
if ($canDo->get('core.create')) {
126+
$childBar->save2new('banner.save2new');
127+
}
128+
}
129+
130+
// If an existing item, can save to a copy.
131+
if (!$isNew && $canDo->get('core.create')) {
132+
$childBar->save2copy('banner.save2copy');
133+
}
134+
}
130135
);
131136

132137
if (empty($this->item->id)) {
133-
ToolbarHelper::cancel('banner.cancel');
138+
$toolbar->cancel('banner.cancel', 'JTOOLBAR_CANCEL');
134139
} else {
135-
ToolbarHelper::cancel('banner.cancel', 'JTOOLBAR_CLOSE');
140+
$toolbar->cancel('banner.cancel');
136141

137142
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $canDo->get('core.edit')) {
138-
ToolbarHelper::versions('com_banners.banner', $this->item->id);
143+
$toolbar->versions('com_banners.banner', $this->item->id);
139144
}
140145
}
141146

142-
ToolbarHelper::divider();
143-
ToolbarHelper::help('Banners:_Edit');
147+
$toolbar->divider();
148+
$toolbar->help('Banners:_Edit');
144149
}
145150
}

administrator/components/com_banners/src/View/Banners/HtmlView.php

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Joomla\CMS\MVC\View\GenericDataException;
2020
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
2121
use Joomla\CMS\Pagination\Pagination;
22+
use Joomla\CMS\Toolbar\Button\DropdownButton;
2223
use Joomla\CMS\Toolbar\Toolbar;
2324
use Joomla\CMS\Toolbar\ToolbarHelper;
2425
use Joomla\Component\Banners\Administrator\Model\BannersModel;
@@ -141,11 +142,9 @@ public function display($tpl = null): void
141142
*/
142143
protected function addToolbar(): void
143144
{
144-
$canDo = ContentHelper::getActions('com_banners', 'category', $this->state->get('filter.category_id'));
145-
$user = Factory::getApplication()->getIdentity();
146-
147-
// Get the toolbar object instance
148-
$toolbar = Toolbar::getInstance('toolbar');
145+
$canDo = ContentHelper::getActions('com_banners', 'category', $this->state->get('filter.category_id'));
146+
$user = Factory::getApplication()->getIdentity();
147+
$toolbar = Toolbar::getInstance();
149148

150149
ToolbarHelper::title(Text::_('COM_BANNERS_MANAGER_BANNERS'), 'bookmark banners');
151150

@@ -154,8 +153,8 @@ protected function addToolbar(): void
154153
}
155154

156155
if (!$this->isEmptyState && ($canDo->get('core.edit.state') || ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')))) {
157-
$dropdown = $toolbar->dropdownButton('status-group')
158-
->text('JTOOLBAR_CHANGE_STATUS')
156+
/** @var DropdownButton $dropdown */
157+
$dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS')
159158
->toggleSplit(false)
160159
->icon('icon-ellipsis-h')
161160
->buttonClass('btn btn-action')
@@ -178,16 +177,15 @@ protected function addToolbar(): void
178177
}
179178
}
180179

181-
$childBar->checkin('banners.checkin')->listCheck(true);
180+
$childBar->checkin('banners.checkin');
182181

183182
if ($this->state->get('filter.published') != -2) {
184183
$childBar->trash('banners.trash')->listCheck(true);
185184
}
186185
}
187186

188187
if ($this->state->get('filter.published') == -2 && $canDo->get('core.delete')) {
189-
$toolbar->delete('banners.delete')
190-
->text('JTOOLBAR_EMPTY_TRASH')
188+
$toolbar->delete('banners.delete', 'JTOOLBAR_EMPTY_TRASH')
191189
->message('JGLOBAL_CONFIRM_DELETE')
192190
->listCheck(true);
193191
}
@@ -198,8 +196,7 @@ protected function addToolbar(): void
198196
&& $user->authorise('core.edit', 'com_banners')
199197
&& $user->authorise('core.edit.state', 'com_banners')
200198
) {
201-
$childBar->popupButton('batch')
202-
->text('JTOOLBAR_BATCH')
199+
$childBar->popupButton('batch', 'JTOOLBAR_BATCH')
203200
->selector('collapseModal')
204201
->listCheck(true);
205202
}

administrator/components/com_banners/src/View/Client/HtmlView.php

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Joomla\CMS\MVC\View\GenericDataException;
2020
use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;
2121
use Joomla\CMS\Object\CMSObject;
22+
use Joomla\CMS\Toolbar\Toolbar;
2223
use Joomla\CMS\Toolbar\ToolbarHelper;
2324
use Joomla\Component\Banners\Administrator\Model\ClientModel;
2425

@@ -112,6 +113,7 @@ protected function addToolbar(): void
112113
$isNew = ($this->item->id == 0);
113114
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->id);
114115
$canDo = $this->canDo;
116+
$toolbar = Toolbar::getInstance();
115117

116118
ToolbarHelper::title(
117119
$isNew ? Text::_('COM_BANNERS_MANAGER_CLIENT_NEW') : Text::_('COM_BANNERS_MANAGER_CLIENT_EDIT'),
@@ -122,35 +124,39 @@ protected function addToolbar(): void
122124

123125
// If not checked out, can save the item.
124126
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
125-
ToolbarHelper::apply('client.apply');
126-
$toolbarButtons[] = ['save', 'client.save'];
127+
$toolbar->apply('client.apply');
127128
}
128129

129-
if (!$checkedOut && $canDo->get('core.create')) {
130-
$toolbarButtons[] = ['save2new', 'client.save2new'];
131-
}
132-
133-
// If an existing item, can save to a copy.
134-
if (!$isNew && $canDo->get('core.create')) {
135-
$toolbarButtons[] = ['save2copy', 'client.save2copy'];
136-
}
137-
138-
ToolbarHelper::saveGroup(
139-
$toolbarButtons,
140-
'btn-success'
130+
$saveGroup = $toolbar->dropdownButton('save-group');
131+
$saveGroup->configure(
132+
function (Toolbar $childBar) use ($checkedOut, $canDo, $isNew) {
133+
// If not checked out, can save the item.
134+
if (!$checkedOut && ($canDo->get('core.edit') || $canDo->get('core.create'))) {
135+
$childBar->save('client.save');
136+
}
137+
138+
if (!$checkedOut && $canDo->get('core.create')) {
139+
$childBar->save2new('client.save2new');
140+
}
141+
142+
// If an existing item, can save to a copy.
143+
if (!$isNew && $canDo->get('core.create')) {
144+
$childBar->save2copy('client.save2copy');
145+
}
146+
}
141147
);
142148

143149
if (empty($this->item->id)) {
144-
ToolbarHelper::cancel('client.cancel');
150+
$toolbar->cancel('client.cancel', 'JTOOLBAR_CANCEL');
145151
} else {
146-
ToolbarHelper::cancel('client.cancel', 'JTOOLBAR_CLOSE');
152+
$toolbar->cancel('client.cancel');
147153

148154
if (ComponentHelper::isEnabled('com_contenthistory') && $this->state->params->get('save_history', 0) && $canDo->get('core.edit')) {
149-
ToolbarHelper::versions('com_banners.client', $this->item->id);
155+
$toolbar->versions('com_banners.client', $this->item->id);
150156
}
151157
}
152158

153-
ToolbarHelper::divider();
154-
ToolbarHelper::help('Banners:_New_or_Edit_Client');
159+
$toolbar->divider();
160+
$toolbar->help('Banners:_New_or_Edit_Client');
155161
}
156162
}

administrator/components/com_banners/src/View/Clients/HtmlView.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,20 +125,17 @@ public function display($tpl = null): void
125125
*/
126126
protected function addToolbar(): void
127127
{
128-
$canDo = ContentHelper::getActions('com_banners');
128+
$canDo = ContentHelper::getActions('com_banners');
129+
$toolbar = Toolbar::getInstance();
129130

130131
ToolbarHelper::title(Text::_('COM_BANNERS_MANAGER_CLIENTS'), 'bookmark banners-clients');
131132

132-
// Get the toolbar object instance
133-
$toolbar = Toolbar::getInstance('toolbar');
134-
135133
if ($canDo->get('core.create')) {
136134
$toolbar->addNew('client.add');
137135
}
138136

139137
if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $canDo->get('core.admin'))) {
140-
$dropdown = $toolbar->dropdownButton('status-group')
141-
->text('JTOOLBAR_CHANGE_STATUS')
138+
$dropdown = $toolbar->dropdownButton('status-group', 'JTOOLBAR_CHANGE_STATUS')
142139
->toggleSplit(false)
143140
->icon('icon-ellipsis-h')
144141
->buttonClass('btn btn-action')
@@ -160,8 +157,7 @@ protected function addToolbar(): void
160157
}
161158

162159
if (!$this->isEmptyState && $this->state->get('filter.state') == -2 && $canDo->get('core.delete')) {
163-
$toolbar->delete('clients.delete')
164-
->text('JTOOLBAR_EMPTY_TRASH')
160+
$toolbar->delete('clients.delete', 'JTOOLBAR_EMPTY_TRASH')
165161
->message('JGLOBAL_CONFIRM_DELETE')
166162
->listCheck(true);
167163
}

0 commit comments

Comments
 (0)