Back to ApplicationHelper class

Method stringURLSafe

public static string
stringURLSafe
(mixed $string, mixed $language = '')
This method transliterates a string into a URL safe string or returns a URL safe UTF-8 string based on the global configuration
Parameters
  • string $string String to process
  • string $language Language to transliterate to if unicode slugs are disabled
Returns
  • string Processed string
Since
  • 3.2

Method stringURLSafe - Source code

/**
 * This method transliterates a string into a URL
 * safe string or returns a URL safe UTF-8 string
 * based on the global configuration
 *
 * @param   string  $string    String to process
 * @param   string  $language  Language to transliterate to if unicode slugs are disabled
 *
 * @return  string  Processed string
 *
 * @since   3.2
 */
public static function stringURLSafe($string, $language = '')
{
    if (Factory::getApplication()->get('unicodeslugs') == 1) {
        $output = OutputFilter::stringUrlUnicodeSlug($string);
    } else {
        if ($language === '*' || $language === '') {
            $languageParams = ComponentHelper::getParams('com_languages');
            $language = $languageParams->get('site');
        }
        $output = OutputFilter::stringURLSafe($string, $language);
    }
    return $output;
}