Skip to content

Commit 22ea525

Browse files
frankmayerwilsonge
authored andcommitted
Cleanups, fixes and a bit of optimizations for site/components batch #3 (#12292)
* Cleanups, fixes and a bit of optimizations for site/components batch #3 - com_content Note: This is a single commit bundling all types of changes, since PR #12261 which had detailed commits, was rejected as a whole * Ch-Ch-Ch-Changes! Made some changes as pointed out by @andrepereiradasilva * A bit more... * Revert * Removed empty function, as there is a fallback. Change made according to comment from @wilsonge * Included @andrepereiradasilva's suggestions * Inserting whitespace before php closing tag
1 parent 239b6ac commit 22ea525

File tree

20 files changed

+55
-70
lines changed

20 files changed

+55
-70
lines changed

components/com_content/controller.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ public function display($cachable = false, $urlparams = false)
7070
$user = JFactory::getUser();
7171

7272
if ($user->get('id')
73-
|| ($this->input->getMethod() == 'POST'
74-
&& (($vName == 'category' && $this->input->get('layout') != 'blog') || $vName == 'archive' )))
73+
|| ($this->input->getMethod() === 'POST'
74+
&& (($vName === 'category' && $this->input->get('layout') !== 'blog') || $vName === 'archive' )))
7575
{
7676
$cachable = false;
7777
}
@@ -95,13 +95,13 @@ public function display($cachable = false, $urlparams = false)
9595
'Itemid' => 'INT');
9696

9797
// Check for edit form.
98-
if ($vName == 'form' && !$this->checkEditId('com_content.edit.article', $id))
98+
if ($vName === 'form' && !$this->checkEditId('com_content.edit.article', $id))
9999
{
100100
// Somehow the person just went to the form - we don't allow that.
101101
return JError::raiseError(403, JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
102102
}
103103

104-
if ($vName == 'article')
104+
if ($vName === 'article')
105105
{
106106
// Get/Create the model
107107
if ($model = $this->getModel($vName))

components/com_content/controllers/article.php

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -274,21 +274,6 @@ protected function getReturnPage()
274274
}
275275
}
276276

