this bug 6014 was solved, added a way to validate if a file exist

This commit is contained in:
Carlos Pacha
2011-01-26 21:16:48 +00:00
parent 3b5414df51
commit 60ea1b73a9

View File

@@ -93,26 +93,36 @@ class Translation extends BaseTranslation {
}
}
if( ! is_dir(dirname($cacheFile)) )
G::mk_dir(dirname($cacheFile));
$f = fopen( $cacheFile , 'w+');
fwrite( $f , "<?php\n" );
fwrite( $f , '$translation =' . 'unserialize(\'' . addcslashes( serialize ( $translation ), '\\\'' ) . "');\n");
fwrite( $f , "?>" );
fclose( $f );
try {
if( ! is_dir(dirname($cacheFile)) )
G::mk_dir(dirname($cacheFile));
$json=new Services_JSON();
if (!file_exists($cacheFile) || !file_exists($cacheFileJS)){
$error = 'translation file does not exist';
throw new Exception($error);
}
$f = fopen( $cacheFile , 'w+');
fwrite( $f , "<?php\n" );
fwrite( $f , '$translation =' . 'unserialize(\'' . addcslashes( serialize ( $translation ), '\\\'' ) . "');\n");
fwrite( $f , "?>" );
fclose( $f );
$f = fopen( $cacheFileJS , 'w');
fwrite( $f , "var G_STRINGS =". $json->encode( $translationJS ) . ";\n");
fclose( $f );
$json=new Services_JSON();
$f = fopen( $cacheFileJS , 'w');
fwrite( $f , "var G_STRINGS =". $json->encode( $translationJS ) . ";\n");
fclose( $f );
$res['cacheFile'] = $cacheFile;
$res['cacheFileJS'] = $cacheFileJS;
$res['rows'] = count ( $translation );
$res['rowsJS'] = count ( $translationJS );
return $res;
} catch( Exception $e ) {
//echo 'Caught exception: ', $e->getMessage(), "\n";
}
$res['cacheFile'] = $cacheFile;
$res['cacheFileJS'] = $cacheFileJS;
$res['rows'] = count ( $translation );
$res['rowsJS'] = count ( $translationJS );
return $res;
}
/**