|
|
|
|
|
|
|
|
|
|
На некоторых форумах, где преобладает контент с нелатинскими символами (например, кириллица), появилась проблема с обрезанием заголовка темы в поле «Последнее сообщение». Обычно вместо укороченного названия темы отображается многоточие.
Данная проблема была исправлена в первом же обновлении к IP.Board 2.2!
Если вы хотите узнать как исправить эту проблему, выполните следующие действия.
Откройте файл /sources/ipsclass.php и найдите в нём функцию «txt_truncate» и следующую за ней функцию «txt_mbsubstr». Выделете код обоих функций и замените его на следующий код:
/*-------------------------------------------------------------------------*/ // Truncate text string /*-------------------------------------------------------------------------*/ /** * Truncate a HTML string without breaking HTML entites * * @param string Input String * @param integer Desired min. length * @return string Parsed string * @since 2.0 */ function txt_truncate($text, $limit=30) { $text = str_replace( '&' , '&', $text ); $text = str_replace( '"', '"', $text ); $start_text = $text; $string_length = $this->txt_mb_strlen( $text ); if ( $string_length > $limit) { $text = $this->txt_mbsubstr( $text, 0, $limit ); } if( $text != $start_text ) { $text .= "..."; $text = preg_replace( "/&(#{0,}([a-zA-Z0-9]+?)?)?\.\.\.$/", '...', $text ); } else { $text = preg_replace( "/&(#{0,}([a-zA-Z0-9]+?)?)?$/", '', $text ); } return $text; } /*-------------------------------------------------------------------------*/ // Multibyte safe substr /*-------------------------------------------------------------------------*/ /** * Substr support for this without mb_substr * * @param string Input String * @param integer Desired min. length * @return string Parsed string * @since 2.0 */ function txt_mbsubstr($text, $start=0, $limit=30) { $text = str_replace( '&' , '&', $text ); $text = str_replace( '"', '"', $text ); // Do we have multi-byte functions? if( function_exists('mb_list_encodings') ) { // PHP 5, preferred method $valid_encodings = array(); $valid_encodings = mb_list_encodings(); if( count($valid_encodings) ) { if( in_array( strtoupper($this->vars['gb_char_set']), $valid_encodings ) ) { return mb_substr( $text, $start, $limit, strtoupper($this->vars['gb_char_set']) ); } } } else if( function_exists('mb_substr') ) { // PHP 4 support return mb_substr( $text, $start, $limit, strtoupper($this->vars['gb_char_set']) ); } // No? Let's do our handrolled method then $string_length = $this->txt_mb_strlen( $text ); if ( $string_length > $limit) { if( strtoupper($this->vars['gb_char_set']) == 'UTF-8' ) { // Multi-byte support $text = @preg_replace('#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,0}'. '((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){'.intval($start).','.intval($limit).'}).*#s', '$1',$text); } else { $text = substr( $text, $start, $limit ); } $text = preg_replace( "/&(#(\d+?)?)?$/", '', $text ); } else { $text = preg_replace( "/&(#(\d+?)?)?$/", '', $text ); } return $text; }
Сохраните файл и загрузите на сервер.
Работает на DokuWiki |