ultimix
lang_markup.php
Go to the documentation of this file.
1 <?php
2 
3  /*
4  * This source code is a part of the Ultimix Project.
5  * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6  * it's own license wich could be found from the corresponding files or sources.
7  * This source code is provided "as is" without any warranties or garanties.
8  *
9  * Have a nice day!
10  *
11  * @url http://ultimix.sorceforge.net
12  *
13  * @author Alexey "gdever" Dodonov
14  */
15 
27 
38  var $CachedMultyFS = false;
39  var $Lang = false;
40 
55  function __construct()
56  {
57  try
58  {
59  $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
60  $this->Lang = get_package( 'lang' , 'last' , __FILE__ );
61  $this->Lang->get_locale();
62  $this->Lang->load_translations();
63  }
64  catch( Exception $e )
65  {
66  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
67  }
68  }
69 
96  function compile_lang_block( &$Settings , $Data )
97  {
98  try
99  {
100  if( $Settings->setting_exists( $this->Lang->get_locale() ) )
101  {
102  return( $Data );
103  }
104  else
105  {
106  return( '' );
107  }
108  }
109  catch( Exception $e )
110  {
111  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
112  }
113  }
114 
137  private function get_package_info( &$Options )
138  {
139  try
140  {
141  $PackageName = $Options->get_setting( 'package_name' );
142  $PackageName = explode( ',' , $PackageName );
143  $PackageVersion = $Options->get_setting( 'package_version' , 'last' );
144  $PackageVersion = explode( ',' , $PackageVersion );
145 
146  return( array( $PackageName , $PackageVersion ) );
147  }
148  catch( Exception $e )
149  {
150  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
151  }
152  }
153 
172  function compile_lang_file( &$Settings )
173  {
174  try
175  {
176  list( $PackageName , $PackageVersion ) = $this->get_package_info( $Settings );
177 
178  foreach( $PackageName as $i => $Name )
179  {
180  $Version = isset( $PackageVersion[ $i ] ) ? $PackageVersion[ $i ] : 'last';
181  $PackagePath = _get_package_path_ex( $Name , $Version );
182 
183  $TopPackageName = _get_top_package_name( $Name );
184  $LangFilePath = $PackagePath.'/res/lang/'.$TopPackageName.'.'.$this->Lang->Language;
185  $RawData = $this->CachedMultyFS->file_get_contents( $LangFilePath , 'cleaned' );
186 
187  $this->Lang->load_data( $RawData );
188  }
189 
190  return( '' );
191  }
192  catch( Exception $e )
193  {
194  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
195  }
196  }
197 
220  function compile_lang_file_js( &$Settings )
221  {
222  try
223  {
224  $PackageName = $Settings->get_setting( 'package_name' );
225  $PackageVersion = $Settings->get_setting( 'package_version' , 'last' );
226 
227  $this->Lang->include_strings_js( $PackageName , $PackageVersion );
228 
229  return( '' );
230  }
231  catch( Exception $e )
232  {
233  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
234  }
235  }
236 
259  function compile_lang( &$Settings )
260  {
261  try
262  {
263  $RawSettings = $Settings->get_raw_settings();
264  $StringAlias = array_shift( array_keys( $RawSettings ) );
265  $Value = $Settings->get_setting( 'value' , 'default' );
266  $TransformedString = $this->Lang->get_string( $StringAlias , $Value );
267 
268  if( $TransformedString == $StringAlias )
269  {
270  $DefaultTransform = $Settings->get_setting( 'default' , false );
271  $TransformedString =
272  $DefaultTransform === false ? $TransformedString : "{lang:$DefaultTransform}";
273  }
274 
275  return( $TransformedString );
276  }
277  catch( Exception $e )
278  {
279  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
280  }
281  }
282 
309  function compile_iconv( &$Settings , $Data )
310  {
311  try
312  {
313  $Code = iconv(
314  $this->Settings->get_setting( 'in_charset' ) ,
315  $this->Settings->get_setting( 'out_charset' , 'UTF-8' ) , $Data
316  );
317 
318  return( $Code );
319  }
320  catch( Exception $e )
321  {
322  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
323  }
324  }
325 
352  function compile_locale( &$Settings )
353  {
354  try
355  {
356  return( $this->Lang->Language );
357  }
358  catch( Exception $e )
359  {
360  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
361  }
362  }
363  }
364 
365 ?>