Skip to content

Commit ede348e

Browse files
authored
Merge pull request #20 from KishoriBKarale/codeImprovements
Task #189184 feat: com_cluster improvements
2 parents 763d5cb + 47895d9 commit ede348e

File tree

12 files changed

+123
-97
lines changed

12 files changed

+123
-97
lines changed

src/components/com_cluster/administrator/helpers/cluster.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
defined('_JEXEC') or die('Restricted access');
1111

1212
use Joomla\CMS\Factory;
13+
use Joomla\CMS\Language\Text;
1314

1415
/**
1516
* Cluster helper.
@@ -33,13 +34,13 @@ public static function addSubmenu($vName = '')
3334
if ($layout != "default")
3435
{
3536
JHtmlSidebar::addEntry(
36-
JText::_('COM_CLUSTERS_VIEW_CLUSTERS'),
37+
Text::_('COM_CLUSTERS_VIEW_CLUSTERS'),
3738
'index.php?option=com_cluster&view=clusters',
3839
$vName == 'clusters'
3940
);
4041

4142
JHtmlSidebar::addEntry(
42-
JText::_('COM_CLUSTERS_VIEW_CLUSTER_USERS'),
43+
Text::_('COM_CLUSTERS_VIEW_CLUSTER_USERS'),
4344
'index.php?option=com_cluster&view=clusterusers',
4445
$vName == 'clusterusers'
4546
);

src/components/com_cluster/administrator/libraries/cluster.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
use Joomla\CMS\Factory;
1313
use Joomla\CMS\Object\CMSObject;
14+
use Joomla\CMS\Language\Text;
1415

1516
/**
1617
* Cluster class. Handles all application interaction with a Cluster
@@ -192,15 +193,15 @@ public function bind(&$array)
192193
{
193194
if (empty($array))
194195
{
195-
$this->setError(JText::_('COM_CLUSTER_EMPTY_DATA'));
196+
$this->setError(Text::_('COM_CLUSTER_EMPTY_DATA'));
196197

197198
return false;
198199
}
199200

200201
// Bind the array
201202
if (!$this->setProperties($array))
202203
{
203-
$this->setError(\JText::_('COM_CLUSTER_BINDING_ERROR'));
204+
$this->setError(Text::_('COM_CLUSTER_BINDING_ERROR'));
204205

205206
return false;
206207
}

src/components/com_cluster/administrator/views/cluster/view.html.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
use Joomla\CMS\Factory;
1313
use Joomla\CMS\MVC\View\HtmlView;
14+
use Joomla\CMS\Helper\ContentHelper;
15+
use Joomla\CMS\Language\Text;
16+
use Joomla\CMS\Toolbar\ToolbarHelper;
1417

1518
/**
1619
* View to edit
@@ -70,7 +73,7 @@ public function display($tpl = null)
7073
$this->form = $this->get('Form');
7174
$this->input = Factory::getApplication()->input;
7275

73-
$this->canDo = JHelperContent::getActions('com_cluster', 'cluster', $this->item->id);
76+
$this->canDo = ContentHelper::getActions('com_cluster', 'cluster', $this->item->id);
7477

7578
// Check for errors.
7679
if (count($errors = $this->get('Errors')))
@@ -110,29 +113,29 @@ protected function addToolbar()
110113
{
111114
Factory::getApplication()->input->set('hidemainmenu', true);
112115

113-
JToolbarHelper::title(
114-
JText::_('COM_CLUSTER_PAGE_' . ($checkedOut ? 'VIEW_CLUSTER' : ($isNew ? 'ADD_CLUSTER' : 'EDIT_CLUSTER'))),
116+
ToolbarHelper::title(
117+
Text::_('COM_CLUSTER_PAGE_' . ($checkedOut ? 'VIEW_CLUSTER' : ($isNew ? 'ADD_CLUSTER' : 'EDIT_CLUSTER'))),
115118
'pencil-2 cluster-add'
116119
);
117120

118121
if ($isNew)
119122
{
120-
JToolbarHelper::save('cluster.save');
121-
JToolbarHelper::cancel('cluster.cancel');
123+
ToolbarHelper::save('cluster.save');
124+
ToolbarHelper::cancel('cluster.cancel');
122125
}
123126
else
124127
{
125128
$itemEditable = $this->isEditable($canDo, $userId);
126129

127130
// Can't save the record if it's checked out and editable
128131
$this->canSave($checkedOut, $itemEditable);
129-
JToolbarHelper::cancel('cluster.cancel', 'JTOOLBAR_CLOSE');
132+
ToolbarHelper::cancel('cluster.cancel', 'JTOOLBAR_CLOSE');
130133
}
131134
}
132135
else
133136
{
134-
JToolbarHelper::title(
135-
JText::_('COM_CLUSTER_PAGE_VIEW_CLUSTER')
137+
ToolbarHelper::title(
138+
Text::_('COM_CLUSTER_PAGE_VIEW_CLUSTER')
136139
);
137140

138141
$app = Factory::getApplication();
@@ -143,7 +146,7 @@ protected function addToolbar()
143146
$this->sidebar = JHtmlSidebar::render();
144147
}
145148

146-
JToolbarHelper::divider();
149+
ToolbarHelper::divider();
147150
}
148151

149152
/**
@@ -159,7 +162,7 @@ protected function canSave($checkedOut, $itemEditable)
159162
{
160163
if (!$checkedOut && $itemEditable)
161164
{
162-
JToolbarHelper::save('cluster.save');
165+
ToolbarHelper::save('cluster.save');
163166
}
164167
}
165168

src/components/com_cluster/administrator/views/clusters/view.html.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
use Joomla\CMS\Factory;
1414
use Joomla\CMS\MVC\View\HtmlView;
1515
use Joomla\CMS\Object\CMSObject;
16+
use Joomla\CMS\Helper\ContentHelper;
17+
use Joomla\CMS\Language\Text;
18+
use Joomla\CMS\Toolbar\ToolbarHelper;
1619

1720
/**
1821
* Clusters view
@@ -93,7 +96,7 @@ public function display($tpl = null)
9396
$this->filterForm = $this->get('FilterForm');
9497
$this->activeFilters = $this->get('ActiveFilters');
9598
$this->user = Factory::getUser();
96-
$this->canDo = JHelperContent::getActions('com_cluster');
99+
$this->canDo = ContentHelper::getActions('com_cluster');
97100

98101
ClusterHelper::addSubmenu('clusters');
99102
$this->addToolbar();
@@ -111,38 +114,38 @@ public function display($tpl = null)
111114
*/
112115
protected function addToolbar()
113116
{
114-
JToolBarHelper::title(JText::_('COM_CLUSTERS_VIEW_CLUSTERS'), '');
117+
ToolbarHelper::title(Text::_('COM_CLUSTERS_VIEW_CLUSTERS'), '');
115118
$canDo = $this->canDo;
116119

117120
if ($canDo->get('core.create'))
118121
{
119-
JToolbarHelper::addNew('cluster.add');
122+
ToolbarHelper::addNew('cluster.add');
120123
}
121124

122125
if ($canDo->get('core.edit'))
123126
{
124-
JToolbarHelper::editList('cluster.edit');
127+
ToolbarHelper::editList('cluster.edit');
125128
}
126129

127130
if ($canDo->get('core.edit.state'))
128131
{
129-
JToolbarHelper::divider();
130-
JToolbarHelper::publish('clusters.publish', 'JTOOLBAR_PUBLISH', true);
131-
JToolbarHelper::unpublish('clusters.unpublish', 'JTOOLBAR_UNPUBLISH', true);
132-
JToolBarHelper::archiveList('clusters.archive', 'JTOOLBAR_ARCHIVE');
133-
JToolbarHelper::divider();
132+
ToolbarHelper::divider();
133+
ToolbarHelper::publish('clusters.publish', 'JTOOLBAR_PUBLISH', true);
134+
ToolbarHelper::unpublish('clusters.unpublish', 'JTOOLBAR_UNPUBLISH', true);
135+
ToolbarHelper::archiveList('clusters.archive', 'JTOOLBAR_ARCHIVE');
136+
ToolbarHelper::divider();
134137
}
135138

136139
if ($canDo->get('core.delete'))
137140
{
138-
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'clusters.delete', 'JTOOLBAR_DELETE');
139-
JToolbarHelper::divider();
141+
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'clusters.delete', 'JTOOLBAR_DELETE');
142+
ToolbarHelper::divider();
140143
}
141144

