--- loncom/interface/lonextresedit.pm 2016/01/26 14:30:25 1.9
+++ loncom/interface/lonextresedit.pm 2016/11/22 00:43:12 1.11
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: lonextresedit.pm,v 1.9 2016/01/26 14:30:25 raeburn Exp $
+# $Id: lonextresedit.pm,v 1.11 2016/11/22 00:43:12 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -259,38 +259,50 @@ sub process_changes {
sub update_exttool {
my ($marker,$cdom,$cnum,$args) = @_;
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
- my (%newhash,$changed,$errormsg);
- ($newhash{'target'},$newhash{'width'},$newhash{'height'}) = split(/:/,$args);
+ my (%newhash,$changed,@deleted,$errormsg);
+ ($newhash{'target'},$newhash{'width'},$newhash{'height'},$newhash{'crslabel'},$newhash{'crstitle'}) = split(/:/,$args);
+ $newhash{'crslabel'} = &unescape($newhash{'crslabel'});
+ $newhash{'crstitle'} = &unescape($newhash{'crstitle'});
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
- foreach my $item ('target','width','height') {
+ foreach my $item ('target','width','height','crslabel','crstitle') {
$newhash{$item} =~ s/^\s+//;
$newhash{$item} =~ s/\s+$//;
- unless ($item eq 'target') {
+ if (($item eq 'width') || ($item eq 'height')) {
if ($newhash{'target'} eq 'iframe') {
$newhash{$item} = '';
}
}
if ($toolhash{$item} ne $newhash{$item}) {
if ($newhash{$item} eq '') {
- delete($toolhash{$item});
+ unless (($item eq 'target') ||
+ ((($item eq 'width') || ($item eq 'height')) &&
+ (($newhash{'target'} eq 'window') ||
+ (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window'))))) {
+ delete($toolhash{$item});
+ push(@deleted,$item);
+ $changed = 1;
+ }
} else {
$toolhash{$item} = $newhash{$item};
+ $changed = 1;
}
- $changed = 1;
}
}
if ($changed) {
my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$cdom,$cnum);
unless ($putres eq 'ok') {
- $errormsg = &mt('Failed to save updated settings.').' '.&mt('Error: [_1].',$putres);
+ $errormsg = &mt('Failed to save updated settings.').' '.&mt('Error: [_1].',$putres);
}
}
+ if (@deleted) {
+ &Apache::lonnet::del('exttool_'.$marker,\@deleted,$cdom,$cnum);
+ }
return ($changed,$errormsg);
}
sub extedit_form {
my ($supplementalflag,$residx,$orig_url,$orig_title,$pathitem,$helpitem,$caller,
- $symb,$type,$cdom,$cnum,$ltitools) = @_;
+ $symb,$type,$cdom,$cnum,$ltitools,$disabled) = @_;
if ($type ne 'tool') {
$type = 'ext';
}
@@ -313,14 +325,17 @@ sub extedit_form {
$tabid = 'ee';
}
my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle,
- $legend,$urlelem,$toolelem,%toolattr);
+ $labelstyle,$titlestyle,$legend,$urlelem,$toolelem,%toolattr);
$formname = 'new'.$type;
$toggle = $type;
$fieldsetid = 'upload'.$type.'form';
$urlid = $type.'url';
- map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight');
+ map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight',
+ 'crstitlediv','crslabeldiv','crstitle','crslabel');
$dispdivstyle = 'display:none';
$dimendivstyle = 'display:none';
+ $labelstyle = 'display:none';
+ $titlestyle = 'display:none';
if ($supplementalflag) {
$formname = 'newsupp'.$type;
$toggle = 'supp'.$type;
@@ -328,7 +343,7 @@ sub extedit_form {
$urlid = 'supp'.$type.'url';
map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr));
}
- my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,
+ my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel,
$fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,%chkstate);
$fieldsetstyle = 'display: none;';
$action = '/adm/coursedocs';
@@ -384,7 +399,7 @@ sub extedit_form {
$orig_url = 'http://';
$orig_title = $lt{'ex'};
$extsrc = $lt{'ul'}.':
';
- $preview = '';
+ $preview = '';
$save = $lt{'al'};
} else {
$orig_title = $lt{'et'};
@@ -395,7 +410,7 @@ sub extedit_form {
}
$formid = $formname;
if ($type eq 'ext') {
- $urlelem = '';
+ $urlelem = '';
} else {
my $class = 'LC_nobreak';
if ($residx) {
@@ -404,7 +419,6 @@ sub extedit_form {
my $marker = $1;
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
if ($toolhash{'id'}) {
- $dispdivstyle = 'display:block';
if (ref($ltitools) eq 'HASH') {
if (keys(%{$ltitools})) {
if (ref($ltitools->{$toolhash{'id'}}) eq 'HASH') {
@@ -423,6 +437,19 @@ sub extedit_form {
}
$width = $toolhash{'width'};
$height = $toolhash{'height'};
+ if (ref($ltitools->{$toolhash{'id'}}->{'crsconf'}) eq 'HASH') {
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'title'}) {
+ $crstitle = $toolhash{'crstitle'};
+ $titlestyle = 'display:inline';
+ }
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'label'}) {
+ $crslabel = $toolhash{'crslabel'};
+ $labelstyle = 'display:inline';
+ }
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'target'}) {
+ $dispdivstyle = 'display:block';
+ }
+ }
$toolelem = ''.$image.' '.$tooltitle.'
';
}
}
@@ -432,7 +459,7 @@ sub extedit_form {
} else {
$toolelem = ''."\n".
'';
+ $toolelem .= '
';
+ $crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'};
+ $crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'};
}
$toolelem .= '