Changeset 1555 for trunk/gregarius/dist

Show
Ignore:
Timestamp:
09/03/06 15:04:40 (2 years ago)
Author:
cfriesen
Message:

Still wouldn't run it, but the logic makes sense.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/dist/convert.php

    r1554 r1555  
    22    include_once('intl/en.php'); 
    33 
     4    $EXCLUDE = array('intl', 'extlib'); 
     5 
    46    function Convert($dir) 
    57    { 
    6         if(!is_dir($dir) || "intl" == $dir) { 
     8        global $EXCLUDE; 
     9 
     10        if(!is_dir($dir) || in_array($dir, $EXCLUDE)) { 
    711            return; 
    812        } 
     
    1014        $baseDir = opendir($dir); 
    1115        while($file = readdir($baseDir)) { 
    12             if("." == $file || 
    13                  ".." == $file) { 
     16            if('.' == $file || 
     17                 '..' == $file) { 
    1418                continue; 
    1519            } 
     
    1822                Convert($file); 
    1923            } else { 
    20                 $fp = fopen($file, 'w+'); 
     24                $old = fopen($file, 'r'); 
     25                $new = fopen($file . '.new', 'w'); 
    2126 
    22                 while(($line = fread($fp) != feof()) { 
     27                while(($line = fread($old)) != feof($old)) { 
     28                    preg_match('/\.*.LBL_*.\.', $line, $matches); 
    2329 
     30                    if(is_array($matches)) { 
     31                        foreach($matches as $match) { 
     32                            preg_replace($match, eval('echo ' . $match . ';'), $line); 
     33                        } 
     34                    } 
    2435 
     36                    fwrite($new, $line); 
    2537                } 
    26                 flush($fp); 
    27                 fclose($fp); 
    2838 
    29 #               define('A', "Hello, World"); 
    30 #               $con = "A"; 
    31 #               $val = eval('echo ' . $con . ';'); 
    32 #               echo $val; 
     39                flush($new); 
     40                fclose($old); 
     41                fclose($new); 
     42 
     43                rename($old, $old . '.old'); 
     44                rename($new, $old); 
     45 
     46                echo "Completed .. " . $old . "\n"; 
    3347            } 
    3448        } 
    3549    } 
    3650 
    37     Convert("."); 
     51    Convert('.'); 
    3852?>