142145
if ($canDo->get('core.admin') || $canDo->get('core.options'))
143146
{
144-
JToolbarHelper::preferences('com_cluster');
145-
JToolbarHelper::divider();
147+
ToolbarHelper::preferences('com_cluster');
148+
ToolbarHelper::divider();
146149
}
147150
}
148151

@@ -154,11 +157,11 @@ protected function addToolbar()
154157
protected function getSortFields()
155158
{
156159
return array(
157-
'cl.id' => JText::_('JGRID_HEADING_ID'),
158-
'cl.title' => JText::_('COM_CLUSTER_LIST_CLUSTERS_NAME'),
159-
'cl.client' => JText::_('COM_CLUSTER_LIST_CLUSTERS_CLIENT'),
160-
'cl.ordering' => JText::_('JGRID_HEADING_ORDERING'),
161-
'cl.state' => JText::_('JSTATUS'),
160+
'cl.id' => Text::_('JGRID_HEADING_ID'),
161+
'cl.title' => Text::_('COM_CLUSTER_LIST_CLUSTERS_NAME'),
162+
'cl.client' => Text::_('COM_CLUSTER_LIST_CLUSTERS_CLIENT'),
163+
'cl.ordering' => Text::_('JGRID_HEADING_ORDERING'),
164+
'cl.state' => Text::_('JSTATUS'),
162165
);
163166
}
164167
}

