[LON-CAPA-cvs] cvs: loncom /interface loncoursegroups.pm
bisitz
lon-capa-cvs-allow@mail.lon-capa.org
Tue, 21 Oct 2008 14:29:39 -0000
This is a MIME encoded message
--bisitz1224599379
Content-Type: text/plain
bisitz Tue Oct 21 10:29:39 2008 EDT
Modified files:
/loncom/interface loncoursegroups.pm
Log:
Optimized localization and usage of standard styles (part 1):
- Optimized &mt() calls, e.g. don't include HTML Tags, use parameters, optimized usage of group and course type variables, etc.
- Added LON-CAPA standard success, warning and error styles to success, warning and error messages
Note: so far untested (restart of web server without problems)
[-> 3466]
--bisitz1224599379
Content-Type: text/plain
Content-Disposition: attachment; filename="bisitz-20081021102939.txt"
Index: loncom/interface/loncoursegroups.pm
diff -u loncom/interface/loncoursegroups.pm:1.78 loncom/interface/loncoursegroups.pm:1.79
--- loncom/interface/loncoursegroups.pm:1.78 Sun Aug 24 08:54:55 2008
+++ loncom/interface/loncoursegroups.pm Tue Oct 21 10:29:39 2008
@@ -1,6 +1,6 @@
# The LearningOnline Network with CAPA
#
-# $Id: loncoursegroups.pm,v 1.78 2008/08/24 12:54:55 raeburn Exp $
+# $Id: loncoursegroups.pm,v 1.79 2008/10/21 14:29:39 bisitz Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -111,8 +111,10 @@
$crstype);
}
} else {
- $r->print(&mt('You do not have [_1] administration '.
- 'privileges in this [_2]',$gpterm,lc($crstype)));
+ $r->print('<div class="LC_warning">'
+ .&mt('You do not have '.$gpterm.' administration '
+ .'privileges in this '.lc($crstype).'.')
+ .'</div>');
}
} else {
&print_main_menu($r,$cdom,$cnum,\%functions,\%idx,$view_permission,
@@ -346,7 +348,10 @@
'<td>'.$functionality.'</td>'.
'<td align="right">'.$quota.'</td>'.
'<td align="right">'.$totalmembers.'</td>'.
- '<td align="right"><nobr>'.&mt('Files: ').$totalfiles.'</nobr><br /><nobr>'.&mt('Folders: ').$totaldirs.'</nobr></td>'.
+ '<td align="right">'.
+ '<div class="LC_nobreak">'.&mt('Files: [_1]',$totalfiles).'</div>'.
+ '<div class="LC_nobreak">'.&mt('Folders: [_1]',$totaldirs).'</div>'.
+ '</td>'.
'<td align="right">'.$boards.'</td>'.
'<td align="right">'.$diskuse.'</td>'.
&Apache::loncommon::end_data_table_row());
@@ -390,9 +395,7 @@
}
}
} else {
- $r->print(&mt('You are not currently a member of any '.
- 'active [_1]s in this [_2]',$gpterm,
- lc($crstype)));
+ $r->print(&mt('You are not currently a member of any active '.$gpterm.'s in this '.lc($crstype).'.'));
}
}
return;
@@ -1134,8 +1137,8 @@
sub verify_delete {
my ($r,$groupname,$formname,$action,$page,$states,$stored) = @_;
$r->print(&Apache::lonhtmlcommon::echo_form_input([]));
- $r->print(&mt("You have requested deletion of the following group: ").'<i>'.
- $stored->{'description'}.'</i>'.
+ $r->print(&mt('You have requested deletion of the group [_1].'
+ ,'<i>'.$stored->{'description'}.'</i>').
'<br /><br />'.&mt('When a group is deleted the following occurs:').'<ul>'.
'<li>'.&mt('All group membership is terminated.').'</li>'.
'<li>'.&mt('The group ceases to be available either for viewing or for modification of group settings and membership.').'</li>'.
@@ -1191,7 +1194,10 @@
\%usersettings);
}
if ($num_fail > 0) {
- $r->print(&mt('Group deletion failed because deletion of [_1] out of [_2] members failed.',$num_fail,$num_users));
+ $r->print('<div class="LC_error">'
+ .&mt('Group deletion failed because deletion of [_1] out of [_2] members failed.'
+ ,$num_fail,$num_users)
+ .'</div>');
} else {
my ($result,$message) =
@@ -1200,12 +1206,19 @@
if ($result eq 'ok') {
my $outcome = &modify_folders($cdom,$cnum,$groupname);
if ($outcome eq '') {
- $r->print(&mt('Group successfully deleted.'));
+ $r->print('<div class="LC_success">'
+ .&mt('Group successfully deleted.')
+ .'</div>');
} else {
- $r->print(&mt("Although the group was deleted, an error ([_1]) occurred when removing the group's folder from the 'Course Groups' folder.",$outcome));
+ $r->print('<div class="LC_error">'
+ .&mt("Although the group was deleted, an error occurred when removing"
+ ." the group's folder from the 'Course Groups' folder: [_1]",$outcome)
+ .'</div>');
}
} else {
- $r->print(&mt('Group deletion failed.'));
+ $r->print('<div class="LC_error">'
+ .&mt('Group deletion failed.')
+ .'</div>');
}
}
return;
@@ -1216,13 +1229,15 @@
my $outcome;
my $crspath = '/uploaded/'.$cdom.'/'.$cnum.'/';
my $allgrpsmap = $crspath.'group_allfolders.sequence';
- my $foldertitle = &mt('Course Folder -').$description;
+ my $foldertitle = &mt('Course Folder -[_1]',$description);
my $mapurl = $crspath.'group_folder_'.
$groupname.'.sequence';
my ($errtext,$fatal)=&LONCAPA::map::mapread($allgrpsmap);
if ($fatal) {
- $outcome=&mt('Error reading contents of parent folder to group').
- " ($allgrpsmap): $errtext".'<br />';
+ $outcome='<div class="LC_error">'
+ .&mt('An error occurred when reading contents of parent folder to group:')
+ ."<br />($allgrpsmap): $errtext"
+ .'</div>';
} else {
my $idx=&LONCAPA::map::getresidx($mapurl);
$LONCAPA::map::resources[$idx] = $foldertitle.':'.$mapurl.
@@ -1230,8 +1245,10 @@
$LONCAPA::map::order[1+$#LONCAPA::map::order]=$idx;
my ($outtext,$errtext) = &LONCAPA::map::storemap($allgrpsmap,1);
if ($errtext) {
- $outcome = &mt('Error saving updated parent folder to group').
- "- $allgrpsmap - $errtext".'<br />';
+ $outcome='<div class="LC_error">'
+ .&mt('An error occurred when saving updated parent folder to group:'
+ ,"<br />$allgrpsmap - $errtext")
+ .'</div>';
} else {
my ($furl,$ferr) =
&Apache::lonuserstate::readmap($cdom.'/'.$cnum);
@@ -1256,8 +1273,10 @@
$map = '/'.$map;
my ($errtext,$fatal) = &LONCAPA::map::mapread($map);
if ($fatal) {
- $outcome=&mt('Error reading contents of parent folder to group').
- " ($map): $errtext".'<br />';
+ $outcome='<div class="LC_error">'
+ .&mt('An error occurred when reading contents of parent folder to group:')
+ ."<br />($map): $errtext"
+ .'</div>';
} else {
my $idx = 0;
my $grpidx;
@@ -1280,7 +1299,10 @@
$#LONCAPA::map::order--;
my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1);
if ($errtext) {
- $outcome = &mt('Error saving updated parent folder to group'). "- $map - $errtext".'<br />';
+ $outcome='<div class="LC_error">'
+ .&mt('An error occurred when saving updated parent folder to group:')
+ ."<br />$map - $errtext"
+ .'</div>';
} else {
my ($furl,$ferr) =
&Apache::lonuserstate::readmap($cdom.'/'.$cnum);
@@ -1294,8 +1316,8 @@
sub verify_reenable {
my ($r,$groupname,$formname,$action,$page,$states,$stored) = @_;
$r->print(&Apache::lonhtmlcommon::echo_form_input([]));
- $r->print(&mt("You have requested enabling the following previously deleted group: ").'<i>'.
- $stored->{'description'}.'</i>'.
+ $r->print(&mt('You have requested enabling the previously deleted group [_1].'
+ ,'<i>'.$stored->{'description'}.'</i>').
'<br /><br />'.&mt('When a deleted group is re-enabled the following occurs:').'<ul>'.
'<li>'.&mt('Group settings and membership at the time the group was deleted are reinstated.').'</li>'.
'<li>'.&mt('A group folder is added to the "Course Groups" folder which contains folders for all groups in the course.').'</li></ul>');
@@ -1316,7 +1338,7 @@
&Apache::longroup::coursegroups($cdom,$cnum,$groupname,
'deleted_groups');
if (keys(%groups) == 0) {
- $r->print(&mt('The group ([_1]) was not re-enabled, because it is not a deleted group.<br />Perhaps it has already been re-enabled?',$groupname));
+ $r->print(&mt('The group [_1] was not re-enabled, because it is not a deleted group.[_2]Perhaps it has already been re-enabled?','<i>'.$groupname.'</i>'),'<br />');
return;
}
my %groupinfo =
@@ -1371,22 +1393,34 @@
&Apache::lonnet::modify_coursegroup_membership($cdom,$cnum,
\%usersettings);
if ($roster_result eq 'ok') {
- $r->print(&mt('Membership reinstated for [_1] users, each with start and end dates for group access set to defaults: [_2] and [_3]',$num_ok,$showstart,$showend).'<br />');
+ $r->print('<div class="LC_success">'
+ .&mt('Membership reinstated for [quant,_1,user], each with start and end dates for group access set to defaults: [_2] and [_3]',$num_ok,$showstart,$showend)
+ .'</div>');
}
} else {
- $r->print(&mt('A problem occurred when trying to reinstate [_1] of the [_2] members of the pre-existing group.',$num_fail,$num_users).'<br />');
+ $r->print('<div class="LC_error">'
+ .&mt('A problem occurred when trying to reinstate [_1] of the [_2] members of the pre-existing group.',$num_fail,$num_users)
+ .'</div>');
}
} else {
- $r->print(&mt('There were no group members to reinstate, as none were removed when the group was deleted.').'<br />');
+ $r->print('<div class="LC_info">'
+ .&mt('There were no group members to reinstate, as none were removed when the group was deleted.')
+ .'</div>');
}
my $outcome = &reenable_folder($cdom,$cnum,$groupname,$description);
if ($outcome eq '') {
- $r->print(&mt('Group successfully re-enabled.'));
- } else {
- $r->print(&mt("Although the group was re-enabled, an error ([_1]) occurred when adding the group's folder to the 'Course Groups' folder.",$outcome));
+ $r->print('<div class="LC_success">'
+ .&mt('Group successfully re-enabled.')
+ .'</div>');
+ } else {
+ $r->print('<div class="LC_error">'
+ .&mt("Although the group was re-enabled, an error occurred when adding the group's folder to the 'Course Groups' folder: [_1]",$outcome)
+ .'</div>');
}
} else {
- $r->print(&mt('Re-enabling group failed'));
+ $r->print('<div class="LC_error">'
+ .&mt('Re-enabling group failed.')
+ .'</div>');
}
return;
}
@@ -1643,23 +1677,25 @@
<tr>
<td class="LC_description">'.&mt('Disk quota: ').'</td><td colspan="10">');
if ($action eq 'create') {
- $r->print(&mt('If you enable the file repository for the [_1], allocate a disk quota.',$gpterm));
+ $r->print(&mt('If you enable the file repository for the '.$gpterm.', allocate a disk quota.'));
} else {
$r->print(&mt('Quota allocated to file repository:'));
}
- $r->print(' <input type="text" name="quota" size="4" />Mb');
+ $r->print(' '.&mt('[_1] Mb','<input type="text" name="quota" size="4" />'));
if ($action eq 'create') {
- $r->print('<br />'.
- &mt('A total of [_1] Mb can be divided amongst all [_2]s in the '.
- '[_3], and [_4] Mb are currently unallocated.',$crsquota,
- $gpterm,lc($crstype),sprintf("%.2f",$freespace)));
+ $r->print('<br />'
+ .&mt('A total of [_1] Mb can be divided amongst all '.$gpterm.'s in the '
+ .lc($crstype).', and [_2] Mb are currently unallocated.'
+ ,$crsquota,sprintf("%.2f",$freespace))
+ );
} else {
$r->print(' ('.&mt('The quota is currently [_1] Mb',
$$stored{'quota'}).').');
- $r->print('<br />'.&mt('The quota can be increased to [_1] Mb, '.
- 'by adding all unallocated space for [_2]s in the [_3].',
- sprintf("%.2f",$maxposs),$gpterm,lc($crstype)));
+ $r->print('<br />'
+ .&mt('The quota can be increased to [_1] Mb, '
+ .'by adding all unallocated space for '.$gpterm.'s in the '.lc($crstype).'.'
+ ,sprintf("%.2f",$maxposs)));
}
$r->print('
</td>
@@ -1933,7 +1969,7 @@
<td>
');
if (@{$available} > 0) {
- $r->print(&mt('<b>Available for assignment to members:</b>').
+ $r->print('<b>'.&mt('Available for assignment to members:').'</b>'.
'<table class="LC_group_priv"><tr>');
my $rowcell = int(@{$available}/2) + @{$available}%2;
for (my $i=0; $i<@{$available}; $i++) {
@@ -1951,7 +1987,7 @@
$r->print('</tr></table><br />');
}
if (@{$unavailable} > 0) {
- $r->print(&mt('<b>Unavailable for assignment:</b>').
+ $r->print('<b>'.&mt('<b>Unavailable for assignment:').'</b>'.
'<table class="LC_group_priv"><tr>');
my $rowcell = int(@{$unavailable}/2) + @{$unavailable}%2;
for (my $j=0; $j<@{$unavailable}; $j++) {
@@ -1968,10 +2004,11 @@
}
$r->print('</tr></table>');
}
+ my $quota_text=&mt('[_1] Mb',$quota);
$r->print(<<"END");
</td>
<td valign="top"><b>$lt{'difn'}</b> $granularity</td>
- <td valign="top">$quota Mb</td>
+ <td valign="top">$quota_text</td>
<td valign="top"><b>$lt{'stda'}</b> $showstart<br />
<b>$lt{'enda'}</b> $showend
</td>
@@ -1994,9 +2031,9 @@
'nnew' => "There are no users to add as new members, as all users".
" matching the specified type(s), role(s), and ".
"section(s) are already affiliated with this group.",
- 'yoma' => 'You may need to use the '."'".'modify existing, past or '.
- 'future members'."'".' page if you need to re-enable '.
- 'or activate access for previous or future members.',
+ 'yoma' => "You may need to use the 'modify existing, past or ".
+ "future members' page if you need to re-enable ".
+ "or activate access for previous or future members.",
);
my %members;
my $totalusers = 0;
@@ -2273,7 +2310,8 @@
if ($fixed ne '') {
$fixed .= '</td><td class="LC_groups_fixed">';
}
- $fixed .= '<input type="hidden" name="defpriv" value="'.$priv.'" /><nobr>'.$$toolprivs{$tool}{$priv}.' ';
+ $fixed .= '<input type="hidden" name="defpriv" value="'.$priv.'" />'
+ .'<span class="LC_nobreak">'.$$toolprivs{$tool}{$priv}.' ';
if ($action eq 'modify') {
if (grep(/^$tool$/,@{$available})) {
$fixed .= '<small>'.&mt('(on)').'<small> ';
@@ -2281,18 +2319,18 @@
$fixed .= '<small>'.&mt('(off)').'<small> ';
}
}
- $fixed .= '</nobr>';
+ $fixed .= '</span>';
} else {
$privcount++;
if ($privcount == 3) {
$dynamic .= '</tr>
<tr>'."\n";
}
- $dynamic .= '<td><nobr><label><input type="checkbox" name="defpriv" value="'.$priv.'" />'.$$toolprivs{$tool}{$priv}.'</label></nobr></td>'."\n";
+ $dynamic .= '<td><span class="LC_nobreak"><label><input type="checkbox" name="defpriv" value="'.$priv.'" />'.$$toolprivs{$tool}{$priv}.'</label></span></td>'."\n";
}
}
if ($privcount == 0) {
- $dynamic .= '<td>None</td>'."\n";
+ $dynamic .= '<td>'.&mt('None').'</td>'."\n";
}
if ($privcount < 3) {
$dynamic .= '<td> </td>'."\n";
@@ -3082,11 +3120,19 @@
}
if ($quota !~ /^\d*\.?\d*$/) {
$quota = 0;
- $r->print(&mt('The value you entered for the quota for the file repository in this [_1] contained invalid characters, so it has been set to 0 Mb. You can change this by modifying the [_1] settings.<br />',$gpterm));
+ $r->print('<div class="LC_warning">'
+ .&mt('The value you entered for the quota for the file repository in this '.$gpterm
+ .' contained invalid characters, so it has been set to 0 Mb. You can change this by'
+ .' modifying the '.$gpterm.' settings.')
+ .'</div>');
}
if ($quota > $maxposs) {
$quota = $maxposs;
- $r->print(&mt('The value you entered for the quota for the file repository in this [_1] exceeded the maximum possible value, so it has been set to [_2] Mb (the maximum possible value).<br />',$gpterm,sprintf("%.2f",$maxposs)));
+ $r->print('<div class="LC_warning">'
+ .&mt('The value you entered for the quota for the file repository in this '.$gpterm
+ .' exceeded the maximum possible value, so it has been set to [_1] Mb '
+ .'(the maximum possible value).',sprintf("%.2f",$maxposs))
+ .'</div>');
}
my %groupinfo = (
description => $esc_description,
@@ -3151,10 +3197,17 @@
my $result = &add_group_folder($cdom,$cnum,$now,$groupname,$action,
$description,$tools,\%groupinfo,
$gpterm,$ucgpterm,$crstype);
- if ($result ne 'ok') {
- $r->print(&mt('A problem occurred when creating folders for the new [_1].<br />[_2]<br />',$gpterm,$result));
+ if ($result eq 'ok') {
+ $r->print('<div class="LC_success">'
+ .&mt($ucgpterm.' [_1] was created.','<i>'.$groupname.'</i>')
+ .'</div>');
+ } else {
+ $r->print('<div class="LC_error">'
+ .&mt('A problem occurred when creating folders for the new '.$gpterm.' [_1]:'
+ ,'<i>'.$groupname.'</i>')
+ .'<br />'.$result
+ .'</div>');
}
- $r->print(&mt('[_1] [_2] was created.<br />',$ucgpterm,$groupname));
} elsif ($action eq 'modify') {
my (@oldtools,@newtools);
if (ref($$stored{'tool'}) eq 'ARRAY') {
@@ -3184,11 +3237,15 @@
my $parm_result = &parm_setter($navmap,$cdom,$boardsmap,
$groupname);
if ($parm_result) {
- $r->print(&mt('Error while setting parameters '.
- 'for Discussion Boards folder: '.
- '[_1]<br />.',$parm_result));
+ $r->print('<div class="LC_error">'
+ .&mt('An error occurred while setting parameters '
+ .'for Discussion Boards folder: '
+ .'[_1]',$parm_result)
+ .'</div>');
} else {
- $r->print(&mt('Discussion Boards Folder created.<br />'));
+ $r->print('<div class="LC_success">'
+ .&mt('Discussion Boards Folder created.')
+ .'</div>');
}
} else {
$r->print($outcome);
@@ -3196,7 +3253,9 @@
undef($navmap);
}
}
- $r->print(&mt('[_1] [_2] was updated.<br />',$ucgpterm,$groupname));
+ $r->print('<div class="LC_success">'
+ .&mt($ucgpterm.' [_1] was updated.','<i>'.$groupname.'</i>')
+ .'</div>');
}
} else {
my %actiontype = (
@@ -3206,8 +3265,10 @@
&Apache::lonnet::logthis("Failed to store $gpterm $groupname ".
'in '.lc($crstype).': '.$cnum.
' in domain: '.$cdom);
- $r->print(&mt('An error occurred when [_1] the [_2]. '.
- 'Please try again.',$actiontype{$action},$gpterm));
+ $r->print('<div class="LC_error">'
+ .&mt('An error occurred when [_1] the '.$gpterm.'. '
+ .'Please try again.',$actiontype{$action})
+ .'</div>');
}
return $result;
}
@@ -3400,7 +3461,9 @@
}
if ($num_fail) {
foreach my $type (sort(keys(%failed))) {
- $r->print(&mt('The following users could not be [_1], because an error occurred:<br />',$type));
+ $r->print('<div class="LC_error">'
+ .&mt("The following users could not be $type, because an error occurred:")
+ .'</div>');
foreach my $user (@{$failed{$type}}) {
$r->print($$userdata{$user}[$$idx{fullname}].' - '.$user.'<br />');
}
--bisitz1224599379--