Version 3.1.4
This commit is contained in:
1 parent
1d4720f3e2
commit
ae5c01cc78
2563 files changed
+283048
-240689
No files matched your search
@@ -1,19 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.0.5
|
||||
* Localization Class
|
||||
* IP.Board v3.1.4
|
||||
* Localization Class.
|
||||
*
|
||||
* Used for handling language text, money formatting, etc.
|
||||
* Last Updated: $Date: 2009-11-10 10:11:01 -0500 (Tue, 10 Nov 2009) $
|
||||
* Last Updated: $Date: 2010-10-06 06:09:32 -0400 (Wed, 06 Oct 2010) $
|
||||
* </pre>
|
||||
*
|
||||
* @author Joshua Williams <josh@invisionpower.com>
|
||||
* @version $Rev: 5343 $
|
||||
* @version $Rev: 6946 $
|
||||
* @since 1.0
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.iinvisionpower.com/community/board/license.html
|
||||
* @link http://www.iinvisionpower.com
|
||||
* @package Invision Power Board
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @link http://www.invisionpower.com
|
||||
* @package IP.Board
|
||||
*/
|
||||
|
||||
class class_localization
|
||||
@@ -69,7 +71,7 @@ class class_localization
|
||||
* @access public
|
||||
* @var string
|
||||
*/
|
||||
public $local = "en_US";
|
||||
public $local = "ru_RU";
|
||||
|
||||
/**
|
||||
* Array of loaded language files
|
||||
@@ -93,7 +95,7 @@ class class_localization
|
||||
* @access public
|
||||
* @var bool
|
||||
*/
|
||||
public $load_from_db = 0;
|
||||
public $load_from_db = false;
|
||||
|
||||
/**
|
||||
* Force UK/English language
|
||||
@@ -121,6 +123,15 @@ class class_localization
|
||||
$this->request = $registry->fetchRequest();
|
||||
$this->memberData =& $registry->member()->fetchMemberData();
|
||||
|
||||
/* Prevent notices */
|
||||
$this->memberData['member_id'] = !isset($this->memberData['member_id']) ? 0 : $this->memberData['member_id'];
|
||||
|
||||
/* Load from database */
|
||||
if( $this->settings['safe_mode_skins'] && ! IN_DEV )
|
||||
{
|
||||
$this->load_from_db = true;
|
||||
}
|
||||
|
||||
/* Rebuild the cache if needed */
|
||||
if( ! $this->caches['lang_data'] )
|
||||
{
|
||||
@@ -188,7 +199,7 @@ class class_localization
|
||||
'LONG' => $this->settings['clock_long'] ? $this->settings['clock_long'] : '%d %B %Y - %I:%M %p',
|
||||
'TINY' => $this->settings['clock_tiny'] ? $this->settings['clock_tiny'] : '%d %b %Y - %H:%M',
|
||||
'DATE' => $this->settings['clock_date'] ? $this->settings['clock_date'] : '%d %b %Y',
|
||||
'SHORT2' => $this->settings['clock_short2'] ? $this->settings['clock_short2'] : '%d %B %G',
|
||||
'SHORT2' => $this->settings['clock_short2'] ? $this->settings['clock_short2'] : '%d %B %Y',
|
||||
'TIME' => 'h:i A',
|
||||
'ACP' => '%d %B %Y, %H:%M',
|
||||
'ACP2' => '%d %B %Y, %H:%M',
|
||||
@@ -215,6 +226,10 @@ class class_localization
|
||||
{
|
||||
if( $this->memberData['member_id'] )
|
||||
{
|
||||
/* Rest variables to prevent loop when this class is next constructed */
|
||||
unset( ipsRegistry::$request['langid'] );
|
||||
unset( ipsRegistry::$request['setlanguage'] );
|
||||
|
||||
IPSMember::save( $this->memberData['member_id'], array( 'core' => array( 'language' => $data['lang_id'] ) ) );
|
||||
}
|
||||
else
|
||||
@@ -252,7 +267,8 @@ class class_localization
|
||||
// Set locale
|
||||
//-----------------------------------------
|
||||
|
||||
setlocale( LC_ALL, $this->local );
|
||||
//setlocale( LC_ALL, $this->local );
|
||||
IPSLib::setlocale( $this->local );
|
||||
$this->local_data = localeconv();
|
||||
|
||||
//-----------------------------------------
|
||||
@@ -345,8 +361,20 @@ class class_localization
|
||||
* @return float
|
||||
*/
|
||||
public function formatNumber( $number, $places=0 )
|
||||
{
|
||||
return str_replace( 'x', $this->local_data['thousands_sep'], number_format( $number, $places, $this->local_data['decimal_point'], 'x' ) );
|
||||
{
|
||||
$placeholders = array('@', '~');
|
||||
$actual = array($this->local_data['decimal_point'], $this->local_data['thousands_sep']);
|
||||
|
||||
// format number with placeholders
|
||||
$formatted = number_format($number, $places, $placeholders[0], $placeholders[1]);
|
||||
|
||||
// replace by localized characters
|
||||
if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
|
||||
{
|
||||
return iconv( 'windows-1251', 'utf-8', str_replace($placeholders, $actual, $formatted) );
|
||||
}
|
||||
|
||||
return str_replace($placeholders, $actual, $formatted);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,6 +429,12 @@ class class_localization
|
||||
if ( preg_match( "#^manual\{([^\{]+?)\}#i", $method, $match ) )
|
||||
{
|
||||
$format = $match[1];
|
||||
|
||||
//-----------------------------------------
|
||||
// Shut off relative dates if using manual{} tag
|
||||
//-----------------------------------------
|
||||
|
||||
$norelative = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -444,7 +478,7 @@ class class_localization
|
||||
return '--';
|
||||
}
|
||||
|
||||
if ($this->offset_set == 0)
|
||||
if ($this->offset_set == 0 OR ! $this->today_time)
|
||||
{
|
||||
// Save redoing this code for each call, only do once per page load
|
||||
|
||||
@@ -452,8 +486,8 @@ class class_localization
|
||||
|
||||
if ( $this->settings['time_use_relative'] )
|
||||
{
|
||||
$this->today_time = gmstrftime('%m,%d,%Y', ( time() + $this->offset ) );
|
||||
$this->yesterday_time = gmstrftime('%m,%d,%Y', ( ( time() - 86400 ) + $this->offset ) );
|
||||
$this->today_time = @gmstrftime('%m,%d,%Y', ( time() + $this->offset ) );
|
||||
$this->yesterday_time = @gmstrftime('%m,%d,%Y', ( ( time() - 86400 ) + $this->offset ) );
|
||||
}
|
||||
|
||||
$this->offset_set = 1;
|
||||
@@ -513,7 +547,12 @@ class class_localization
|
||||
}
|
||||
else
|
||||
{
|
||||
return gmstrftime($format, ($date + $this->offset) );
|
||||
if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
|
||||
{
|
||||
return iconv( 'windows-1251', 'utf-8', @gmstrftime( $format, ($date + $this->offset) ) );
|
||||
}
|
||||
|
||||
return @gmstrftime($format, ($date + $this->offset) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,13 +562,13 @@ class class_localization
|
||||
|
||||
else if ( $this->settings['time_use_relative'] and ( $norelative != 1 ) )
|
||||
{
|
||||
$this_time = gmstrftime('%m,%d,%Y', ($date + $this->offset) );
|
||||
$this_time = @gmstrftime('%m,%d,%Y', ($date + $this->offset) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Use level 2 relative?
|
||||
//-----------------------------------------
|
||||
|
||||
if ( $this->settings['time_use_relative'] == 2 AND ($date < time()) )
|
||||
if ( $this->settings['time_use_relative'] == 2 AND ($date <= time()) )
|
||||
{
|
||||
$diff = time() - $date;
|
||||
|
||||
@@ -552,15 +591,20 @@ class class_localization
|
||||
|
||||
if ( $this_time == $this->today_time )
|
||||
{
|
||||
return str_replace( '{--}', $this->words['time_today'], gmstrftime($this->settings['time_use_relative_format'], ($date + $this->offset) ) );
|
||||
return str_replace( '{--}', $this->words['time_today'], @gmstrftime($this->settings['time_use_relative_format'], ($date + $this->offset) ) );
|
||||
}
|
||||
else if ( $this_time == $this->yesterday_time )
|
||||
{
|
||||
return str_replace( '{--}', $this->words['time_yesterday'], gmstrftime($this->settings['time_use_relative_format'], ($date + $this->offset) ) );
|
||||
return str_replace( '{--}', $this->words['time_yesterday'], @gmstrftime($this->settings['time_use_relative_format'], ($date + $this->offset) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return gmstrftime( $format, ($date + $this->offset) );
|
||||
if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
|
||||
{
|
||||
return iconv( 'windows-1251', 'utf-8', @gmstrftime( $format, ($date + $this->offset) ) );
|
||||
}
|
||||
|
||||
return @gmstrftime( $format, ($date + $this->offset) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -570,7 +614,12 @@ class class_localization
|
||||
|
||||
else
|
||||
{
|
||||
return gmstrftime($format, ($date + $this->offset) );
|
||||
if( strpos( strtolower( PHP_OS ), 'win' ) === 0 )
|
||||
{
|
||||
return iconv( 'windows-1251', 'utf-8', @gmstrftime( $format, ($date + $this->offset) ) );
|
||||
}
|
||||
|
||||
return @gmstrftime($format, ($date + $this->offset) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,7 +643,7 @@ class class_localization
|
||||
$this->offset_set = 1;
|
||||
}
|
||||
|
||||
return gmstrftime($method, ($date + $this->offset) );
|
||||
return @gmstrftime($method, ($date + $this->offset) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -607,8 +656,11 @@ class class_localization
|
||||
public function getTimeOffset()
|
||||
{
|
||||
$r = 0;
|
||||
|
||||
$r = ( ( ($this->memberData['time_offset'] AND $this->memberData['time_offset'] != "" ) OR $this->memberData['time_offset'] === '0' OR $this->memberData['time_offset'] === 0 ) ? $this->memberData['time_offset'] : $this->settings['time_offset'] ) * 3600;
|
||||
|
||||
$this->settings['time_offset'] = ( ! empty( $this->settings['time_offset'] ) ) ? $this->settings['time_offset'] : 0;
|
||||
$this->memberData['time_offset'] = ( isset( $this->memberData['time_offset'] ) ) ? $this->memberData['time_offset'] : null;
|
||||
|
||||
$r = ( ( $this->memberData['time_offset'] !== null ) ? $this->memberData['time_offset'] : $this->settings['time_offset'] ) * 3600;
|
||||
|
||||
if ( $this->settings['time_adjust'] )
|
||||
{
|
||||
@@ -659,9 +711,9 @@ class class_localization
|
||||
* @return void
|
||||
*/
|
||||
public function loadLanguageFile( $load=array(), $app='', $lang='', $forceReload=false )
|
||||
{
|
||||
{
|
||||
$_MASTER2 = IPSDebug::getMemoryDebugFlag();
|
||||
|
||||
|
||||
/* App */
|
||||
$app = ( $app ) ? $app : IPS_APP_COMPONENT;
|
||||
$load = ( $load ) ? $load : array();
|
||||
@@ -681,7 +733,7 @@ class class_localization
|
||||
}
|
||||
|
||||
/* Has the global language file been loaded? */
|
||||
if ( ! in_array( $global, $this->loaded_lang_files ) AND ( $app == 'core' AND ! in_array( $_global, $load ) ) )
|
||||
if ( ! in_array( $app . '_' . $global, $this->loaded_lang_files ) AND ( $app == 'core' AND ! in_array( $_global, $load ) ) )
|
||||
{
|
||||
$load[] = $global;
|
||||
}
|
||||
@@ -691,6 +743,8 @@ class class_localization
|
||||
|
||||
if( $this->load_from_db OR $this->_forceEnglish )
|
||||
{
|
||||
$_apps = array( 0 => "'" . $app . "'" );
|
||||
|
||||
if( is_array( $load ) AND count( $load ) )
|
||||
{
|
||||
/* Reformat for query and make sure we're not loading something twice */
|
||||
@@ -698,13 +752,24 @@ class class_localization
|
||||
|
||||
foreach( $load as $l )
|
||||
{
|
||||
/* Load global from the core app */
|
||||
if ( $l == $_global )
|
||||
{
|
||||
$_apps[] = "'core'";
|
||||
}
|
||||
|
||||
/* Already loaded? */
|
||||
if ( ! in_array( $app . $l, $this->loaded_lang_files ) OR $forceReload === TRUE )
|
||||
if ( ! in_array( $app . '_' . $l, $this->loaded_lang_files ) OR $forceReload === TRUE )
|
||||
{
|
||||
/* Reformat */
|
||||
$_load[] = "'{$l}'";
|
||||
}
|
||||
|
||||
if ( ! count( $_load ) )
|
||||
{
|
||||
$_load[] = '\'' . $_global . '\'';
|
||||
}
|
||||
|
||||
/* Add to the loaded array */
|
||||
$this->loaded_lang_files[] = $app . '_' . $l;
|
||||
}
|
||||
@@ -713,7 +778,7 @@ class class_localization
|
||||
$this->DB->build( array(
|
||||
'select' => 'word_key, word_default, word_custom',
|
||||
'from' => 'core_sys_lang_words',
|
||||
'where' => "lang_id={$this->lang_id} AND word_app='{$app}' AND word_pack IN ( " . implode( ',', $_load ) . " )",
|
||||
'where' => "lang_id={$this->lang_id} AND word_app IN (" . implode( ',', $_apps ) . ") AND word_pack IN ( " . implode( ',', $_load ) . " )",
|
||||
) );
|
||||
$this->DB->execute();
|
||||
|
||||
@@ -759,7 +824,7 @@ class class_localization
|
||||
}
|
||||
else
|
||||
{
|
||||
$errors .= "<li>Missing Language File: " . $_file;
|
||||
$errors .= "<li>Missing Language File: " . $_file . "</li>";
|
||||
|
||||
IPSDebug::setMemoryDebugFlag( "NO SUCH Language File: " . str_replace( IPS_CACHE_PATH, '', $_file ), $_MASTER2 );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user