277-
/**
278-
* Function that allows child controller access to model data after the data has been saved.
279-
*
280-
* @param JModelLegacy $model The data model object.
281-
* @param array $validData The validated data.
282-
*
283-
* @return void
284-
*
285-
* @since 1.6
286-
*/
287-
protected function postSaveHook(JModelLegacy $model, $validData = array())
288-
{
289-
return;
290-
}
291-
292277
/**
293278
* Method to save a record.
294279
*

components/com_content/helpers/association.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ abstract class ContentHelperAssociation extends CategoryHelperAssociation
3333
public static function getAssociations($id = 0, $view = null)
3434
{
3535
$jinput = JFactory::getApplication()->input;
36-
$view = is_null($view) ? $jinput->get('view') : $view;
36+
$view = $view === null ? $jinput->get('view') : $view;
3737
$id = empty($id) ? $jinput->getInt('id') : $id;
3838

39-
if ($view == 'article' || $view == 'category' || $view == 'featured')
39+
if ($view === 'article' || $view === 'category' || $view === 'featured')
4040
{
4141
if ($id)
4242
{
@@ -53,7 +53,7 @@ public static function getAssociations($id = 0, $view = null)
5353
}
5454
}
5555

56-
if ($view == 'category' || $view == 'categories')
56+
if ($view === 'category' || $view === 'categories')
5757
{
5858
return self::getCategoryAssociations($id, 'com_content');
5959
}

components/com_content/helpers/query.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ public static function buildVotingQuery($params = null)
212212
$join = '';
213213
}
214214

215-
return array ('select' => $select, 'join' => $join);
215+
return array('select' => $select, 'join' => $join);
216216
}
217217

218218
/**

components/com_content/helpers/route.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public static function getArticleRoute($id, $catid = 0, $language = 0)
3737
$link .= '&catid=' . $catid;
3838
}
3939

40-
if ($language && $language != '*' && JLanguageMultilang::isEnabled())
40+
if ($language && $language !== '*' && JLanguageMultilang::isEnabled())
4141
{
4242
$link .= '&lang=' . $language;
4343
}
@@ -74,7 +74,7 @@ public static function getCategoryRoute($catid, $language = 0)
7474
{
7575
$link = 'index.php?option=com_content&view=category&id=' . $id;
7676

77-
if ($language && $language != '*' && JLanguageMultilang::isEnabled())
77+
if ($language && $language !== '*' && JLanguageMultilang::isEnabled())
7878
{
7979
$link .= '&lang=' . $language;
8080
}

components/com_content/models/articles.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ protected function getListQuery()
225225
// Join over the frontpage articles if required.
226226
if ($this->getState('filter.frontpage'))
227227
{
228-
if ($orderby_sec == 'front')
228+
if ($orderby_sec === 'front')
229229
{
230230
$query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id');
231231
}
@@ -234,7 +234,7 @@ protected function getListQuery()
234234
$query->where('a.featured = 1');
235235
}
236236
}
237-
elseif ($orderby_sec == 'front' || $this->getState('list.ordering') == 'fp.ordering')
237+
elseif ($orderby_sec === 'front' || $this->getState('list.ordering') === 'fp.ordering')
238238
{
239239
$query->join('LEFT', '#__content_frontpage AS fp ON fp.content_id = a.id');
240240
}
@@ -503,7 +503,7 @@ protected function getListQuery()
503503
}
504504

505505
// Process the filter for list views with user-entered filters
506-
if (is_object($params) && ($params->get('filter_field') != 'hide') && ($filter = $this->getState('list.filter')))
506+
if (is_object($params) && ($params->get('filter_field') !== 'hide') && ($filter = $this->getState('list.filter')))
507507
{
508508
// Clean filter variable
509509
$filter = StringHelper::strtolower($filter);
@@ -591,8 +591,8 @@ public function getItems()
591591
/*For blogs, article params override menu item params only if menu param = 'use_article'
592592
Otherwise, menu item params control the layout
593593
If menu item is 'use_article' and there is no article param, use global*/
594-
if (($input->getString('layout') == 'blog') || ($input->getString('view') == 'featured')
595-
|| ($this->getState('params')->get('layout_type') == 'blog'))
594+
if (($input->getString('layout') === 'blog') || ($input->getString('view') === 'featured')
595+
|| ($this->getState('params')->get('layout_type') === 'blog'))
596596
{
597597
// Create an array of just the params set to 'use_article'
598598
$menuParamsArray = $this->getState('params')->toArray();

components/com_content/models/category.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ protected function populateState($ordering = null, $direction = null)
187187
$this->setState('list.start', $app->input->get('limitstart', 0, 'uint'));
188188

189189
// Set limit for query. If list, use parameter. If blog, add blog parameters for limit.
190-
if (($app->input->get('layout') == 'blog') || $params->get('layout_type') == 'blog')
190+
if (($app->input->get('layout') === 'blog') || $params->get('layout_type') === 'blog')
191191
{
192192
$limit = $params->get('num_leading_articles') + $params->get('num_intro_articles') + $params->get('num_links');
193193
$this->setState('list.links', $params->get('num_links'));
@@ -458,9 +458,11 @@ public function &getChildren()
458458
{
459459
$params = $this->getState()->get('params');
460460

461-
if ($params->get('orderby_pri') == 'alpha' || $params->get('orderby_pri') == 'ralpha')
461+
$orderByPri = $params->get('orderby_pri');
462+
463+
if ($orderByPri === 'alpha' || $orderByPri === 'ralpha')
462464
{
463-
$this->_children = ArrayHelper::sortObjects($this->_children, 'title', ($params->get('orderby_pri') == 'alpha') ? 1 : (-1));
465+
$this->_children = ArrayHelper::sortObjects($this->_children, 'title', ($orderByPri === 'alpha') ? 1 : (-1));
464466
}
465467
}
466468

components/com_content/models/form.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -177,17 +177,15 @@ public function getReturnPage()
177177
public function save($data)
178178
{
179179
// Associations are not edited in frontend ATM so we have to inherit them
180-
if (JLanguageAssociations::isEnabled() && !empty($data['id']))
180+
if (JLanguageAssociations::isEnabled() && !empty($data['id'])
181+
&& $associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $data['id']))
181182
{
182-
if ($associations = JLanguageAssociations::getAssociations('com_content', '#__content', 'com_content.item', $data['id']))
183+
foreach ($associations as $tag => $associated)
183184
{
184-
foreach ($associations as $tag => $associated)
185-
{
186-
$associations[$tag] = (int) $associated->id;
187-
}
188-
189-
$data['associations'] = $associations;
185+
$associations[$tag] = (int) $associated->id;
190186
}
187+
188+
$data['associations'] = $associations;
191189
}
192190

193191
return parent::save($data);

components/com_content/views/archive/tmpl/default.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
<form id="adminForm" action="<?php echo JRoute::_('index.php'); ?>" method="post" class="form-inline">
2525
<fieldset class="filters">
2626
<div class="filter-search">
27-
<?php if ($this->params->get('filter_field') != 'hide') : ?>
27+
<?php if ($this->params->get('filter_field') !== 'hide') : ?>
2828
<label class="filter-search-lbl element-invisible" for="filter-search"><?php echo JText::_('COM_CONTENT_TITLE_FILTER_LABEL') . '&#160;'; ?></label>
2929
<input type="text" name="filter-search" id="filter-search" value="<?php echo $this->escape($this->filter); ?>" class="inputbox span2" onchange="document.getElementById('adminForm').submit();" placeholder="<?php echo JText::_('COM_CONTENT_TITLE_FILTER_LABEL'); ?>" />
3030
<?php endif; ?>

components/com_content/views/archive/view.html.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function display($tpl = null)
4949
$item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
5050

5151
// No link for ROOT category
52-
if ($item->parent_alias == 'root')
52+
if ($item->parent_alias === 'root')
5353
{
5454
$item->parent_slug = null;
5555
}
@@ -114,7 +114,7 @@ public function display($tpl = null)
114114
$years = array();
115115
$years[] = JHtml::_('select.option', null, JText::_('JYEAR'));
116116

117-
for ($i = 0; $i < count($this->years); $i++)
117+
for ($i = 0, $iMax = count($this->years); $i < $iMax; $i++)
118118
{
119119
$years[] = JHtml::_('select.option', $this->years[$i], $this->years[$i]);
120120
}

0 commit comments

Comments
 (0)