--- loncom/xml/londefdef.pm 2007/06/05 22:37:58 1.366
+++ loncom/xml/londefdef.pm 2007/06/26 01:36:48 1.371
@@ -1,7 +1,7 @@
# The LearningOnline Network with CAPA
# Tags Default Definition Module
#
-# $Id: londefdef.pm,v 1.366 2007/06/05 22:37:58 albertel Exp $
+# $Id: londefdef.pm,v 1.371 2007/06/26 01:36:48 albertel Exp $
#
#
# Copyright Michigan State University Board of Trustees
@@ -481,13 +481,21 @@ sub start_accessrule {
('realm',$parstack,$safeeval,undef,1);
my $role=&Apache::lonxml::get_param
('role',$parstack,$safeeval,undef,1);
- $realm=~s/\s+//g;
- $realm=~s/\//\_/g;
- $realm=~s/^\_//;
- $realm=~s/\W/\;/g;
- $role=~s/\s+//g;
- $role=~s/\//\_/g;
- $role=~s/\W/\;/g;
+ my ($dom,$crs,$sec)=split(/\_/,$realm);
+ $dom = &LONCAPA::clean_domain($dom);
+ my $type=&Apache::lonxml::get_param
+ ('type',$parstack,$safeeval,undef,1);
+ if ($type eq 'user') {
+ $crs = &LONCAPA::clean_username($crs);
+ } else {
+ $crs = &LONCAPA::clean_courseid($crs);
+ }
+ $sec =~s/\W//;
+ $realm = $dom;
+ if ($crs =~ /\S/) { $realm .= '_'.$crs; }
+ if ($sec =~ /\S/) { $realm .= '_'.$sec; }
+ $role=~s/\W//g;
+
if ($target eq 'web') {
my $args='';
if ( $#$parstack > -1 ) { $args=$$parstack[$#$parstack]; }
@@ -498,7 +506,7 @@ sub start_accessrule {
}
}
if ($target eq 'meta') {
- $currentstring=''.$eff.':'.$realm.':'.$role.'';
+ $currentstring=''.$eff.':'.$realm.':'.$role.':'.$type.'';
}
return $currentstring;
}
@@ -2154,11 +2162,11 @@ sub end_table {
my @fwidth=@{$Apache::londefdef::table[-1]{'TeXlen'}[0]};#final width array
my @adjust=();
#step 1. adjustment by maximum value
- my $space_neeeded=0;
+ my $space_needed=0;
for (my $jn=0;$jn<=$#max_len;$jn++) {
- $space_neeeded=$space_neeeded+$max_len[$jn];
+ $space_needed=$space_needed+$max_len[$jn];
}
- if ($space_neeeded<=$available_space) {
+ if ($space_needed<=$available_space) {
for (my $jn=0;$jn<=$#max_len;$jn++) {
if ($fwidth[$jn]==0) {
@@ -2167,11 +2175,11 @@ sub end_table {
}
} else {
#step 2. adjustment by minimum value (estimation)
- $space_neeeded=0;
+ $space_needed=0;
for (my $jn=0;$jn<=$#min_len;$jn++) {
- $space_neeeded+=$min_len[$jn];
+ $space_needed+=$min_len[$jn];
}
- if ($space_neeeded>$available_space) {
+ if ($space_needed>$available_space) {
$WARNING=' \textbf{NOT ENOUGH SPACE FOR TABLE} ';
for (my $jn=0;$jn<=$#max_len;$jn++) {
if ($fwidth[$jn]==0) {
@@ -2188,7 +2196,7 @@ sub end_table {
}
}
if ($how_many_to_scale>0) {
- my $space_to_adjust=($space_neeeded-$available_space)/$how_many_to_scale;
+ my $space_to_adjust=($space_needed-$available_space)/$how_many_to_scale;
foreach my $jn (@to_scale) {
for (my $in=0;$in<=$Apache::londefdef::table[-1]{'row_number'};$in++) {
$Apache::londefdef::table[-1]{'content'}[$in][$jn]=~m/width\s*=\s*(\d+\.?\d*\s*(mm|cm|in|pc|pt)*)/;
@@ -2210,7 +2218,7 @@ sub end_table {
}
} else {
#step 3. adjustment over minimal + corrections
- my $enlarge_coef=$available_space/$space_neeeded;
+ my $enlarge_coef=$available_space/$space_needed;
my $acsessive=0;
for (my $jn=0;$jn<=$#min_len;$jn++) {
$adjust[$jn]=$min_len[$jn]*$enlarge_coef;
@@ -2250,6 +2258,9 @@ sub end_table {
for (my $i=0;$i<=$#fwidth;$i++) {
$current+=$fwidth[$i];
}
+ if ($current == 0) {
+ $current = $Apache::londefdef::table[-1]{'width'};
+ }
my $coef=$Apache::londefdef::table[-1]{'width'}/$current;
for (my $i=0;$i<=$#fwidth;$i++) {
$fwidth[$i]*=$coef;
@@ -3001,9 +3012,10 @@ sub start_img {
# And here's where the semi-quote breaks down: allow the user
# to edit the beast as well by rendering the problem for edit:
} elsif ($target eq 'edit') {
+ my $only = join(',',&Apache::loncommon::filecategorytypes('Pictures'));
$currentstring .=&Apache::edit::tag_start($target,$token);
$currentstring .=&Apache::edit::text_arg('Image Url:','src',$token,70).
- &Apache::edit::browse('src',undef,'alt').' '.
+ &Apache::edit::browse('src',undef,'alt',$only).' '.
&Apache::edit::search('src',undef,'alt').'
';
$currentstring .=&Apache::edit::text_arg('Description:','alt',$token,70).'
';
$currentstring .=&Apache::edit::text_arg('width (pixel):','width',$token,5);