Skip to content

Commit

Permalink
Simplify active id $value control
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrezdev committed May 18, 2016
1 parent 2214bdc commit 29a6bf9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 30 deletions.
Expand Up @@ -49,14 +49,7 @@ protected function getInput()
JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR);

// The active category id field.
if (0 == (int) $this->value)
{
$value = '';
}
else
{
$value = (int) $this->value;
}
$value = (int) $this->value > 0 ? (int) $this->value : '';

// Build the script.
$script = array();
Expand Down Expand Up @@ -130,13 +123,13 @@ protected function getInput()
$urlSelect = $linkCategories . '&' . JSession::getFormToken() . '=1';
$urlEdit = $linkCategory . '&id=' . $value . '&' . JSession::getFormToken() . '=1';

if ((int) $this->value > 0)
if ($value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('title'))
->from($db->quoteName('#__categories'))
->where($db->quoteName('id') . ' = ' . (int) $this->value);
->where($db->quoteName('id') . ' = ' . (int) $value);
$db->setQuery($query);

try
Expand Down
Expand Up @@ -40,14 +40,7 @@ protected function getInput()
JFactory::getLanguage()->load('com_contact', JPATH_ADMINISTRATOR);

// The active contact id field.
if (0 == (int) $this->value)
{
$value = '';
}
else
{
$value = (int) $this->value;
}
$value = (int) $this->value > 0 ? (int) $this->value : '';

// Build the script.
$script = array();
Expand Down Expand Up @@ -127,13 +120,13 @@ protected function getInput()
$urlSelect = $linkContacts . '&' . JSession::getFormToken() . '=1';
$urlEdit = $linkContact . '&id=' . $value . '&' . JSession::getFormToken() . '=1';

if ((int) $this->value > 0)
if ($value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('name'))
->from($db->quoteName('#__contact_details'))
->where($db->quoteName('id') . ' = ' . (int) $this->value);
->where($db->quoteName('id') . ' = ' . (int) $value);
$db->setQuery($query);

try
Expand Down
Expand Up @@ -40,14 +40,7 @@ protected function getInput()
JFactory::getLanguage()->load('com_newsfeeds', JPATH_ADMINISTRATOR);

// The active newsfeed id field.
if (0 == (int) $this->value)
{
$value = '';
}
else
{
$value = (int) $this->value;
}
$value = (int) $this->value > 0 ? (int) $this->value : '';

// Build the script.
$script = array();
Expand Down Expand Up @@ -127,13 +120,13 @@ protected function getInput()
$urlSelect = $linkNewsfeeds . '&' . JSession::getFormToken() . '=1';
$urlEdit = $linkNewsfeed . '&id=' . $value . '&' . JSession::getFormToken() . '=1';

if ((int) $this->value > 0)
if ($value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('name'))
->from($db->quoteName('#__newsfeeds'))
->where($db->quoteName('id') . ' = ' . (int) $this->value);
->where($db->quoteName('id') . ' = ' . (int) $value);
$db->setQuery($query);

try
Expand Down

0 comments on commit 29a6bf9

Please sign in to comment.