version 1.1090, 2012/08/07 10:52:17
|
version 1.1092, 2012/08/14 15:45:06
|
Line 70 use Apache::lonclonecourse();
|
Line 70 use Apache::lonclonecourse();
|
use LONCAPA qw(:DEFAULT :match); |
use LONCAPA qw(:DEFAULT :match); |
use DateTime::TimeZone; |
use DateTime::TimeZone; |
use DateTime::Locale::Catalog; |
use DateTime::Locale::Catalog; |
|
use Text::Aspell; |
|
|
# ---------------------------------------------- Designs |
# ---------------------------------------------- Designs |
use vars qw(%defaultdesign); |
use vars qw(%defaultdesign); |
Line 3063 Note: This sub assumes that aspell is in
|
Line 3064 Note: This sub assumes that aspell is in
|
|
|
sub check_spelling { |
sub check_spelling { |
my ($wordlist, $language) = @_; |
my ($wordlist, $language) = @_; |
|
my @misspellings; |
|
|
|
# Generate the speller and set the langauge. |
|
# if explicitly selected: |
|
|
# Format the command. If $language is null then |
my $speller = Text::Aspell->new; |
# don't request a language - Note that's dangerous |
|
# because there's no assurance the server is running the intended default |
|
# language. |
|
|
|
my $langswitch = ''; |
|
if ($language) { |
if ($language) { |
$langswitch = "--lang=$language"; |
$speller->set_option('lang', $language); |
} |
} |
|
|
my $aspell_command = "aspell -a $language"; |
# Turn the word list into an array of words by splittingon whitespace |
my $full_command = "echo $wordlist | $aspell_command"; |
|
|
|
my $ispell_result = `$full_command`; |
|
|
|
# The result is several lines of text. |
my @words = split(/\s+/, $wordlist); |
# the first line will start with @(#). Other wise |
|
# There's an error. With an error our fallback is to declare |
|
# all the words are correctly spelled (return empty string). |
|
|
|
my @misspellings; |
foreach my $word (@words) { |
my @lines = split(/\n/, $ispell_result); |
if(! $speller->check($word)) { |
my $heading = shift(@lines); # header |
push(@misspellings, $word); |
if ($heading =~ /^\@\(#\) /) { |
|
foreach my $word (split(/\s+/, $wordlist)) { |
|
my $spellok = pop(@lines); |
|
if (!($spellok =~ /^\*/)) { |
|
push(@misspellings, $word); |
|
} |
|
} |
} |
return join(' ', (@misspellings)); # empty if all words ok. |
|
} else { |
|
return ""; |
|
} |
} |
|
return join(' ', @misspellings); |
|
|
} |
} |
|
|
# -------------------------------------------------------------- Plaintext name |
# -------------------------------------------------------------- Plaintext name |
Line 13885 sub init_user_environment {
|
Line 13872 sub init_user_environment {
|
\%userenv,\%domdef,\%is_adv); |
\%userenv,\%domdef,\%is_adv); |
} |
} |
|
|
|
$userenv{'canrequest.author'} = |
|
&Apache::lonnet::usertools_access($username,$domain,'requestauthor', |
|
'reload','requestauthor', |
|
\%userenv,\%domdef,\%is_adv); |
|
my %reqauthor = &Apache::lonnet::get('requestauthor',['author_status','author'], |
|
$domain,$username); |
|
my $reqstatus = $reqauthor{'author_status'}; |
|
if ($reqstatus eq 'approval' || $reqstatus eq 'approved') { |
|
if (ref($reqauthor{'author'}) eq 'HASH') { |
|
$userenv{'requestauthorqueued'} = $reqstatus.':'. |
|
$reqauthor{'author'}{'timestamp'}; |
|
} |
|
} |
|
|
$env{'user.environment'} = "$lonids/$cookie.id"; |
$env{'user.environment'} = "$lonids/$cookie.id"; |
|
|
if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id", |
if (tie(my %disk_env,'GDBM_File',"$lonids/$cookie.id", |