--- loncom/interface/lonextresedit.pm 2016/01/26 14:30:25 1.9
+++ loncom/interface/lonextresedit.pm 2017/05/08 14:20:20 1.18
@@ -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.18 2017/05/08 14:20:20 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -60,7 +60,7 @@ sub handler {
$symb,$type);
if (($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) {
$supplementalflag = 1;
- if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/exttools?$}) {
+ if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {
$type = 'tool';
}
}
@@ -79,7 +79,7 @@ sub handler {
if ($symb ne $env{'form.symb'}) {
$env{'form.symb'} = $symb;
}
- if ($url =~ m{/adm/$cdom/$cnum/\d+/exttools?$}) {
+ if ($url =~ m{/adm/$cdom/$cnum/\d+/ext\.tool$}) {
$type = 'tool';
}
}
@@ -146,7 +146,7 @@ sub process_changes {
$oldtitle = &unescape($env{'form.title'});
$container = 'sequence';
$supplementalflag = 1;
- if ($oldurl =~ m{^/adm/$cdom/$cnum/\d+/exttools?$}) {
+ if ($oldurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {
$type = 'tool';
} else {
$type = 'ext';
@@ -157,7 +157,7 @@ sub process_changes {
if ($env{'form.importdetail'}) {
($newtitle,$newurl,$newidx) =
map {&unescape($_)} split(/\=/,$env{'form.importdetail'});
- if ($newurl =~ m{^(/adm/$cdom/$cnum/(\d+)/exttools?)\:?(.*)$}) {
+ if ($newurl =~ m{^(/adm/$cdom/$cnum/(\d+)/ext\.tool)\:?(.*)$}) {
$newurl = $1;
$marker = $2;
$args = $3;
@@ -259,38 +259,52 @@ 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{'linktext'},$newhash{'explanation'},
+ $newhash{'crslabel'},$newhash{'crstitle'}) = split(/:/,$args);
+ foreach my $item ('linktext','explanation','crslabel','crstitle') {
+ $newhash{$item} = &unescape($newhash{$item});
+ }
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
- foreach my $item ('target','width','height') {
+ foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle') {
$newhash{$item} =~ s/^\s+//;
$newhash{$item} =~ s/\s+$//;
- unless ($item eq 'target') {
+ if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {
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') || ($item eq 'linktext') || ($item eq 'explanation')) &&
+ (($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 +327,23 @@ sub extedit_form {
$tabid = 'ee';
}
my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle,
+ $windivstyle,$linktextstyle,$explanationstyle,$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',
+ 'windiv','linktextdiv','explanationdiv','linktext',
+ 'explanation');
$dispdivstyle = 'display:none';
$dimendivstyle = 'display:none';
+ $windivstyle = 'display:none';
+ $linktextstyle = 'display:none';
+ $explanationstyle = 'display:none';
+ $labelstyle = 'display:none';
+ $titlestyle = 'display:none';
if ($supplementalflag) {
$formname = 'newsupp'.$type;
$toggle = 'supp'.$type;
@@ -328,14 +351,20 @@ sub extedit_form {
$urlid = 'supp'.$type.'url';
map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr));
}
- my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,
- $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,%chkstate);
+ my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel,
+ $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,
+ $linktext,$explanation,%chkstate);
$fieldsetstyle = 'display: none;';
$action = '/adm/coursedocs';
+ my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http');
+ my $rows = 2;
+ my $cols = 20;
if ($residx) {
if ($caller eq 'direct') {
$fieldsetstyle = 'display: block;';
$action = '/adm/extresedit';
+ $rows = 10;
+ $cols = 45;
if ($type eq 'tool') {
$legend = $lt{'ee'};
} else {
@@ -362,7 +391,7 @@ sub extedit_form {
$srcclass = ' class="LC_nobreak"';
if ($type eq 'ext') {
$extsrc = ''.$lt{'ul'}.' ';
- $preview = ' '.$lt{'pr'}.'';
+ $preview = ' '.$lt{'pr'}.'';
}
$title = ''.$lt{'ti'}.' ';
$save = $lt{'sv'};
@@ -384,27 +413,26 @@ sub extedit_form {
$orig_url = 'http://';
$orig_title = $lt{'ex'};
$extsrc = $lt{'ul'}.':
';
- $preview = '';
+ $preview = '';
$save = $lt{'al'};
} else {
$orig_title = $lt{'et'};
$save = $lt{'at'};
- $orig_url = "/adm/$cdom/$cnum/new/exttool";
+ $orig_url = "/adm/$cdom/$cnum/new/ext\.tool";
}
$pathitem .= '
';
}
$formid = $formname;
if ($type eq 'ext') {
- $urlelem = '';
+ $urlelem = '';
} else {
my $class = 'LC_nobreak';
if ($residx) {
$class = 'LC_docs_ext_edit LC_nobreak';
- if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/exttools?$}) {
+ if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/ext\.tool$}) {
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') {
@@ -417,12 +445,34 @@ sub extedit_form {
$tooltarget = $toolhash{'target'};
if ($tooltarget eq 'window') {
$dimendivstyle = 'display:block';
+ $windivstyle = 'display:block';
$chkstate{'window'} = 'checked="checked" ';
} else {
$chkstate{'iframe'} = 'checked="checked" ';
}
$width = $toolhash{'width'};
$height = $toolhash{'height'};
+ $linktext = $toolhash{'linktext'};
+ $explanation = $toolhash{'explanation'};
+ 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';
+ }
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'linktext'}) {
+ $linktextstyle = 'padding:0;display:inline';
+ }
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'explanation'}) {
+ $explanationstyle = 'padding:0;display:inline';
+ }
+ }
$toolelem = ''.$image.' '.$tooltitle.'
';
}
}
@@ -432,7 +482,7 @@ sub extedit_form {
} else {
$toolelem = ''."\n".
'';
+ $toolelem .= '
';
+ $crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'};
+ $crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'};
}
$toolelem .= '