В русских версиях IP .Board присутствует полезная возможность транслита URL . Поисковикам нравится, если адреса на сайте написаны латинскими буквами, поэтому это помогает в поисковой оптимизации форума.
Однако, в англоязычных версиях такой функции нет (попросту не нужно), поэтому, если вы поставили англоязычную версию форума, адреса будут отображаться как есть, без транслита. Ниже я описываю как добавить эту функцию в англоязычную версию форума. Внимание! Это нужно только если у вас англоязычная версия , не от IBR!
Откройте файл root/admin/sources/base/core.php (где root - корень вашего форума). Найдите:
static public function encodeForXml( $string )
{
if ( function_exists( 'mb_detect_encoding' ) )
{
$encoding = mb_detect_encoding( $string );
if ( $encoding != 'UTF-8' )
{
$string = IPSText::convertCharsets( $string, $encoding );
}
}
elseif ( strtolower( IPS _DOC_CHAR_SET ) == 'utf-8' )
{
$string = utf8_encode( $string );
}
return $string;
}
ниже вставьте:
static public function transliterate( $text )
{
return str_replace( array('а','б','в','г','д','е','ё','ж','з','и','й','к','л','м','н','о','п','р','с','т','у','ф','х','ц','ч','ш','щ','э','ю','я','ы','ь','ъ'), array('a','b','v','g','d','e','e','zh','z','i','i','k','l','m','n','o','p','r','s','t','u','f','h','c','ch','sh','sh','a','ju','ja','i','',''), $text);
}
static public function makeSeoTransliterate( $text )
{
$text = urldecode($text);
$text = self::transliterate( $text );
$text = preg_replace('#[^a-z0-9-]#', '', $text);
$text = urlencode($text);
return $text;
}
Теперь в этом же файле найдите
/**
* Make an SEO title for use in the URL
* We parse them even if friendly urls are off so that the data is there when you do switch it on
*
* @param string Raw SEO title or text
* @return string Cleaned up SEO title
*/
static public function makeSeoTitle( $text )
{
if ( ! $text )
{
return '';
}
/* Strip all HTML tags first */
$text = strip_tags($text);
/* Preserve %data */
$text = preg_replace('#%([a-fA-F0-9][a-fA-F0-9])#', '-xx-$1-xx-', $text);
$text = str_replace( array( '%', '`' ), '', $text);
$text = preg_replace('#-xx-([a-fA-F0-9][a-fA-F0-9])-xx-#', '%$1', $text);
/* Convert accented chars */
$text = self::convertAccents($text);
/* Convert it */
if ( self::isUTF8( $text ) )
{
if ( function_exists('mb_strtolower') )
{
$text = mb_strtolower($text, 'UTF-8');
}
$text = self::utf8Encode( $text, 250 );
}
/* Finish off */
$text = strtolower($text);
if ( strtolower( IPS _DOC_CHAR_SET ) == 'utf-8' )
{
$text = preg_replace( '#&.+?;#' , '', $text );
$text = preg_replace( '#[^%a-z0-9 _-]#', '', $text );
}
else
{
/* Remove &#xx; and &#xxx; but keep &#xxxx; */
$text = preg_replace( '/&#(d){2,3};/', '', $text );
$text = preg_replace( '#[^%&#;a-z0-9 _-]#', '', $text );
$text = str_replace( array( '"', '&'), '', $text );
}
$text = str_replace( array( '`', ' ', '+', '.', '?', '_', '#' ), '-', $text );
$text = preg_replace( "#-{2,}#", '-', $text );
$text = trim($text, '-');
IPSDebug::addMessage( "<span style='color:red'>makeSeoTitle ($text) called</span>" );
return ( $text ) ? $text : '-';
}
и после строчки
$text = trim($text, '-');
вставьте:
$text = self::makeSeoTransliterate( $text );
Внимание! Сохраните этот файл в кодировке UTF-8 БЕЗ BOM! По умолчанию он в кодировке ANSI, поэтому работать ничего не будет! Для того, чтобы сохранить файл в этой кодировке, скачайте программу Notepad++, откройте в ней этот файл (root/admin/sources/base/core.php) и выберите в верхнем меню Кодировки → Преобразовать в UTF-8 без BOM, после этого сохраните файл и закачайте к себе на сервер.
Теперь откройте файл root/admin/sources/classes/output/publicOutput.php Найдите:
/**
* Formats the URL (.htaccess SEO, etc)
*
* @access public
* @param string Raw URL
* @param string Any special SEO title passed
* @param string Any special SEO template to use. If none is passed but SEO is enabled, IPB will search all templates for a match
* @return string Formatted URL
*/
public function formatUrl( $ url , $seoTitle='', $seoTemplate='' )
{
//-----------------------------------------
// INIT
//-----------------------------------------
if ( ! ipsRegistry::$settings['use_friendly_ urls '] )
{
return $ url ;
}
и после этой фигурной скобки вставьте:
$seoTitle = IPSText::makeSeoTransliterate( $seoTitle );
Все. Теперь адреса содержащие кириллицу будут отображаться транслитом.