Ignore:
Timestamp:
12/26/07 04:28:00 (4 years ago)
Author:
bogdanpasoi@…
Message:

New diff.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/controllers/textblock.php

    r852 r877  
    44require_once(IA_ROOT_DIR . "common/db/textblock.php"); 
    55require_once(IA_ROOT_DIR . "common/textblock.php"); 
     6require_once(IA_ROOT_DIR . "common/diff.php"); 
    67 
    7 // smart ass diff 
    8 function string_diff($string1, $string2) { 
    9     $name1 = tempnam(IA_ROOT_DIR.'attach/', "ia"); 
    10     $name2 = tempnam(IA_ROOT_DIR.'attach/', "ia"); 
    11     $fp1 = fopen($name1, "w"); 
    12     if (!$fp1) { 
    13         flash_error("Eroare la comparare!"); 
    14         request(url_home()); 
    15     } 
    16     $string1 .= "\n"; 
    17     fputs($fp1, $string1); 
    18     fclose($fp1); 
    19  
    20     $fp2 = fopen($name2, "w"); 
    21     if (!$fp2) { 
    22         flash_error("Eroare la comparare!"); 
    23         request(url_home()); 
    24     } 
    25     $string2 .= "\n"; 
    26     fputs($fp2, $string2); 
    27     fclose($fp2); 
    28  
    29     ob_start(); 
    30     system("diff -au ".$name1." ".$name2); 
    31     $ret = ob_get_contents(); 
    32     ob_end_clean(); 
    33     if (!unlink($name1)) { 
    34         flash_error("Eroare la comparare!"); 
    35         request(url_home()); 
    36     } 
    37     if (!unlink($name2)) { 
    38         flash_error("Eroare la comparare!"); 
    39         request(url_home()); 
    40     } 
    41     return $ret; 
    42 } 
    438 
    449// View a plain textblock. 
     
    12691    log_assert_valid(textblock_validate($revto)); 
    12792 
    128     $diff_title = string_diff($revfrom['title'], $revto['title']); 
    129     $diff_content = string_diff($revfrom['text'], $revto['text']); 
     93    $diff_title = string_diff(array($revfrom['title'], $revto['title'])); 
     94    $diff_content = string_diff(array($revfrom['text'], $revto['text'])); 
    13095 
    13196    $view = array(); 
     
    13499    $view['revfrom_id'] = $revfrom_id; 
    135100    $view['revto_id'] = $revto_id; 
    136     $view['diff_title'] = explode("\n", $diff_title); 
    137     $view['diff_content'] = explode("\n", $diff_content); 
     101    $view['diff_title'] = $diff_title; 
     102    $view['diff_content'] = $diff_content; 
    138103    execute_view_die('views/textblock_diff.php', $view); 
    139104} 
Note: See TracChangeset for help on using the changeset viewer.