--- loncom/interface/lonextresedit.pm 2016/11/22 00:43:12 1.11
+++ loncom/interface/lonextresedit.pm 2017/11/30 01:52:14 1.20
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: lonextresedit.pm,v 1.11 2016/11/22 00:43:12 raeburn Exp $
+# $Id: lonextresedit.pm,v 1.20 2017/11/30 01:52:14 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;
@@ -260,16 +260,22 @@ sub update_exttool {
my ($marker,$cdom,$cnum,$args) = @_;
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
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'});
+ ($newhash{'target'},$newhash{'width'},$newhash{'height'},$newhash{'linktext'},$newhash{'explanation'},
+ $newhash{'crslabel'},$newhash{'crstitle'},$newhash{'crsappend'}) = split(/:/,$args);
+ foreach my $item ('linktext','explanation','crslabel','crstitle','crsappend') {
+ $newhash{$item} = &unescape($newhash{$item});
+ }
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
- foreach my $item ('target','width','height','crslabel','crstitle') {
+ foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle','crsappend') {
$newhash{$item} =~ s/^\s+//;
$newhash{$item} =~ s/\s+$//;
- if (($item eq 'width') || ($item eq 'height')) {
+ if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {
if ($newhash{'target'} eq 'iframe') {
$newhash{$item} = '';
+ } elsif ($newhash{'target'} eq 'tab') {
+ if (($item eq 'width') || ($item eq 'height')) {
+ $newhash{$item} = '';
+ }
}
}
if ($toolhash{$item} ne $newhash{$item}) {
@@ -277,7 +283,10 @@ sub update_exttool {
unless (($item eq 'target') ||
((($item eq 'width') || ($item eq 'height')) &&
(($newhash{'target'} eq 'window') ||
- (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window'))))) {
+ (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window')))) ||
+ ((($item eq 'linktext') || ($item eq 'explanation')) &&
+ ((($newhash{'target'} =~ /^(window|tab)$/)) ||
+ (($newhash{'target'} eq '') && ($toolhash{'target'} =~ /^(window|tab)$/))))) {
delete($toolhash{$item});
push(@deleted,$item);
$changed = 1;
@@ -325,17 +334,25 @@ sub extedit_form {
$tabid = 'ee';
}
my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle,
- $labelstyle,$titlestyle,$legend,$urlelem,$toolelem,%toolattr);
+ $windivstyle,$linktextstyle,$explanationstyle,$labelstyle,$titlestyle,
+ $appendstyle,$legend,$urlelem,$toolelem,%toolattr);
$formname = 'new'.$type;
$toggle = $type;
$fieldsetid = 'upload'.$type.'form';
$urlid = $type.'url';
map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight',
- 'crstitlediv','crslabeldiv','crstitle','crslabel');
+ 'crstitlediv','crslabeldiv','crsappenddiv',
+ 'crstitle','crslabel','crsappend','windiv',
+ 'linktextdiv','explanationdiv','linktext',
+ 'explanation','providerurl');
$dispdivstyle = 'display:none';
$dimendivstyle = 'display:none';
+ $windivstyle = 'display:none';
+ $linktextstyle = 'display:none';
+ $explanationstyle = 'display:none';
$labelstyle = 'display:none';
$titlestyle = 'display:none';
+ $appendstyle = 'display:none';
if ($supplementalflag) {
$formname = 'newsupp'.$type;
$toggle = 'supp'.$type;
@@ -344,13 +361,19 @@ sub extedit_form {
map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr));
}
my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel,
- $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,%chkstate);
+ $crsappend,$fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,
+ $linktext,$explanation,$providerurl,%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 {
@@ -377,7 +400,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'};
@@ -399,12 +422,12 @@ 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 .= '
';
}
@@ -415,7 +438,7 @@ sub extedit_form {
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'}) {
@@ -428,15 +451,26 @@ sub extedit_form {
if ($icon) {
$image = '';
}
+ if ($ltitools->{$toolhash{'id'}}->{'url'} =~ m{://}) {
+ (my $prot,my $host,$providerurl) = ($ltitools->{$toolhash{'id'}}->{'url'} =~ m{^([^/]+)://([^/]+)(|/.+)$});
+ } else {
+ $providerurl = $ltitools->{$toolhash{'id'}}->{'url'};
+ }
$tooltarget = $toolhash{'target'};
if ($tooltarget eq 'window') {
$dimendivstyle = 'display:block';
+ $windivstyle = 'display:block';
$chkstate{'window'} = 'checked="checked" ';
+ } elsif ($tooltarget eq 'tab') {
+ $windivstyle = 'display:block';
+ $chkstate{'tab'} = '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'};
@@ -446,9 +480,19 @@ sub extedit_form {
$crslabel = $toolhash{'crslabel'};
$labelstyle = 'display:inline';
}
+ if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'append'}) {
+ $crsappend = $toolhash{'crsappend'};
+ $appendstyle = '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.'
';
}
@@ -482,25 +526,44 @@ sub extedit_form {
$toolelem .= '
';
$crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'};
$crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'};
+ $crsappend = '';
}
$toolelem .= '