00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 include_once( "lib/ezutils/classes/ezdebug.php" );
00037 include_once( "lib/ezi18n/classes/ezutf8codec.php" );
00038 include_once( "lib/ezi18n/classes/ezcharsetinfo.php" );
00039
00040 define( "EZ_CODEPAGE_CACHE_CODE_DATE", 1028204478 );
00041
00042 class eZCodePage
00043 {
00044
00045
00046
00047 function eZCodePage( $charset_code, $use_cache = true )
00048 {
00049 $this->RequestedCharsetCode = $charset_code;
00050 $this->CharsetCode = eZCharsetInfo::realCharsetCode( $charset_code );
00051 $this->CharsetEncodingScheme = eZCharsetInfo::characterEncodingScheme( $charset_code );
00052 $this->Valid = false;
00053 $this->SubstituteChar = 63;
00054 $this->MinCharValue = 0;
00055 $this->MaxCharValue = 0;
00056
00057 $this->load( $use_cache );
00058 }
00059
00060 function convertString( &$str )
00061 {
00062 $len = strlen( $str );
00063 $chars = '';
00064 $utf8_codec =& eZUTF8Codec::instance();
00065 for ( $i = 0; $i < $len; )
00066 {
00067 $charLen = 1;
00068 $char = $this->charToUTF8( $str, $i, $charLen );
00069 if ( $char !== null )
00070 $chars .= $char;
00071 else
00072 $chars .= $utf8_codec->toUtf8( $this->SubstituteChar );
00073 $i += $charLen;
00074 }
00075 return $chars;
00076 }
00077
00078 function convertStringToUnicode( &$str )
00079 {
00080 $len = strlen( $str );
00081 $unicodeValues = array();
00082 for ( $i = 0; $i < $len; )
00083 {
00084 $charLen = 1;
00085 $unicodeValue = $this->charToUnicode( $str, $i, $charLen );
00086 if ( $unicodeValue !== null )
00087 $unicodeValues[] = $unicodeValue;
00088 $i += $charLen;
00089 }
00090 return $unicodeValues;
00091 }
00092
00093 function convertUnicodeToString( $unicodeValues )
00094 {
00095 if ( !is_array( $unicodeValues ) )
00096 return false;
00097 $text = '';
00098 foreach ( $unicodeValues as $unicodeValue )
00099 {
00100 $char = $this->unicodeToChar( $unicodeValue );
00101 $text .= $char;
00102 }
00103 return $text;
00104 }
00105
00106 function convertStringFromUTF8( &$multi_char )
00107 {
00108 $strlen = strlen( $multi_char );
00109 $text = '';
00110 $codeMap =& $this->CodeMap;
00111 $subChar = $this->SubstituteChar;
00112 for ( $offs = 0; $offs < $strlen; )
00113 {
00114
00115
00116
00117 $char_code = false;
00118 if ( ( ord( $multi_char[$offs + 0] ) & 0x80 ) == 0x00 )
00119 {
00120 $char_code = ord( $multi_char[$offs + 0] );
00121 $offs += 1;
00122 }
00123 else if ( ( ord( $multi_char[$offs + 0] ) & 0xe0 ) == 0xc0 )
00124 {
00125 if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 )
00126 {
00127 $offs += 2;
00128 continue;
00129 }
00130 $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x1f ) << 6) +
00131 (( ord( $multi_char[$offs + 1] ) & 0x3f )) );
00132 $offs += 2;
00133 if ( $char_code < 128 )
00134 continue;
00135 }
00136 else if ( ( ord( $multi_char[$offs + 0] ) & 0xf0 ) == 0xe0 )
00137 {
00138 if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 or
00139 ( ord( $multi_char[$offs + 2] ) & 0xc0 ) != 0x80 )
00140 {
00141 $offs += 3;
00142 continue;
00143 }
00144 $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x0f ) << 12) +
00145 (( ord( $multi_char[$offs + 1] ) & 0x3f ) << 6) +
00146 (( ord( $multi_char[$offs + 2] ) & 0x3f )) );
00147 $offs += 3;
00148 if ( $char_code < 2048 )
00149 continue;
00150 }
00151 else if ( ( ord( $multi_char[$offs + 0] ) & 0xf8 ) == 0xf0 )
00152 {
00153 if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 or
00154 ( ord( $multi_char[$offs + 2] ) & 0xc0 ) != 0x80 or
00155 ( ord( $multi_char[$offs + 3] ) & 0xc0 ) != 0x80 )
00156 {
00157 $offs += 4;
00158 continue;
00159 }
00160 $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x07 ) << 18) +
00161 (( ord( $multi_char[$offs + 1] ) & 0x3f ) << 12) +
00162 (( ord( $multi_char[$offs + 2] ) & 0x3f ) << 6) +
00163 (( ord( $multi_char[$offs + 3] ) & 0x3f )) );
00164 $offs += 4;
00165 if ( $char_code < 65536 )
00166 continue;
00167 }
00168 else if ( ( ord( $multi_char[$offs + 0] ) & 0xfc ) == 0xf8 )
00169 {
00170 if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 or
00171 ( ord( $multi_char[$offs + 2] ) & 0xc0 ) != 0x80 or
00172 ( ord( $multi_char[$offs + 3] ) & 0xc0 ) != 0x80 or
00173 ( ord( $multi_char[$offs + 4] ) & 0xc0 ) != 0x80 )
00174 {
00175 $offs += 5;
00176 continue;
00177 }
00178 $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x03 ) << 24) +
00179 (( ord( $multi_char[$offs + 1] ) & 0x3f ) << 18) +
00180 (( ord( $multi_char[$offs + 2] ) & 0x3f ) << 12) +
00181 (( ord( $multi_char[$offs + 3] ) & 0x3f ) << 6) +
00182 (( ord( $multi_char[$offs + 4] ) & 0x3f )) );
00183 $offs += 5;
00184 if ( $char_code < 2097152 )
00185 continue;
00186 }
00187 else if ( ( ord( $multi_char[$offs + 0] ) & 0xfe ) == 0xfc )
00188 {
00189 if ( ( ord( $multi_char[$offs + 1] ) & 0xc0 ) != 0x80 or
00190 ( ord( $multi_char[$offs + 2] ) & 0xc0 ) != 0x80 or
00191 ( ord( $multi_char[$offs + 3] ) & 0xc0 ) != 0x80 or
00192 ( ord( $multi_char[$offs + 4] ) & 0xc0 ) != 0x80 or
00193 ( ord( $multi_char[$offs + 5] ) & 0xc0 ) != 0x80 )
00194 {
00195 $offs += 6;
00196 continue;
00197 }
00198 $char_code = ( (( ord( $multi_char[$offs + 0] ) & 0x01 ) << 30) +
00199 (( ord( $multi_char[$offs + 1] ) & 0x3f ) << 24) +
00200 (( ord( $multi_char[$offs + 2] ) & 0x3f ) << 18) +
00201 (( ord( $multi_char[$offs + 3] ) & 0x3f ) << 12) +
00202 (( ord( $multi_char[$offs + 4] ) & 0x3f ) << 6) +
00203 (( ord( $multi_char[$offs + 5] ) & 0x3f )) );
00204 $offs += 6;
00205 if ( $char_code < 67108864 )
00206 continue;
00207 }
00208 else
00209 {
00210 $offs += 1;
00211 continue;
00212 }
00213
00214
00215 if ( isset( $codeMap[$char_code] ) )
00216 {
00217 $code = $codeMap[$char_code];
00218 if ( $code <= 0xff )
00219 $text .= chr( $code );
00220 else
00221 $text .= chr( ( $code >> 8 ) & 0xff ) . chr( $code & 0xff );
00222 }
00223 else
00224 $text .= chr( $subChar );
00225 }
00226 return $text;
00227 }
00228
00229 function strlen( &$str )
00230 {
00231 if ( $this->CharsetEncodingScheme == "doublebyte" )
00232 {
00233 $len = strlen( $str );
00234 $strlen = 0;
00235 for ( $i = 0; $i < $len; )
00236 {
00237 $charLen = 1;
00238 $code = ord( $str[$i] );
00239 if ( isset( $this->ReadExtraMap[$code] ) )
00240 $charLen = 2;
00241 ++$strlen;
00242 $i += $charLen;
00243 }
00244 return $strlen;
00245 }
00246 else
00247 return strlen( $str );
00248 }
00249
00250 function strlenFromUTF8( &$str )
00251 {
00252 $utf8_codec =& eZUTF8Codec::instance();
00253 return $utf8_codec->strlen( $str );
00254 }
00255
00256 function charToUtf8( &$str, $pos, &$charLen )
00257 {
00258 $code = ord( $str[$pos] );
00259 $charLen = 1;
00260 if ( isset( $this->ReadExtraMap[$code] ) )
00261 {
00262 $code = ( $code << 8 ) | ord( $str[$pos+1] );
00263 $charLen = 2;
00264 }
00265 if ( isset( $this->UTF8Map[$code] ) )
00266 return $this->UTF8Map[$code];
00267 return null;
00268 }
00269
00270 function charToUnicode( &$str, $pos, &$charLen )
00271 {
00272 $code = ord( $str[$pos] );
00273 $charLen = 1;
00274 if ( isset( $this->ReadExtraMap[$code] ) )
00275 {
00276 $code = ( $code << 8 ) | ord( $str[$pos+1] );
00277 $charLen = 2;
00278 }
00279 if ( isset( $this->UnicodeMap[$code] ) )
00280 return $this->UnicodeMap[$code];
00281 return null;
00282 }
00283
00284 function codeToUtf8( &$code )
00285 {
00286 return $this->UTF8Map[$code];
00287 }
00288
00289 function codeToUnicode( &$code )
00290 {
00291 if ( isset( $this->UnicodeMap[$code] ) )
00292 {
00293 return $this->UnicodeMap[$code];
00294 }
00295 return null;
00296 }
00297
00298 function utf8ToChar( &$ucode )
00299 {
00300 if ( isset( $this->UTF8CodeMap[$ucode] ) )
00301 {
00302 $code = $this->UTF8CodeMap[$ucode];
00303 if ( $code <= 0xff )
00304 return chr( $code );
00305 else
00306 return chr( ( $code >> 8 ) & 0xff ) . chr( $code & 0xff );
00307 }
00308 else
00309 return chr( $this->SubstituteChar );
00310 }
00311
00312 function unicodeToChar( &$ucode )
00313 {
00314 if ( isset( $this->CodeMap[$ucode] ) )
00315 {
00316 $code = $this->CodeMap[$ucode];
00317 if ( $code <= 0xff )
00318 return chr( $code );
00319 else
00320 return chr( ( $code >> 8 ) & 0xff ) . chr( $code & 0xff );
00321 }
00322 else
00323 return chr( $this->SubstituteChar );
00324 }
00325
00326 function utf8ToCode( &$ucode )
00327 {
00328 if ( isset( $this->UTF8CodeMap[$ucode] ) )
00329 return $this->UTF8CodeMap[$ucode];
00330 return null;
00331 }
00332
00333 function unicodeToCode( &$ucode )
00334 {
00335 if ( isset( $this->CodeMap[$ucode] ) )
00336 return $this->CodeMap[$ucode];
00337 return null;
00338 }
00339
00340 function substituteChar()
00341 {
00342 return $this->SubstituteChar;
00343 }
00344
00345 function setSubstituteChar( $char )
00346 {
00347 $this->SubstituteChar = $char;
00348 }
00349
00350
00351
00352
00353
00354 function exists( $charset_code )
00355 {
00356 $file = eZCodePage::fileName( $charset_code );
00357 return file_exists( $file );
00358 }
00359
00360
00361
00362
00363
00364 function fileName( $charset_code )
00365 {
00366 $charset_code = eZCharsetInfo::realCharsetCode( $charset_code );
00367 $file = "share/codepages/" . $charset_code;
00368 return $file;
00369 }
00370
00371 function cacheFileName( $charset_code )
00372 {
00373 $permissionArray = eZCodepage::permissionSetting();
00374 $charset_code = eZCharsetInfo::realCharsetCode( $charset_code );
00375 $cache_dir = $permissionArray['var_directory'] . "/codepages/";
00376 $cache_filename = md5( $charset_code );
00377 $cache = $cache_dir . $cache_filename . ".php";
00378 return $cache;
00379 }
00380
00381 function fileModification( $charset_code )
00382 {
00383 $file = eZCodePage::fileName( $charset_code );
00384 if ( !file_exists( $file ) )
00385 return false;
00386 return filemtime( $file );
00387 }
00388
00389 function codepageList()
00390 {
00391 $list = array();
00392 $dir = "share/codepages/";
00393 $dh = opendir( $dir );
00394 while ( ( $file = readdir( $dh ) ) !== false )
00395 {
00396 if ( $file == "." or
00397 $file == ".." or
00398 preg_match( "/^\./", $file ) or
00399 preg_match( "/~$/", $file ) )
00400 continue;
00401 $list[] = $file;
00402 }
00403 closedir( $dh );
00404 sort( $list );
00405 return $list;
00406 }
00407
00408
00409
00410
00411
00412 function storeCacheObject( $filename, $permissionArray )
00413 {
00414
00415 $cache_dir = $permissionArray['var_directory'] . "/codepages/";
00416
00417
00418
00419 $str = "\$umap = array();\n\$utf8map = array();\n\$cmap = array();\n\$utf8cmap = array();\n";
00420 reset( $this->UnicodeMap );
00421 while ( ( $key = key( $this->UnicodeMap ) ) !== null )
00422 {
00423 $item =& $this->UnicodeMap[$key];
00424 $str .= "\$umap[$key] = $item;\n";
00425 next( $this->UnicodeMap );
00426 }
00427 reset( $this->UTF8Map );
00428 while ( ( $key = key( $this->UTF8Map ) ) !== null )
00429 {
00430 $item =& $this->UTF8Map[$key];
00431 $val = str_replace( array( "\\", "'" ),
00432 array( "\\\\", "\\'" ),
00433 $item );
00434 $str .= "\$utf8map[$key] = '$val';\n";
00435 next( $this->UTF8Map );
00436 }
00437 reset( $this->CodeMap );
00438 while ( ( $key = key( $this->CodeMap ) ) !== null )
00439 {
00440 $item =& $this->CodeMap[$key];
00441 $str .= "\$cmap[$key] = $item;\n";
00442 next( $this->CodeMap );
00443 }
00444 reset( $this->UTF8CodeMap );
00445 while ( ( $key = key( $this->UTF8CodeMap ) ) !== null )
00446 {
00447 $item =& $this->UTF8CodeMap[$key];
00448 if ( $item == 0 )
00449 {
00450 $str .= "\$utf8cmap[chr(0)] = 0;\n";
00451 }
00452 else
00453 {
00454 $val = str_replace( array( "\\", "'" ),
00455 array( "\\\\", "\\'" ),
00456 $key );
00457 $str .= "\$utf8cmap['$val'] = $item;\n";
00458 }
00459 next( $this->UTF8CodeMap );
00460 }
00461 reset( $this->ReadExtraMap );
00462 while ( ( $key = key( $this->ReadExtraMap ) ) !== null )
00463 {
00464 $item =& $this->ReadExtraMap[$key];
00465 $str .= "\$read_extra[$key] = $item;\n";
00466 next( $this->ReadExtraMap );
00467 }
00468
00469 $str = "<?" . "php
00470 $str
00471 \$eZCodePageCacheCodeDate = " . EZ_CODEPAGE_CACHE_CODE_DATE . ";
00472 \$min_char = " . $this->MinCharValue . ";
00473 \$max_char = " . $this->MaxCharValue . ";
00474 ?" . ">";
00475
00476 if ( !file_exists( $cache_dir ) )
00477 {
00478
00479
00480
00481 $oldPermissionSetting = umask( 0 );
00482
00483 include_once( 'lib/ezfile/classes/ezdir.php' );
00484 if ( ! eZDir::mkdir( $cache_dir, $permissionArray['dir_permission'], true ) )
00485 eZDebug::writeError( "Couldn't create cache directory $cache_dir, perhaps wrong permissions", "eZCodepage" );
00486
00487
00488 umask( $oldPermissionSetting );
00489
00490 }
00491 $fd = @fopen( $filename, "w+" );
00492 if ( ! $fd )
00493 {
00494 eZDebug::writeError( "Couldn't write cache file $filename, perhaps wrong permissions or leading directories not created", "eZCodepage" );
00495 }
00496 else
00497 {
00498 fwrite( $fd, $str );
00499 fclose( $fd );
00500 }
00501
00502 if ( file_exists( $filename) )
00503 {
00504
00505 $oldPermissionSetting = umask( 0 );
00506
00507
00508 @chmod( $filename, $permissionArray['file_permission'] );
00509
00510
00511 umask( $oldPermissionSetting );
00512 }
00513 }
00514
00515
00516
00517
00518 function cacheFilepath()
00519 {
00520 $permissionArray = eZCodepage::permissionSetting();
00521 $cache_dir = $permissionArray['var_directory'] . "/codepages/";
00522 $cache_filename = md5( $this->CharsetCode );
00523 $cache = $cache_dir . $cache_filename . ".php";
00524
00525 return $cache;
00526 }
00527
00528
00529
00530
00531
00532
00533
00534
00535 function load( $use_cache = true )
00536 {
00537 $file = "share/codepages/" . $this->CharsetCode;
00538
00539
00540 $permissionArray = eZCodepage::permissionSetting();
00541 $cache_dir = $permissionArray['var_directory'] . "/codepages/";
00542 $cache_filename = md5( $this->CharsetCode );
00543 $cache = $cache_dir . $cache_filename . ".php";
00544
00545 if ( !file_exists( $file ) )
00546 {
00547 eZDebug::writeWarning( "Couldn't load codepage file $file", "eZCodePage" );
00548 return;
00549 }
00550 $file_m = filemtime( $file );
00551 $this->Valid = false;
00552 if ( isset( $GLOBALS['eZSiteBasics'] ) )
00553 {
00554 $siteBasics = $GLOBALS['eZSiteBasics'];
00555 if ( isset( $siteBasics['no-cache-adviced'] ) and
00556 $siteBasics['no-cache-adviced'] )
00557 $use_cache = false;
00558 }
00559 if ( file_exists( $cache ) and $use_cache )
00560 {
00561 $cache_m = filemtime( $cache );
00562 if ( $file_m <= $cache_m )
00563 {
00564 unset( $eZCodePageCacheCodeDate );
00565 $umap =& $this->UnicodeMap;
00566 $utf8map =& $this->UTF8Map;
00567 $cmap =& $this->CodeMap;
00568 $utf8cmap =& $this->UTF8CodeMap;
00569 $min_char =& $this->MinCharValue;
00570 $max_char =& $this->MaxCharValue;
00571 $read_extra =& $this->ReadExtraMap;
00572 include( $cache );
00573 unset( $umap );
00574 unset( $utf8map );
00575 unset( $cmap );
00576 unset( $utf8map );
00577 unset( $min_char );
00578 unset( $max_char );
00579 unset( $read_extra );
00580 if ( isset( $eZCodePageCacheCodeDate ) and
00581 $eZCodePageCacheCodeDate == EZ_CODEPAGE_CACHE_CODE_DATE )
00582 {
00583 $this->Valid = true;
00584 return;
00585 }
00586 }
00587 }
00588
00589 $utf8_codec =& eZUTF8Codec::instance();
00590
00591 $this->UnicodeMap = array();
00592 $this->UTF8Map = array();
00593 $this->CodeMap = array();
00594 $this->UTF8CodeMap = array();
00595 $this->ReadExtraMap = array();
00596 for ( $i = 0; $i < 32; ++$i )
00597 {
00598 $code = $i;
00599 $ucode = $i;
00600 $utf8_code = $utf8_codec->toUtf8( $ucode );
00601 $this->UnicodeMap[$code] = $ucode;
00602 $this->UTF8Map[$code] = $utf8_code;
00603 $this->CodeMap[$ucode] = $code;
00604 $this->UTF8CodeMap[$utf8_code] = $code;
00605 }
00606 $this->MinCharValue = 0;
00607 $this->MaxCharValue = 31;
00608
00609 $lines = file( $file );
00610 reset( $lines );
00611 while ( ( $key = key( $lines ) ) !== null )
00612 {
00613 if ( preg_match( "/^#/", $lines[$key] ) )
00614 {
00615 next( $lines );
00616 continue;
00617 }
00618 $line = trim( $lines[$key] );
00619 $items = explode( "\t", $line );
00620 if ( count( $items ) == 3 )
00621 {
00622 $code = false;
00623 $ucode = false;
00624 $desc = $items[2];
00625 if ( preg_match( "/(=|0x)([0-9a-fA-F]{4})/", $items[0], $args ) )
00626 {
00627 $code = hexdec( $args[2] );
00628
00629 }
00630 else if ( preg_match( "/(=|0x)([0-9a-fA-F]{2})/", $items[0], $args ) )
00631 {
00632 $code = hexdec( $args[2] );
00633
00634 }
00635 if ( preg_match( "/(U\+|0x)([0-9a-fA-F]{4})/", $items[1], $args ) )
00636 {
00637 $ucode = hexdec( $args[2] );
00638 }
00639
00640 if ( $code !== false and
00641 $ucode !== false )
00642 {
00643 $utf8_code = $utf8_codec->toUtf8( $ucode );
00644 $this->UnicodeMap[$code] = $ucode;
00645 $this->UTF8Map[$code] = $utf8_code;
00646 $this->CodeMap[$ucode] = $code;
00647 $this->UTF8CodeMap[$utf8_code] = $code;
00648 $this->MinCharValue = min( $this->MinCharValue, $code );
00649 $this->MaxCharValue = max( $this->MaxCharValue, $code );
00650 }
00651 else if ( $code !== false )
00652 {
00653 $this->ReadExtraMap[$code] = true;
00654 }
00655 }
00656 next( $lines );
00657 }
00658
00659 $this->Valid = true;
00660 $this->MinCharValue = min( $this->MinCharValue, $code );
00661 $this->MaxCharValue = max( $this->MaxCharValue, $code );
00662
00663 if ( $use_cache )
00664 {
00665
00666 $permissionArray = $this->permissionSetting();
00667
00668
00669 if ( $permissionArray === false )
00670 {
00671 if ( !isset ( $GLOBALS['EZCODEPAGECACHEOBJECTLIST'] ) )
00672 {
00673 $GLOBALS['EZCODEPAGECACHEOBJECTLIST'] = array();
00674 }
00675
00676
00677 $GLOBALS['EZCODEPAGECACHEOBJECTLIST'][] =& $this;
00678 }
00679
00680 else
00681 {
00682
00683 $this->storeCacheObject( $cache, $permissionArray );
00684
00685
00686 }
00687 }
00688 }
00689
00690
00691
00692
00693
00694
00695 function charsetCode()
00696 {
00697 return $this->CharsetCode;
00698 }
00699
00700
00701
00702
00703 function requestedCharsetCode()
00704 {
00705 return $this->RequestedCharsetCode;
00706 }
00707
00708
00709
00710
00711 function minCharValue()
00712 {
00713 return $this->MinCharValue;
00714 }
00715
00716
00717
00718
00719 function maxCharValue()
00720 {
00721 return $this->MaxCharValue;
00722 }
00723
00724
00725
00726
00727 function isValid()
00728 {
00729 return $this->Valid;
00730 }
00731
00732
00733
00734
00735 function &instance( $charset_code, $use_cache = true )
00736 {
00737 $cp =& $GLOBALS["eZCodePage-$charset_code"];
00738 if ( get_class( $cp ) != "ezcodepage" )
00739 {
00740 $cp = new eZCodePage( $charset_code, $use_cache );
00741 }
00742 return $cp;
00743 }
00744
00745
00746
00747
00748
00749
00750
00751 function permissionSetting()
00752 {
00753
00754
00755 if ( isset( $GLOBALS['EZCODEPAGEPERMISSIONS'] ) )
00756 {
00757 return $GLOBALS['EZCODEPAGEPERMISSIONS'];
00758 }
00759 else
00760 {
00761 return false;
00762 }
00763 }
00764
00765
00766
00767
00768
00769
00770 function setPermissionSetting( $permissionArray )
00771 {
00772
00773
00774 $GLOBALS['EZCODEPAGEPERMISSIONS'] = $permissionArray;
00775
00776 if ( $permissionArray !== false )
00777 {
00778 eZCodepage::flushCacheObject();
00779 }
00780 }
00781
00782
00783
00784
00785 function flushCacheObject()
00786 {
00787
00788 if ( !isset( $GLOBALS['EZCODEPAGECACHEOBJECTLIST'] ) )
00789 {
00790 return false;
00791 }
00792
00793
00794 $permissionArray = eZCodepage::permissionSetting();
00795
00796
00797 if ( $permissionArray === false )
00798 {
00799
00800
00801
00802 return false;
00803 }
00804
00805 else
00806 {
00807
00808
00809
00810 foreach( array_keys( $GLOBALS['EZCODEPAGECACHEOBJECTLIST'] ) as $codePageKey )
00811 {
00812 $codePage =& $GLOBALS['EZCODEPAGECACHEOBJECTLIST'][$codePageKey];
00813
00814 $filename = $codePage->cacheFilepath();
00815
00816
00817 $codePage->storeCacheObject( $filename, $permissionArray );
00818 }
00819
00820
00821 unset( $GLOBALS['EZCODEPAGECACHEOBJECTLIST'] );
00822 }
00823 }
00824
00825
00826
00827 var $RequestedCharsetCode;
00828
00829 var $CharsetCode;
00830
00831 var $CharsetEncodingScheme;
00832
00833 var $UnicodeMap;
00834
00835 var $UTF8Map;
00836
00837 var $CodeMap;
00838
00839 var $UTF8CodeMap;
00840
00841 var $MinCharValue;
00842
00843 var $MaxCharValue;
00844
00845 var $Valid;
00846
00847 var $SubstituteChar;
00848 }
00849
00850
00851 if ( isset( $GLOBALS['EZCODEPAGEPERMISSIONS'] ) and
00852 $GLOBALS['EZCODEPAGEPERMISSIONS'] !== false )
00853 {
00854 eZCodepage::flushCacheObject();
00855 }
00856
00857 ?>