Changeset 1005

Show
Ignore:
Timestamp:
04/19/02 10:42:00 (11 years ago)
Author:
bradfitz
Message:

more lang/text work

Location:
trunk/bin/upgrading
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/bin/upgrading/texttool.pl

    r1001 r1005  
    2929  dumptext     Dump lang text based on text[-local].dat information 
    3030  check        Check validity of text[-local].dat files 
     31  wipedb       Remove all language/text data from database. 
    3132  newitems     Search files in htdocs, cgi-bin, & bin and insert 
    3233               necessary text item codes in database. 
     
    141142popstruct() if $mode eq "dump"; 
    142143newitems() if $mode eq "newitems"; 
     144wipedb() if $mode eq "wipedb"; 
    143145help(); 
     146 
     147sub wipedb 
     148{ 
     149    $dbh->do("DELETE FROM ml_$_") 
     150        foreach (qw(domains items langdomains langs latest text)); 
     151    exit 0;                  
     152} 
    144153 
    145154sub popstruct 
     
    166175 
    167176    print "All done.\n"; 
     177    exit 0; 
     178} 
     179 
     180sub poptext 
     181{ 
     182    foreach my $lang (keys %lang_code) 
     183    { 
     184        print "$lang\n"; 
     185        my $l = $lang_code{$lang}; 
     186        open (D, "$ENV{'LJHOME'}/bin/upgrading/${lang}.dat") 
     187            or die "Can't find $lang.dat\n"; 
     188        my $lnum = 0; 
     189        my ($code, $text); 
     190        while (my $line = <D>) { 
     191            $lnum++; 
     192            if ($line =~ /^(\S+?)=(.*)/) { 
     193                ($code, $text) = ($1, $2); 
     194            } elsif ($line =~ /^(\S+?)\<\<\s*$/) { 
     195                ($code, $text) = ($1, ""); 
     196                while (<D>) { 
     197                    last if $_ eq ".\n"; 
     198                    s/^\.//; 
     199                    $text .= $_; 
     200                } 
     201            } elsif ($line =~ /\S/) { 
     202                die "$lang.dat:$lnum: Bogus format.\n"; 
     203            } 
     204 
     205            my $qcode = $dbh->quote($code); 
     206            my $exists = $dbh->selectrow_array("SELECT COUNT(*) FROM ml_latest l, ml_items i ". 
     207                                               "WHERE l.dmid=1 AND i.dmid AND i.itcode=$qcode AND ". 
     208                                               "i.itid=l.itid AND l.lnid=$l->{'lnid'}"); 
     209            if (! $exists) { 
     210                print " adding: $code = "; 
     211                my $res = LJ::Lang::set_text($dbh, 1, $lang, $code, $text); 
     212                print "$res\n"; 
     213            } 
     214        } 
     215        close D; 
     216    } 
    168217    exit 0; 
    169218} 
  • trunk/bin/upgrading/update-db-general.pl

    r999 r1005  
    14161416   PRIMARY KEY (lnid, dmid, itid), 
    14171417   chgtime  DATETIME NOT NULL, 
    1418    txtid     INT UNSIGNED NOT NULL, 
    1419    version   SMALLINT UNSIGNED NOT NULL, 
     1418   staleness  TINYINT UNSIGNED DEFAULT 0 NOT NULL, # better than ENUM('0','1','2'); 
     1419   INDEX (lnid, staleness), 
    14201420   INDEX (dmid, itid), 
    14211421   INDEX (lnid, dmid, chgtime),