Skip to content

Commit

Permalink
[5.3] Fix language default parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
janschoenherr committed Dec 5, 2024
1 parent 9800738 commit 54358cc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions components/com_contact/src/Helper/RouteHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ abstract class RouteHelper
*
* @param integer $id The id of the contact
* @param integer $catid The id of the contact's category
* @param mixed $language The id of the language being used.
* @param string $language The language code.
*
* @return string The link to the contact
*
* @since 1.5
*/
public static function getContactRoute($id, $catid, $language = 0)
public static function getContactRoute($id, $catid, $language = null)
{
// Create the link
$link = 'index.php?option=com_contact&view=contact&id=' . $id;
Expand All @@ -47,7 +47,7 @@ public static function getContactRoute($id, $catid, $language = 0)
$link .= '&catid=' . $catid;
}

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}

Expand All @@ -58,13 +58,13 @@ public static function getContactRoute($id, $catid, $language = 0)
* Get the URL route for a contact category from a contact category ID and language
*
* @param mixed $catid The id of the contact's category either an integer id or an instance of CategoryNode
* @param mixed $language The id of the language being used.
* @param mixed $language The language code.
*
* @return string The link to the contact
*
* @since 1.5
*/
public static function getCategoryRoute($catid, $language = 0)
public static function getCategoryRoute($catid, $language = null)
{
if ($catid instanceof CategoryNode) {
$id = $catid->id;
Expand All @@ -78,7 +78,7 @@ public static function getCategoryRoute($catid, $language = 0)
// Create the link
$link = 'index.php?option=com_contact&view=category&id=' . $id;

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}
}
Expand Down
6 changes: 3 additions & 3 deletions components/com_content/src/Helper/RouteHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ public static function getArticleRoute($id, $catid = 0, $language = null, $layou
* Get the category route.
*
* @param integer $catid The category ID.
* @param integer $language The language code.
* @param string $language The language code.
* @param string $layout The layout value.
*
* @return string The article route.
*
* @since 1.5
*/
public static function getCategoryRoute($catid, $language = 0, $layout = null)
public static function getCategoryRoute($catid, $language = null, $layout = null)
{
if ($catid instanceof CategoryNode) {
$id = $catid->id;
Expand All @@ -81,7 +81,7 @@ public static function getCategoryRoute($catid, $language = 0, $layout = null)

$link = 'index.php?option=com_content&view=category&id=' . $id;

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}

Expand Down
18 changes: 9 additions & 9 deletions components/com_newsfeeds/src/Helper/RouteHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ abstract class RouteHelper
/**
* getNewsfeedRoute
*
* @param int $id menu itemid
* @param int $catid category id
* @param int $language language
* @param int $id menu itemid
* @param int $catid category id
* @param string $language language
*
* @return string
*/
public static function getNewsfeedRoute($id, $catid, $language = 0)
public static function getNewsfeedRoute($id, $catid, $language = null)
{
// Create the link
$link = 'index.php?option=com_newsfeeds&view=newsfeed&id=' . $id;
Expand All @@ -42,7 +42,7 @@ public static function getNewsfeedRoute($id, $catid, $language = 0)
$link .= '&catid=' . $catid;
}

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}

Expand All @@ -52,12 +52,12 @@ public static function getNewsfeedRoute($id, $catid, $language = 0)
/**
* getCategoryRoute
*
* @param int $catid category id
* @param int $language language
* @param int $catid category id
* @param string $language language
*
* @return string
*/
public static function getCategoryRoute($catid, $language = 0)
public static function getCategoryRoute($catid, $language = null)
{
if ($catid instanceof CategoryNode) {
$id = $catid->id;
Expand All @@ -71,7 +71,7 @@ public static function getCategoryRoute($catid, $language = 0)
// Create the link
$link = 'index.php?option=com_newsfeeds&view=category&id=' . $id;

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
}
}
Expand Down
6 changes: 3 additions & 3 deletions libraries/src/Helper/RouteHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ protected function findItem($needles = [])
* Fetches the category route
*
* @param mixed $catid Category ID or CategoryNode instance
* @param mixed $language Language code
* @param string $language Language code
* @param string $extension Extension to lookup
*
* @return string
Expand All @@ -217,7 +217,7 @@ protected function findItem($needles = [])
*
* @throws \InvalidArgumentException
*/
public static function getCategoryRoute($catid, $language = 0, $extension = '')
public static function getCategoryRoute($catid, $language = null, $extension = '')
{
// Note: $extension is required but has to be an optional argument in the function call due to argument order
if (empty($extension)) {
Expand All @@ -242,7 +242,7 @@ public static function getCategoryRoute($catid, $language = 0, $extension = '')
'category' => [$id],
];

if ($language && $language !== '*' && Multilanguage::isEnabled()) {
if (!empty($language) && $language !== '*' && Multilanguage::isEnabled()) {
$link .= '&lang=' . $language;
$needles['language'] = $language;
}
Expand Down

0 comments on commit 54358cc

Please sign in to comment.