From Data Life Engine All rights reserved by DLE-News function totrans

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* From Data Life Engine 7.5
* All rights reserved by DLE-News.
*/
function totranslit($var, $lower = true, $punkt = true) {
$NpjLettersFrom = "абвгдезиклмнопрстуфцыі";
$NpjLettersTo = "abvgdeziklmnoprstufcyi";
$NpjBiLetters = array ("й" => "j", "ё" => "yo", "ж" => "zh", "х" => "x", "ч" => "ch", "ш" => "sh", "щ" => "shh", "э" => "ye", "ю" => "yu", "я" => "ya", "ъ" => "", "ь" => "", "ї" => "yi", "є" => "ye" );
$NpjCaps = "АБВГДЕЁЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЪЫЭЮЯЇЄІ";
$NpjSmall = "абвгдеёжзийклмнопрстуфхцчшщьъыэюяїєі";
$var = str_replace( ".php", "", $var );
$var = trim( strip_tags( $var ) );
$var = preg_replace( "/\s+/ms", "-", $var );
$var = strtr( $var, $NpjCaps, $NpjSmall );
$var = strtr( $var, $NpjLettersFrom, $NpjLettersTo );
$var = strtr( $var, $NpjBiLetters );
if ( $punkt ) $var = preg_replace( "/[^a-z0-9\_\-.]+/mi", "", $var );
else $var = preg_replace( "/[^a-z0-9\_\-]+/mi", "", $var );
$var = preg_replace( '#[\-]+#i', '-', $var );
if ( $lower ) $var = strtolower( $var );
if( strlen( $var ) > 50 ) {
$var = substr( $var, 0, 50 );
if( ($temp_max = strrpos( $var, '-' )) ) $var = substr( $var, 0, $temp_max );
}
return $var;
}