PHP Класс URLify
Handles symbols from Latin languages, Greek, Turkish, Bulgarian, Russian,
Ukrainian, Czech, Polish, Romanian, Latvian, Lithuanian, Vietnamese, Arabic,
Serbian, and Azerbaijani. Symbols it cannot transliterate
it will simply omit.
Usage:
echo URLify::filter (' J\'étudie le français ');
"jetudie-le-francais"
echo URLify::filter ('Lo siento, no hablo español.');
"lo-siento-no-hablo-espanol"
Показать файл
Открыть проект
Примеры использования класса
Открытые свойства
Открытые методы
Метод |
Описание |
|
add_chars ( $map ) |
Add new characters to the list. $map should be a hash. |
|
downcode ( $text, $language = "" ) |
Transliterates characters to their ASCII equivalents. |
|
filter ( string $text, integer $length = 60, string $language = "", boolean $file_name = false, boolean $use_remove_list = true, boolean $lower_case = true, boolean $treat_underscore_as_space = true ) |
Filters a string, e.g., "Petty theft" to "petty-theft" |
|
remove_words ( $words ) |
Append words to the remove list. Accepts either single words
or an array of words. |
|
transliterate ( $text ) |
Alias of URLify::downcode(). |
|
Приватные методы
Метод |
Описание |
|
init ( $language = "" ) |
Initializes the character map. |
|
Описание методов
add_chars()
публичный статический Метод
Add new characters to the list. $map should be a hash.
downcode()
публичный статический Метод
$language specifies a priority for a specific language.
The latter is useful if languages have different rules for the same character.
public static downcode ( $text, $language = "" ) |
filter()
публичный статический Метод
Filters a string, e.g., "Petty theft" to "petty-theft"
public static filter ( string $text, integer $length = 60, string $language = "", boolean $file_name = false, boolean $use_remove_list = true, boolean $lower_case = true, boolean $treat_underscore_as_space = true ) |
$text |
string |
The text to return filtered |
$length |
integer |
The length (after filtering) of the string to be returned |
$language |
string |
The transliteration language, passed down to downcode() |
$file_name |
boolean |
Whether there should be and additional filter considering this is a filename |
$use_remove_list |
boolean |
Whether you want to remove specific elements previously set in self::$remove_list |
$lower_case |
boolean |
Whether you want the filter to maintain casing or lowercase everything (default) |
$treat_underscore_as_space |
boolean |
Treat underscore as space, so it will replaced with "-" |
remove_words()
публичный статический Метод
Append words to the remove list. Accepts either single words
or an array of words.
transliterate()
публичный статический Метод
Alias of URLify::downcode().
Описание свойств
$maps публичное статическое свойство
$remove_list публичное статическое свойство
List of words to remove from URLs.
public static $remove_list |