src/components/com_cluster/administrator/views/clusteruser/view.html.php

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@
1111

1212
use Joomla\CMS\Factory;
1313
use Joomla\CMS\MVC\View\HtmlView;
14+
use Joomla\CMS\Helper\ContentHelper;
15+
use Joomla\CMS\Language\Text;
16+
use Joomla\CMS\Toolbar\ToolbarHelper;
1417

1518
/**
1619
* View to edit
@@ -70,7 +73,7 @@ public function display($tpl = null)
7073
$this->form = $this->get('Form');
7174
$this->input = Factory::getApplication()->input;
7275

73-
$this->canDo = JHelperContent::getActions('com_cluster', 'clusteruser', $this->item->id);
76+
$this->canDo = ContentHelper::getActions('com_cluster', 'clusteruser', $this->item->id);
7477

7578
// Check for errors.
7679
if (count($errors = $this->get('Errors')))
@@ -108,35 +111,35 @@ protected function addToolbar()
108111
{
109112
Factory::getApplication()->input->set('hidemainmenu', true);
110113

111-
JToolbarHelper::title(
112-
JText::_('COM_CLUSTER_PAGE_' . ($checkedOut ? 'VIEW_USER' : ($isNew ? 'ADD_USER' : 'EDIT_USER'))),
114+
ToolbarHelper::title(
115+
Text::_('COM_CLUSTER_PAGE_' . ($checkedOut ? 'VIEW_USER' : ($isNew ? 'ADD_USER' : 'EDIT_USER'))),
113116
'pencil-2 cluster-add'
114117
);
115118

116119
if ($isNew)
117120
{
118-
JToolbarHelper::save('clusteruser.save');
119-
JToolbarHelper::cancel('clusteruser.cancel');
121+
ToolbarHelper::save('clusteruser.save');
122+
ToolbarHelper::cancel('clusteruser.cancel');
120123
}
121124
else
122125
{
123126
$itemEditable = $this->isEditable($this->canDo, $user->id);
124127
$this->canSave($checkedOut, $itemEditable);
125-
JToolbarHelper::cancel('clusteruser.cancel', 'JTOOLBAR_CLOSE');
128+
ToolbarHelper::cancel('clusteruser.cancel', 'JTOOLBAR_CLOSE');
126129
}
127130
}
128131
else
129132
{
130-
JToolbarHelper::title(
131-
JText::_('COM_CLUSTER_PAGE_VIEW_CLUSTER_USER')
133+
ToolbarHelper::title(
134+
Text::_('COM_CLUSTER_PAGE_VIEW_CLUSTER_USER')
132135
);
133136

134137
ClusterHelper::addSubmenu('clusteruser');
135138

136139
$this->sidebar = JHtmlSidebar::render();
137140
}
138141

139-
JToolbarHelper::divider();
142+
ToolbarHelper::divider();
140143
}
141144

142145
/**
@@ -152,7 +155,7 @@ protected function canSave($checkedOut, $itemEditable)
152155
{
153156
if (!$checkedOut && $itemEditable)
154157
{
155-
JToolbarHelper::save('clusteruser.save');
158+
ToolbarHelper::save('clusteruser.save');
156159
}
157160
}
158161

src/components/com_cluster/administrator/views/clusterusers/view.html.php

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313
use Joomla\CMS\Factory;
1414
use Joomla\CMS\MVC\View\HtmlView;
15+
use Joomla\CMS\Helper\ContentHelper;
16+
use Joomla\CMS\Language\Text;
17+
use Joomla\CMS\Toolbar\ToolbarHelper;
1518

1619
/**
1720
* Clusters view
@@ -92,7 +95,7 @@ public function display($tpl = null)
9295
$this->filterForm = $this->get('FilterForm');
9396
$this->activeFilters = $this->get('ActiveFilters');
9497
$this->user = Factory::getUser();
95-
$this->canDo = JHelperContent::getActions('com_cluster');
98+
$this->canDo = ContentHelper::getActions('com_cluster');
9699

97100
ClusterHelper::addSubmenu('clusterusers');
98101
$this->addToolbar();
@@ -110,37 +113,37 @@ public function display($tpl = null)
110113
*/
111114
protected function addToolbar()
112115
{
113-
JToolBarHelper::title(JText::_('COM_CLUSTERS_VIEW_CLUSTERS'), '');
116+
ToolBarHelper::title(Text::_('COM_CLUSTERS_VIEW_CLUSTERS'), '');
114117

115118
if ($this->canDo->get('core.create'))
116119
{
117-
JToolbarHelper::addNew('clusteruser.add');
120+
ToolBarHelper::addNew('clusteruser.add');
118121
}
119122

120123
if ($this->canDo->get('core.edit'))
121124
{
122-
JToolbarHelper::editList('clusteruser.edit');
125+
ToolBarHelper::editList('clusteruser.edit');
123126
}
124127

125128
if ($this->canDo->get('core.edit.state'))
126129
{
127-
JToolbarHelper::divider();
128-
JToolbarHelper::publish('clusteruser.publish', 'JTOOLBAR_PUBLISH', true);
129-
JToolbarHelper::unpublish('clusteruser.unpublish', 'JTOOLBAR_UNPUBLISH', true);
130-
JToolBarHelper::archiveList('clusteruser.archive', 'JTOOLBAR_ARCHIVE');
131-
JToolbarHelper::divider();
130+
ToolBarHelper::divider();
131+
ToolBarHelper::publish('clusteruser.publish', 'JTOOLBAR_PUBLISH', true);
132+
ToolBarHelper::unpublish('clusteruser.unpublish', 'JTOOLBAR_UNPUBLISH', true);
133+
ToolBarHelper::archiveList('clusteruser.archive', 'JTOOLBAR_ARCHIVE');
134+
ToolBarHelper::divider();
132135
}
133136

134137
if ($this->canDo->get('core.delete'))
135138
{
136-
JToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'clusterusers.delete', 'JTOOLBAR_DELETE');
137-
JToolbarHelper::divider();
139+
ToolBarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'clusterusers.delete', 'JTOOLBAR_DELETE');
140+
ToolBarHelper::divider();
138141
}
139142

