--- loncom/interface/portfolio.pm 2006/06/22 15:33:35 1.109 +++ loncom/interface/portfolio.pm 2006/06/22 19:11:13 1.117 @@ -31,7 +31,7 @@ use Apache::lonfeedback; use Apache::lonlocal; use Apache::lonnet; use Apache::longroup; -use lib '/home/httpd/lib/perl'; +use HTML::Entities; use LONCAPA; # receives a file name and path stub from username/userfiles/portfolio/ @@ -40,9 +40,9 @@ sub make_anchor { my ($url, $filename, $current_path, $current_mode, $field_name, $continue_select,$group) = @_; if ($continue_select ne 'true') {$continue_select = 'false'}; - my $anchor = ''.$filename.''; return $anchor; @@ -63,42 +63,43 @@ sub display_common { 'createdir' => 'Create Subdirectory', 'createdir_label' => 'Create subdirectory in current directory:'); + my $escuri = &HTML::Entities::encode($r->uri,'&<>"'); $r->print(<<"TABLE"); - - - - - '); + $r->print('
- $text{'upload_label'} - $groupitem + + + + - - - - - - + + + + - - + + +
+ $text{'upload_label'} + $groupitem + -
- $text{'createdir_label'} - + +
+ $text{'createdir_label'} + +
$groupitem -
TABLE my @tree = split (/\//,$current_path); - $r->print(''.&make_anchor($url,$port_path,'/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"},$group).'/'); + $r->print(''.&make_anchor($url,$port_path,'/',$env{"form.mode"},$env{"form.fieldname"},$env{"form.continue"},$group).'/'); if (@tree > 1){ my $newCurrentPath = ''; for (my $i = 1; $i< @tree; $i++){ @@ -106,11 +107,11 @@ TABLE $r->print(&make_anchor($url,$tree[$i],'/'.$newCurrentPath, $env{"form.mode"},$env{"form.fieldname"}, $env{"form.continue"},$group).'/'); } } - $r->print(''); + $r->print(''); &Apache::lonhtmlcommon::store_recent($namespace,$current_path,$current_path); - $r->print('
'. &Apache::lonhtmlcommon::select_recent($namespace,'currentpath', @@ -153,13 +154,13 @@ sub display_directory { return; } if ($select_mode eq 'true') { - $r->print(''. - ''); $r->print(''); + $r->print('
Select NameSizeLast Modified
'. + ''); } else { - $r->print('
Select NameSizeLast Modified
'. - ''); $r->print(''); + $r->print('
Actions NameSizeLast ModifiedCurrent Access Status
'. + ''); } if (defined($group)) { $r->print("\n".$groupitem."\n"); @@ -189,16 +190,17 @@ sub display_directory { my ($fname,$version,$extension) = &Apache::grades::file_name_version_ext($filename); if (($filename ne '.') && ($filename ne '..') && ($filename !~ /\.meta$/ ) && ($filename !~ /(.*)\.(\d+)\.([^\.]*)$/)) { if ($dirptr&$testdir) { + my $colspan='colspan="2"'; if ($select_mode eq 'true'){ - $r->print(''); - } else { - $r->print(''); + undef($colspan); } + $r->print(''); $r->print(''); $r->print(''); $r->print(''); } else { - $r->print(''); + my $css_class = 'LC_browser_file'; + my $line; my $version_flag; if (exists($versioned{$fname})) { $version_flag = "*"; @@ -208,22 +210,25 @@ sub display_directory { my $fullpath = $current_path.$filename; $fullpath = &prepend_group($fullpath,$group); if ($select_mode eq 'true'){ - $r->print(''); + $line.=' />'; } else { if (exists $locked_files{$fullpath}) { - $r->print(''); + $line.=''; + $css_class= 'LC_browser_file_locked'; } else { my $cat=''.&mt('Catalog Information').
 			    ''; - $r->print(''); + '; } + $r->print(''); + $r->print($line); } my $curr_access; my $pub_access = 0; @@ -256,15 +261,15 @@ sub display_directory { } $curr_access = join('+ ',@allaccesses); } - $r->print(''); + $r->print(''); $r->print(''); $r->print(''); $r->print(''); - $r->print(''); + '">'.&mt('View/Change').''); $r->print(''); } } @@ -316,7 +321,7 @@ sub close_form { $group.'" />'); } $r->print('

'); - $r->print(' + $r->print('

'); @@ -331,16 +336,20 @@ sub close_form { sub display_file { my ($path,$filename)=@_; my $display_file_text; + my $file_start=''; + my $file_end=''; if (!defined($path)) { $path=$env{'form.currentpath'}; } if (!defined($filename)) { $filename=$env{'form.selectfile'}; - $display_file_text = ''.$path.$filename.''; + $display_file_text = $file_start.$path.$filename.$file_end; } elsif (ref($filename) eq "ARRAY") { - foreach (@$filename) { - $display_file_text .= ''.$path.$_.'
'; + foreach my $file (@$filename) { + $display_file_text .= $file_start.$path.$file.$file_end.'
'; } } elsif (ref($filename) eq "SCALAR") { - $display_file_text = ''.$path.$filename.''; + $display_file_text = $file_start.$path.$$filename.$file_end; + } else { + $display_file_text = $file_start.$path.$filename.$file_end; } return $display_file_text; } @@ -394,8 +403,8 @@ sub delete_confirmed { $env{'form.currentpath'}. $delete_file); if ($result ne 'ok') { - $r->print(' An error occured ('.$result. - ') while trying to delete '.&display_file(undef, $delete_file).'
'); + $r->print(' An error occured ('.$result. + ') while trying to delete '.&display_file(undef, $delete_file).'
'); } } $r->print(&done(undef,$url,$group)); @@ -419,8 +428,8 @@ sub delete_dir_confirmed { $directory_name); if ($result ne 'ok') { - $r->print(' An error occured (dir) ('.$result. - ') while trying to delete '.$directory_name.'
'); + $r->print(' An error occured (dir) ('.$result. + ') while trying to delete '.$directory_name.'
'); } else { # now remove from recent # $r->print('
removing '.$directory_name.'
print(''. + $r->print(''. &mt("Error: no valid filename was provided to rename to."). - '
'); + '
'); $r->print(&done(undef,$url,$group)); return; } @@ -470,12 +479,15 @@ sub rename_confirmed { $port_path.$env{'form.currentpath'}.$env{'form.selectfile'}, $port_path.$env{'form.currentpath'}.$filenewname); if ($result ne 'ok') { - $r->print(' An errror occured ('.$result. - ') while trying to rename '.&display_file().' to '. - &display_file(undef,$filenewname).'
'); + $r->print(''. + &mt('An errror occured ([_1]) while trying to rename [_2]' + .' to [_3]',$result,&display_file(), + &display_file('',$filenewname)).'
'); } if ($filenewname ne $env{'form.filenewname'}) { - $r->print("The new file name was changed from:
".$env{'form.filenewname'}." to $filenewname "); + $r->print(&mt("The new file name was changed from:
[_1] to [_2]", + ''.&display_file('',$env{'form.filenewname'}).'', + ''.&display_file('',$filenewname).'')); } $r->print(&done(undef,$url,$group)); } @@ -547,16 +559,18 @@ sub update_access { my $updated_controls = $access_controls{$file_name}; my ($showstart,$showend); $r->print(&Apache::loncommon::start_data_table()); - $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(&Apache::loncommon::start_data_table_header_row()); $r->print('

'); - $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table_header_row()); foreach my $chg (sort(keys(%processing))) { if (@{$processing{$chg}} > 0) { if ($chg eq 'delete') { if (!($deloutcome eq 'ok')) { - $errors .= &mt('A problem occurred deleting access controls: [_1]',$deloutcome); + $errors .=''. + &mt('A problem occurred deleting access controls: [_1]',$deloutcome). + ''; next; } } @@ -658,7 +672,9 @@ sub update_access { $r->print(&Apache::loncommon::end_data_table()); } else { if ((@{$processing{'activate'}} > 0) || (@{$processing{'update'}} > 0)) { - $errors .= &mt('A problem occurred storing access control settings: [_1]',$outcome); + $errors .= ''. + &mt('A problem occurred storing access control settings: [_1]',$outcome). + ''; } } if ($errors) { @@ -693,7 +709,7 @@ sub update_access { &close_form($r,$url,$group); } else { $r->print('
'. + '&currentpath='.$env{'form.currentpath'}.'">'. &mt('Display all access settings for this file').''); } return; @@ -830,9 +846,9 @@ sub access_setting_table { $r->print('
Actions NameSizeLast ModifiedCurrent Access Status
'.&mt('closed folder').'Go to ...'.&make_anchor($url,$filename.'/',$current_path.$filename.'/',$env{'form.mode'},$env{"form.fieldname"},$env{'form.continue'},$group).'
print("CHECKED"); + $line='print('>LockedLocked + $line.=' Rename '.$cat.' -
'. $filename.''.$size.''.&Apache::lonlocal::locallocaltime($mtime).''.&mt($curr_access).'   '. + $r->print(''.&mt($curr_access).'   '. ''.&mt('View/Change').'
'.&mt('Type of change').''. &mt('Access control').''.&mt('Dates available'). ''.&mt('Additional information').'
'); - $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table_header_row()); $r->print(&Apache::loncommon::start_data_table_row()); if ($public) { $r->print(''); - $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table_header_row()); $r->print(&Apache::loncommon::start_data_table_row()); my $passwd; if ($guest) { @@ -926,8 +942,8 @@ sub display_access_row { my $uctype = $type; $uctype =~ s/^(\w)/uc($1)/e; $r->print(&Apache::loncommon::start_data_table()); - $r->print(&Apache::loncommon::start_data_table_row()); - $r->print(''); if (($type eq 'course') || ($type eq 'group')) { $r->print(''); + $r->print(&Apache::loncommon::end_data_table_row()); } $r->print(&Apache::loncommon::end_data_table()); } else { @@ -964,15 +982,8 @@ sub display_access_row { return; } -sub course_row { - my ($r,$status,$type,$item,$access_controls,$tablecolor,$now,$then) = @_; - my %content; - my $defdom = $env{'user.domain'}; - if ($status eq 'old') { - $defdom = $$access_controls{$item}{'domain'}; - } - $r->print(&Apache::loncommon::coursebrowser_javascript($defdom)); - $r->print(qq| +sub course_js { + return qq| -|); - $r->print(&Apache::loncommon::start_data_table_row()); +|; +} + +sub course_row { + my ($r,$status,$type,$item,$access_controls,$tablecolor,$now,$then) = @_; + my $content; + my $defdom = $env{'user.domain'}; + if ($status eq 'old') { + $content = $$access_controls{$item}; + $defdom = $content->{'domain'}; + } + my $js = &Apache::loncommon::coursebrowser_javascript($defdom) + .&course_js(); my $crsgrptext = 'Groups'; if ($type eq 'group') { $crsgrptext = 'Teams'; } my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then, $type); - $r->print(''); + $r->print(''); if ($status eq 'old') { - my $cid = $content{'domain'}.'_'.$content{'number'}; + my $cid = $content->{'domain'}.'_'.$content->{'number'}; my %course_description = &Apache::lonnet::coursedescription($cid); - $r->print(''); + $r->print(''); } elsif ($status eq 'new') { my $uctype = $type; $uctype =~ s/^(\w)/uc($1)/e; @@ -1036,33 +1058,30 @@ function getIndex(name,value) { &mt($crsgrptext).''); if ($status eq 'old') { my $max_id = 0; - foreach my $role_id (sort(keys(%{$content{'roles'}}))) { + foreach my $role_id (sort(keys(%{$content->{'roles'}}))) { if ($role_id > $max_id) { $max_id = $role_id; } $max_id ++; - my $role_selects = &role_selectors($num,$role_id,$status,$type,\%content,'display'); - $r->print(''.$role_selects.''); + my $role_selects = &role_selectors($num,$role_id,$status,$type,$content,'display'); + $r->print(''.$role_selects.''); } - $r->print('
'); $r->print('

'.&mt('Public access:').' '.$publictext.'

'); $r->print(&Apache::loncommon::start_data_table()); - $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(&Apache::loncommon::start_data_table_header_row()); $r->print('
'.&mt('Action').''.&mt('Dates available').''.&actionbox('old',$publicnum,'public').''. @@ -846,10 +862,10 @@ sub access_setting_table { $r->print(' '); $r->print('

'.&mt('Password-protected access:').' '.$guesttext.'

'); $r->print(&Apache::loncommon::start_data_table()); - $r->print(&Apache::loncommon::start_data_table_row()); + $r->print(&Apache::loncommon::start_data_table_header_row()); $r->print('
'.&mt('Action').''.&mt('Dates available'). ''. &mt('Password').''.&mt('Action?').''.&mt($uctype).''. + $r->print(&Apache::loncommon::start_data_table_header_row()); + $r->print(''.&mt('Action?').''.&mt($uctype).''. &mt('Dates available').''.&mt('Allowed [_1] member affiliations',$type). @@ -938,7 +954,8 @@ sub display_access_row { } elsif ($type eq 'domains') { @all_doms = &Apache::loncommon::get_domains(); } - $r->print(&Apache::loncommon::end_data_table_row()); + $r->print(&Apache::loncommon::end_data_table_header_row()); + $r->print(&Apache::loncommon::start_data_table_row()); foreach my $key (@{$items}) { if (($type eq 'course') || ($type eq 'group')) { &course_row($r,$status,$type,$key,$access_controls, @@ -951,10 +968,11 @@ sub display_access_row { } } $r->print(&Apache::loncommon::end_data_table_row()); - $r->print(&Apache::loncommon::start_data_table_row()); if ($status eq 'old') { + $r->print(&Apache::loncommon::start_data_table_row()); $r->print(''.&additional_item($type). ''.&actionbox($status,$num,$scope).''.$js.&actionbox($status,$num,$scope).''.$course_description{'description'}.''.$course_description{'description'}.'



'.&mt('Add a roles-based condition').' 

'.&mt('Add a roles-based condition').' {'domain'}','$content->{'number'}','Course'".')" value="'.$max_id.'" />'); } elsif ($status eq 'new') { my $role_id = 1; my $role_selects = &role_selectors($num,$role_id,$status,$type,undef,'display'); $r->print(''.&mt('Add').''.$role_selects); $r->print(''); } - $r->print(&Apache::loncommon::end_data_table_row()); return; } sub domains_row { my ($r,$status,$item,$all_doms,$access_controls,$now,$then) = @_; - $r->print(&Apache::loncommon::start_data_table_row()); my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then, 'domains'); - my $dom_select = ''. ' '; - $r->print(&Apache::loncommon::start_data_table_row()); if ($status eq 'old') { my $content = $$access_controls{$item}; foreach my $dom (@{$all_doms}) { @@ -1079,15 +1098,13 @@ sub domains_row { $dom_select .= ''; } } + $dom_select .= ''; $r->print(''.&actionbox($status,$num,$scope).''.$dom_select. ''.&dateboxes($num,$start,$end).''); - $r->print(&Apache::loncommon::end_data_table_row()); - $r->print(&Apache::loncommon::start_data_table_row()); } sub users_row { my ($r,$status,$item,$access_controls,$now,$then) = @_; - $r->print(&Apache::loncommon::start_data_table_row()); my ($num,$scope,$end,$start) = &set_identifiers($status,$item,$now,$then, 'users'); my $curr_user_list; @@ -1096,7 +1113,6 @@ sub users_row { $curr_user_list = &sort_users($content->{'users'}); } $r->print(''.&actionbox($status,$num,$scope).''.&mt("Format for users' username:domain information:").'
sparty:msu,illini:uiuc ... etc.
'.&dateboxes($num,$start,$end).''); - $r->print(&Apache::loncommon::end_data_table_row()); } sub additional_item { @@ -1107,17 +1123,17 @@ sub additional_item { sub actionbox { my ($status,$num,$scope) = @_; - my $output = ''. + '" />'.&mt('Delete').'
'. '
'; + $output .= ''; return $output; } @@ -1132,10 +1148,10 @@ sub dateboxes { undef,undef,1); my $enddate = &Apache::lonhtmlcommon::date_setter('portform', 'enddate_'.$num,$end,undef,undef,undef,1,undef, - undef,undef,1). '  '; + ''; my $output = &mt('Start: ').$startdate.'
'.&mt('End: ').$enddate; return $output; @@ -1278,7 +1294,7 @@ sub select_files { $java_files.=','; } my $javascript =(< +