KaURLify
in component
Url keywords and file names from any text: "Как выбрать ноутбук" -> "kak-vybrat-noutbuk".
A thin wrapper of jbroadway/urlify (vendor/, with voku/portable-ascii) with the API of the KaURLify class of CSV Product Import and of the OpenCart 4 library.
$language is a language code: 'ru', 'ru-ru', 'en-gb' (only the part before '-' is used). The language gives its own transliteration rules, e.g. 'Größe' is 'groesse' for 'de' and 'grosse' for 'en'; Russian text needs 'ru' ('щука' is 'schuka', 'shhuka' with 'en').
Table of Contents
Constants
- URL_FILE = 'file'
- URL_NATIONAL = 'national'
- URL_REGULAR = 'regular'
Properties
Methods
- add_chars() : mixed
- Adds characters to the transliteration: array of character => replacement.
- downcode() : mixed
- Transliterates a text to ASCII characters (no other changes).
- filter() : mixed
- Converts a text to a url keyword: latin letters, digits and '-' in lowercase.
- remove_words() : mixed
- Adds words removed by filter() of the language.
- transliterate() : mixed
- applyFallbackLanguage() : mixed
- Converts the letters of a language with the fallback language by its own table and returns
the text, $language becomes the fallback language. - getLanguageCode() : mixed
- 'ru-ru' -> 'ru', '' -> 'en'.
- registerLoader() : mixed
- Loads the classes of vendor/ (URLify and voku\helper\*) without composer.
Constants
URL_FILE
public
mixed
URL_FILE
= 'file'
URL_NATIONAL
public
mixed
URL_NATIONAL
= 'national'
URL_REGULAR
public
mixed
URL_REGULAR
= 'regular'
Properties
$fallback_languages
protected
static mixed
$fallback_languages
= array('uk' => 'ru')
$is_loader_registered
protected
static mixed
$is_loader_registered
= false
$remove_words
protected
static mixed
$remove_words
= array()
Methods
add_chars()
Adds characters to the transliteration: array of character => replacement.
public
static add_chars(mixed $map) : mixed
Parameters
- $map : mixed
downcode()
Transliterates a text to ASCII characters (no other changes).
public
static downcode(mixed $text[, mixed $language = '' ]) : mixed
Parameters
- $text : mixed
- $language : mixed = ''
filter()
Converts a text to a url keyword: latin letters, digits and '-' in lowercase.
public
static filter(mixed $text[, mixed $length = 90 ][, mixed $language = '' ][, mixed $url_type = self::URL_REGULAR ]) : mixed
$length - maximum length of the result $language - language code, the default is English $url_type - URL_REGULAR, URL_FILE (keeps '.') or URL_NATIONAL (keeps letters of any language)
Parameters
- $text : mixed
- $length : mixed = 90
- $language : mixed = ''
- $url_type : mixed = self::URL_REGULAR
remove_words()
Adds words removed by filter() of the language.
public
static remove_words(mixed $words[, mixed $language = 'en' ]) : mixed
Parameters
- $words : mixed
- $language : mixed = 'en'
transliterate()
public
static transliterate(mixed $text[, mixed $language = '' ]) : mixed
Parameters
- $text : mixed
- $language : mixed = ''
applyFallbackLanguage()
Converts the letters of a language with the fallback language by its own table and returns the text, $language becomes the fallback language.
protected
static applyFallbackLanguage(mixed $text, mixed &$language) : mixed
Parameters
- $text : mixed
- $language : mixed
getLanguageCode()
'ru-ru' -> 'ru', '' -> 'en'.
protected
static getLanguageCode(mixed $language) : mixed
Parameters
- $language : mixed
registerLoader()
Loads the classes of vendor/ (URLify and voku\helper\*) without composer.
protected
static registerLoader() : mixed