Commit de672689 authored by Radek Suski's avatar Radek Suski

(+) option to replace charachters with null in StringUtils::Nid

parent 331eeabf
......@@ -26,7 +26,9 @@ abstract class StringUtils
{
/**
* Removes slashes from string
*
* @param string $txt
*
* @return string
*/
public static function Clean( $txt )
......@@ -41,17 +43,22 @@ abstract class StringUtils
* @param string $txt
* @param bool $unicode
* @param bool $forceUnicode
*
* @param bool $null - nullify
*
* @return string
*/
public static function Nid( $txt, $unicode = false, $forceUnicode = false )
public static function Nid( $txt, $unicode = false, $forceUnicode = false, $null = false )
{
$txt = trim( str_replace( [ '.', '_' ], '-', $txt ) );
$txt = trim( str_replace( [ '.', '_' ], ( $null ? null : '-' ), $txt ) );
return ( Framework::Cfg( 'sef.unicode' ) && $unicode ) || $forceUnicode ? self::UrlSafe( $txt ) : trim( preg_replace( '/(\s|[^A-Za-z0-9\-])+/', '-', \JFactory::getLanguage()->transliterate( $txt ) ), '_-\[\]\(\)' );
}
/**
* Creates URL safe string
*
* @param string $str
*
* @return string
*/
public static function UrlSafe( $str )
......@@ -77,8 +84,10 @@ abstract class StringUtils
/**
* Replaces HTML entities to valid XML entities
*
* @param $txt
* @param $amp
*
* @return string
*/
public static function Entities( $txt, $amp = false )
......
......@@ -30,6 +30,7 @@ Legend:
------------------
(+) Simple OpenSSL encryption added
(+) option to replace charachters with null in StringUtils::Nid
(#) Count on non-arrays (Issue #103)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment