PHP Class 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"
Mostrar archivo Open project: jbroadway/urlify Class Usage Examples

Public Properties

Property Type Description
$maps
$remove_list List of words to remove from URLs.

Public Methods

Method Description
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().

Private Methods

Method Description
init ( $language = "" ) Initializes the character map.

Method Details

add_chars() public static method

Add new characters to the list. $map should be a hash.
public static add_chars ( $map )

downcode() public static method

$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() public static method

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() public static method

Append words to the remove list. Accepts either single words or an array of words.
public static remove_words ( $words )

transliterate() public static method

Alias of URLify::downcode().
public static transliterate ( $text )

Property Details

$maps public_oe static_oe property

public static $maps

$remove_list public_oe static_oe property

List of words to remove from URLs.
public static $remove_list