Skip to content

Commit

Permalink
Cleanups, fixes and a bit of optimizations for site/components batch #5
Browse files Browse the repository at this point in the history
… (joomla#12294)

* Cleanups, fixes and a bit of optimizations for site/components batch #5

- com_tags
- com_users
- com_wrapper

Note: This is a single commit bundling all types of changes, since PR joomla#12261 which had detailed commits, was rejected as a whole

* Some more fixes after conflict resolution

* - Changed some things according to reviewer's suggestions
- Some more changes in updated stuff
  • Loading branch information
frankmayer authored and rdeutz committed Jun 8, 2017
1 parent 778153e commit 7fc2cd3
Show file tree
Hide file tree
Showing 25 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion components/com_tags/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function display($cachable = false, $urlparams = false)
$vName = $this->input->get('view', 'tags');
$this->input->set('view', $vName);

if ($user->get('id') || ($this->input->getMethod() == 'POST' && $vName == 'tags'))
if ($user->get('id') || ($this->input->getMethod() === 'POST' && $vName === 'tags'))
{
$cachable = false;
}
Expand Down
6 changes: 3 additions & 3 deletions components/com_tags/helpers/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public static function getItemRoute($contentItemId, $contentItemAlias, $contentC

if (class_exists($routerClass) && method_exists($routerClass, $routerMethod))
{
if ($routerMethod == 'getCategoryRoute')
if ($routerMethod === 'getCategoryRoute')
{
$link = $routerClass::$routerMethod($contentItemId, $language);
}
Expand All @@ -57,7 +57,7 @@ public static function getItemRoute($contentItemId, $contentItemAlias, $contentC
}
}

if ($link == '')
if ($link === '')
{
// Create a fallback link in case we can't find the component router
$router = new JHelperRoute;
Expand Down Expand Up @@ -158,7 +158,7 @@ protected static function _findItem($needles = null)
{
foreach ($items as $item)
{
if (isset($item->query) && isset($item->query['view']))
if (isset($item->query, $item->query['view']))
{
$lang = ($item->language != '' ? $item->language : '*');

Expand Down
4 changes: 2 additions & 2 deletions components/com_tags/models/tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected function populateState($ordering = 'c.core_title', $direction = 'ASC')
// List state information
$format = $app->input->getWord('format');

if ($format == 'feed')
if ($format === 'feed')
{
$limit = $app->get('feed_limit');
}
Expand Down Expand Up @@ -258,7 +258,7 @@ protected function populateState($ordering = 'c.core_title', $direction = 'ASC')
*/
public function getItem($pk = null)
{
if (!isset($this->item) ||$this->item === null)
if (!isset($this->item))
{
$this->item = false;

Expand Down
6 changes: 3 additions & 3 deletions components/com_tags/models/tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ protected function getListQuery()
$language = JComponentHelper::getParams('com_tags')->get('tag_list_language_filter', 'all');
}

if ($language != 'all')
if ($language !== 'all')
{
if ($language == 'current_language')
if ($language === 'current_language')
{
$language = JHelperContent::getCurrentLanguage();
}
Expand All @@ -156,7 +156,7 @@ protected function getListQuery()
// List state information
$format = $app->input->getWord('format');

if ($format == 'feed')
if ($format === 'feed')
{
$limit = $app->get('feed_limit');
}
Expand Down
4 changes: 2 additions & 2 deletions components/com_tags/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function build(&$query)
return $segments;
}

if ($view == 'tag')
if ($view === 'tag')
{
$notActiveTag = is_array($mId) ? (count($mId) > 1 || $mId[0] != (int) $query['id']) : ($mId != (int) $query['id']);

Expand All @@ -92,7 +92,7 @@ public function build(&$query)
{
if ((!empty($query['Itemid']) && isset($menuItem->query['layout'])
&& $query['layout'] == $menuItem->query['layout'])
|| $query['layout'] == 'default')
|| $query['layout'] === 'default')
{
unset($query['layout']);
}
Expand Down
4 changes: 2 additions & 2 deletions components/com_tags/views/tag/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// Note that there are certain parts of this layout used only when there is exactly one tag.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
$isSingleTag = (count($this->item) == 1);
$isSingleTag = count($this->item) === 1;
?>
<div class="tag-category<?php echo $this->pageclass_sfx; ?>">
<?php if ($this->params->get('show_page_heading')) : ?>
Expand All @@ -25,7 +25,7 @@
</h2>
<?php endif; ?>
<?php // We only show a tag description if there is a single tag. ?>
<?php if (count($this->item) == 1 && ($this->params->get('tag_list_show_tag_image', 1) || $this->params->get('tag_list_show_tag_description', 1))) : ?>
<?php if (count($this->item) === 1 && ($this->params->get('tag_list_show_tag_image', 1) || $this->params->get('tag_list_show_tag_description', 1))) : ?>
<div class="category-desc">
<?php $images = json_decode($this->item[0]->images); ?>
<?php if ($this->params->get('tag_list_show_tag_image', 1) == 1 && !empty($images->image_fulltext)) : ?>
Expand Down
4 changes: 2 additions & 2 deletions components/com_tags/views/tag/tmpl/default_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
</fieldset>
<?php endif; ?>

<?php if ($this->items == false || $n == 0) : ?>
<?php if ($this->items === false || $n === 0) : ?>
<p> <?php echo JText::_('COM_TAGS_NO_ITEMS'); ?></p>
<?php else : ?>

Expand All @@ -74,7 +74,7 @@
<li class="system-unpublished cat-list-row<?php echo $i % 2; ?>">
<?php else : ?>
<li class="cat-list-row<?php echo $i % 2; ?> clearfix" >
<?php if (($item->type_alias == 'com_users.category') || ($item->type_alias == 'com_banners.category')) : ?>
<?php if (($item->type_alias === 'com_users.category') || ($item->type_alias === 'com_banners.category')) : ?>
<h3>
<?php echo $this->escape($item->core_title); ?>
</h3>
Expand Down
2 changes: 1 addition & 1 deletion components/com_tags/views/tag/tmpl/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</h2>
<?php endif; ?>
<?php // We only show a tag description if there is a single tag. ?>
<?php if (count($this->item) == 1 && ($this->params->get('tag_list_show_tag_image', 1) || $this->params->get('tag_list_show_tag_description', 1))) : ?>
<?php if (count($this->item) === 1 && ($this->params->get('tag_list_show_tag_image', 1) || $this->params->get('tag_list_show_tag_description', 1))) : ?>
<div class="category-desc">
<?php $images = json_decode($this->item[0]->images); ?>
<?php if ($this->params->get('tag_list_show_tag_image', 1) == 1 && !empty($images->image_fulltext)) : ?>
Expand Down
8 changes: 4 additions & 4 deletions components/com_tags/views/tag/tmpl/list_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</fieldset>
<?php endif; ?>

<?php if ($this->items == false || $n == 0) : ?>
<?php if ($this->items === false || $n === 0) : ?>
<p> <?php echo JText::_('COM_TAGS_NO_ITEMS'); ?></p>
<?php else : ?>
<table class="category table table-striped table-bordered table-hover">
Expand All @@ -68,11 +68,11 @@
</th>
<?php if ($date = $this->params->get('tag_list_show_date')) : ?>
<th id="categorylist_header_date">
<?php if ($date == 'created') : ?>
<?php if ($date === 'created') : ?>
<?php echo JHtml::_('grid.sort', 'COM_TAGS_' . $date . '_DATE', 'c.core_created_time', $listDirn, $listOrder); ?>
<?php elseif ($date == 'modified') : ?>
<?php elseif ($date === 'modified') : ?>
<?php echo JHtml::_('grid.sort', 'COM_TAGS_' . $date . '_DATE', 'c.core_modified_time', $listDirn, $listOrder); ?>
<?php elseif ($date == 'published') : ?>
<?php elseif ($date === 'published') : ?>
<?php echo JHtml::_('grid.sort', 'COM_TAGS_' . $date . '_DATE', 'c.core_publish_up', $listDirn, $listOrder); ?>
<?php endif; ?>
</th>
Expand Down
4 changes: 2 additions & 2 deletions components/com_tags/views/tag/view.feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function display($tpl = null)
$feedEmail = $app->get('feed_email', 'none');
$document->editor = $fromName;

if ($feedEmail != 'none')
if ($feedEmail !== 'none')
{
$document->editorEmail = $siteEmail;
}
Expand Down Expand Up @@ -69,7 +69,7 @@ public function display($tpl = null)
$feeditem->category = $title;
$feeditem->author = $author;

if ($feedEmail == 'site')
if ($feedEmail === 'site')
{
$item->authorEmail = $siteEmail;
}
Expand Down
2 changes: 1 addition & 1 deletion components/com_tags/views/tag/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ protected function _prepareDocument()
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
$title = $this->params->get('page_title', $menu->title);

if ($menu->query['option'] != 'com_tags')
if ($menu->query['option'] !== 'com_tags')
{
$this->params->set('page_subheading', $menu->title);
}
Expand Down
6 changes: 3 additions & 3 deletions components/com_tags/views/tags/tmpl/default_items.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@
</fieldset>
<?php endif; ?>

<?php if ($this->items == false || $n == 0) : ?>
<?php if ($this->items == false || $n === 0) : ?>
<p><?php echo JText::_('COM_TAGS_NO_TAGS'); ?></p>
<?php else : ?>
<?php foreach ($this->items as $i => $item) : ?>
<?php if ($n == 1 || $i == 0 || $bscolumns == 1 || $i % $bscolumns == 0) : ?>
<?php if ($n === 1 || $i === 0 || $bscolumns === 1 || $i % $bscolumns === 0) : ?>
<ul class="thumbnails">
<?php endif; ?>
<?php if ((!empty($item->access)) && in_array($item->access, $this->user->getAuthorisedViewLevels())) : ?>
Expand Down Expand Up @@ -124,7 +124,7 @@
</div>
</li>

<?php if (($i == 0 && $n == 1) || $i == $n - 1 || $bscolumns == 1 || (($i + 1) % $bscolumns == 0)) : ?>
<?php if (($i === 0 && $n === 1) || $i === $n - 1 || $bscolumns === 1 || (($i + 1) % $bscolumns === 0)) : ?>
</ul>
<?php endif; ?>

Expand Down
4 changes: 2 additions & 2 deletions components/com_tags/views/tags/view.feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function display($tpl = null)
$feedEmail = $app->get('feed_email', 'none');
$document->editor = $fromName;

if ($feedEmail != 'none')
if ($feedEmail !== 'none')
{
$document->editorEmail = $siteEmail;
}
Expand Down Expand Up @@ -63,7 +63,7 @@ public function display($tpl = null)
$feeditem->category = 'All Tags';
$feeditem->author = $author;

if ($feedEmail == 'site')
if ($feedEmail === 'site')
{
$item->authorEmail = $siteEmail;
}
Expand Down
2 changes: 1 addition & 1 deletion components/com_tags/views/tags/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected function _prepareDocument()
$this->params->def('page_heading', JText::_('COM_TAGS_DEFAULT_PAGE_TITLE'));
}

if ($menu && ($menu->query['option'] != 'com_tags'))
if ($menu && $menu->query['option'] !== 'com_tags')
{
$this->params->set('page_subheading', $menu->title);
}
Expand Down
2 changes: 1 addition & 1 deletion components/com_users/helpers/html/users.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public static function helpsite($value)

$value = htmlspecialchars($value, ENT_COMPAT, 'UTF-8');

if (substr($value, 0, 4) == 'http')
if (strpos($value, 'http') !== 0)
{
return '<a href="' . $value . '">' . $text . '</a>';
}
Expand Down
12 changes: 6 additions & 6 deletions components/com_users/helpers/legacyrouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,37 +77,37 @@ public function build(&$query, &$segments)
for ($i = 0, $n = count($items); $i < $n; $i++)
{
// Check to see if we have found the resend menu item.
if (empty($resend) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'resend'))
if (empty($resend) && !empty($items[$i]->query['view']) && $items[$i]->query['view'] === 'resend')
{
$resend = $items[$i]->id;
}

// Check to see if we have found the reset menu item.
if (empty($reset) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'reset'))
if (empty($reset) && !empty($items[$i]->query['view']) && $items[$i]->query['view'] === 'reset')
{
$reset = $items[$i]->id;
}

// Check to see if we have found the remind menu item.
if (empty($remind) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'remind'))
if (empty($remind) && !empty($items[$i]->query['view']) && $items[$i]->query['view'] === 'remind')
{
$remind = $items[$i]->id;
}

// Check to see if we have found the login menu item.
if (empty($login) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'login'))
if (empty($login) && !empty($items[$i]->query['view']) && $items[$i]->query['view'] === 'login')
{
$login = $items[$i]->id;
}

// Check to see if we have found the registration menu item.
if (empty($registration) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'registration'))
if (empty($registration) && !empty($items[$i]->query['view']) && $items[$i]->query['view'] === 'registration')
{
$registration = $items[$i]->id;
}

// Check to see if we have found the profile menu item.
if (empty($profile) && !empty($items[$i]->query['view']) && ($items[$i]->query['view'] == 'profile'))
if (empty($profile) && !empty($items[$i]->query['view']) && $items[$i]->query['view'] === 'profile')
{
$profile = $items[$i]->id;
}
Expand Down
8 changes: 4 additions & 4 deletions components/com_users/models/profile.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ public function getForm($data = array(), $loadData = true)
if ($username)
{
$isUsernameCompliant = !(preg_match('#[<>"\'%;()&\\\\]|\\.\\./#', $username) || strlen(utf8_decode($username)) < 2
|| trim($username) != $username);
|| trim($username) !== $username);
}

$this->setState('user.username.compliant', $isUsernameCompliant);

if (!JComponentHelper::getParams('com_users')->get('change_login_name') && $isUsernameCompliant)
if ($isUsernameCompliant && !JComponentHelper::getParams('com_users')->get('change_login_name'))
{
$form->setFieldAttribute('username', 'class', '');
$form->setFieldAttribute('username', 'filter', '');
Expand Down Expand Up @@ -311,7 +311,7 @@ public function save($data)
// Unset the username if it should not be overwritten
$isUsernameCompliant = $this->getState('user.username.compliant');

if (!JComponentHelper::getParams('com_users')->get('change_login_name') && $isUsernameCompliant)
if ($isUsernameCompliant && !JComponentHelper::getParams('com_users')->get('change_login_name'))
{
unset($data['username']);
}
Expand All @@ -329,7 +329,7 @@ public function save($data)
// Get the current One Time Password (two factor auth) configuration
$otpConfig = $model->getOtpConfig($userId);

if ($twoFactorMethod != 'none')
if ($twoFactorMethod !== 'none')
{
// Run the plugins
FOFPlatform::getInstance()->importPlugin('twofactorauth');
Expand Down
4 changes: 2 additions & 2 deletions components/com_users/models/rules/loginuniquefield.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public function test(SimpleXMLElement $element, $value, $group = null, Registry
$loginRedirectUrl = $input['params']->login_redirect_url;
$loginRedirectMenuitem = $input['params']->login_redirect_menuitem;

if (is_null($form))
if ($form === null)
{
throw new InvalidArgumentException(sprintf('The value for $form must not be null in %s', get_class($this)));
}

if (is_null($input))
if ($input === null)
{
throw new InvalidArgumentException(sprintf('The value for $input must not be null in %s', get_class($this)));
}
Expand Down
4 changes: 2 additions & 2 deletions components/com_users/models/rules/logoutuniquefield.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ public function test(SimpleXMLElement $element, $value, $group = null, Registry
$logoutRedirectUrl = $input['params']->logout_redirect_url;
$logoutRedirectMenuitem = $input['params']->logout_redirect_menuitem;

if (is_null($form))
if ($form === null)
{
throw new InvalidArgumentException(sprintf('The value for $form must not be null in %s', get_class($this)));
}

if (is_null($input))
if ($input === null)
{
throw new InvalidArgumentException(sprintf('The value for $input must not be null in %s', get_class($this)));
}
Expand Down
2 changes: 1 addition & 1 deletion components/com_users/views/login/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

$cookieLogin = $this->user->get('cookieLogin');

if ($this->user->get('guest') || !empty($cookieLogin))
if (!empty($cookieLogin) || $this->user->get('guest'))
{
// The user is not logged in or needs to provide a password.
echo $this->loadTemplate('login');
Expand Down
2 changes: 1 addition & 1 deletion components/com_users/views/profile/tmpl/default_custom.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
<?php $fields = $this->form->getFieldset($group); ?>
<?php if (count($fields)) : ?>
<fieldset id="users-profile-custom-<?php echo $group; ?>" class="users-profile-custom-<?php echo $group; ?>">
<?php if (isset($fieldset->label) && strlen($legend = trim(JText::_($fieldset->label)))) : ?>
<?php if (isset($fieldset->label) && ($legend = trim(JText::_($fieldset->label))) !== '') : ?>
<legend><?php echo $legend; ?></legend>
<?php endif; ?>
<?php if (isset($fieldset->description) && trim($fieldset->description)) : ?>
Expand Down
4 changes: 2 additions & 2 deletions components/com_users/views/profile/tmpl/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
<?php if (!$field->required && $field->type != 'Spacer') : ?>
<?php if (!$field->required && $field->type !== 'Spacer') : ?>
<span class="optional"><?php echo JText::_('COM_USERS_OPTIONAL'); ?></span>
<?php endif; ?>
</div>
<div class="controls">
<?php if ($field->fieldname == 'password1') : ?>
<?php if ($field->fieldname === 'password1') : ?>
<?php // Disables autocomplete ?> <input type="password" style="display:none">
<?php endif; ?>
<?php echo $field->input; ?>
Expand Down
2 changes: 1 addition & 1 deletion components/com_users/views/registration/tmpl/default.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
<?php if (!$field->required && $field->type != 'Spacer') : ?>
<?php if (!$field->required && $field->type !== 'Spacer') : ?>
<span class="optional"><?php echo JText::_('COM_USERS_OPTIONAL'); ?></span>
<?php endif; ?>
</div>
Expand Down
Loading

0 comments on commit 7fc2cd3

Please sign in to comment.