140143
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
141144
{
142-
JToolbarHelper::preferences('com_cluster');
143-
JToolbarHelper::divider();
145+
ToolBarHelper::preferences('com_cluster');
146+
ToolBarHelper::divider();
144147
}
145148
}
146149

@@ -152,11 +155,11 @@ protected function addToolbar()
152155
protected function getSortFields()
153156
{
154157
return array(
155-
'cl.id' => JText::_('JGRID_HEADING_ID'),
156-
'cl.title' => JText::_('COM_CLUSTER_LIST_CLUSTERS_NAME'),
157-
'cl.client' => JText::_('COM_CLUSTER_LIST_CLUSTERS_CLIENT'),
158-
'cl.ordering' => JText::_('JGRID_HEADING_ORDERING'),
159-
'cl.state' => JText::_('JSTATUS'),
158+
'cl.id' => Text::_('JGRID_HEADING_ID'),
159+
'cl.title' => Text::_('COM_CLUSTER_LIST_CLUSTERS_NAME'),
160+
'cl.client' => Text::_('COM_CLUSTER_LIST_CLUSTERS_CLIENT'),
161+
'cl.ordering' => Text::_('JGRID_HEADING_ORDERING'),
162+
'cl.state' => Text::_('JSTATUS'),
160163
);
161164
}
162165
}

src/components/com_cluster/site/cluster.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88

99
defined('_JEXEC') or die;
10+
use Joomla\CMS\Factory;
11+
use Joomla\CMS\MVC\Controller\BaseController;
1012

1113
// Include dependancies
1214
jimport('joomla.application.component.controller');
@@ -16,6 +18,6 @@
1618

1719

1820
// Execute the task.
19-
$controller = JControllerLegacy::getInstance('Cluster');
20-
$controller->execute(JFactory::getApplication()->input->get('task'));
21+
$controller = BaseController::getInstance('Cluster');
22+
$controller->execute(Factory::getApplication()->input->get('task'));
2123
$controller->redirect();

0 commit comments

Comments
 (0)