version 1.9, 2016/01/26 14:30:25
|
version 1.22.2.1, 2020/04/09 22:37:32
|
Line 60 sub handler {
|
Line 60 sub handler {
|
$symb,$type); |
$symb,$type); |
if (($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) { |
if (($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) { |
$supplementalflag = 1; |
$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'; |
$type = 'tool'; |
} |
} |
} |
} |
Line 79 sub handler {
|
Line 79 sub handler {
|
if ($symb ne $env{'form.symb'}) { |
if ($symb ne $env{'form.symb'}) { |
$env{'form.symb'} = $symb; |
$env{'form.symb'} = $symb; |
} |
} |
if ($url =~ m{/adm/$cdom/$cnum/\d+/exttools?$}) { |
if ($url =~ m{/adm/$cdom/$cnum/\d+/ext\.tool$}) { |
$type = 'tool'; |
$type = 'tool'; |
} |
} |
} |
} |
Line 98 sub handler {
|
Line 98 sub handler {
|
} |
} |
my %ltitools; |
my %ltitools; |
if ($type eq 'tool') { |
if ($type eq 'tool') { |
%ltitools = &Apache::lonnet::get_domain_ltitools($cdom); |
%ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer'); |
} |
} |
my $js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript()); |
my $js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript()); |
my $pathitem = '<input type="hidden" name="folderpath" value="'. |
my $pathitem = '<input type="hidden" name="folderpath" value="'. |
Line 146 sub process_changes {
|
Line 146 sub process_changes {
|
$oldtitle = &unescape($env{'form.title'}); |
$oldtitle = &unescape($env{'form.title'}); |
$container = 'sequence'; |
$container = 'sequence'; |
$supplementalflag = 1; |
$supplementalflag = 1; |
if ($oldurl =~ m{^/adm/$cdom/$cnum/\d+/exttools?$}) { |
if ($oldurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) { |
$type = 'tool'; |
$type = 'tool'; |
} else { |
} else { |
$type = 'ext'; |
$type = 'ext'; |
Line 157 sub process_changes {
|
Line 157 sub process_changes {
|
if ($env{'form.importdetail'}) { |
if ($env{'form.importdetail'}) { |
($newtitle,$newurl,$newidx) = |
($newtitle,$newurl,$newidx) = |
map {&unescape($_)} split(/\=/,$env{'form.importdetail'}); |
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; |
$newurl = $1; |
$marker = $2; |
$marker = $2; |
$args = $3; |
$args = $3; |
Line 258 sub process_changes {
|
Line 258 sub process_changes {
|
|
|
sub update_exttool { |
sub update_exttool { |
my ($marker,$cdom,$cnum,$args) = @_; |
my ($marker,$cdom,$cnum,$args) = @_; |
|
my (%newhash,$changed,@deleted,$errormsg); |
|
($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); |
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); |
my (%newhash,$changed,$errormsg); |
foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle','crsappend') { |
($newhash{'target'},$newhash{'width'},$newhash{'height'}) = split(/:/,$args); |
|
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); |
|
foreach my $item ('target','width','height') { |
|
$newhash{$item} =~ s/^\s+//; |
$newhash{$item} =~ s/^\s+//; |
$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') { |
if ($newhash{'target'} eq 'iframe') { |
$newhash{$item} = ''; |
$newhash{$item} = ''; |
|
} elsif ($newhash{'target'} eq 'tab') { |
|
if (($item eq 'width') || ($item eq 'height')) { |
|
$newhash{$item} = ''; |
|
} |
} |
} |
} |
} |
if ($toolhash{$item} ne $newhash{$item}) { |
if ($toolhash{$item} ne $newhash{$item}) { |
if ($newhash{$item} eq '') { |
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')))) || |
|
((($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; |
|
} |
} else { |
} else { |
$toolhash{$item} = $newhash{$item}; |
$toolhash{$item} = $newhash{$item}; |
|
$changed = 1; |
} |
} |
$changed = 1; |
|
} |
} |
} |
} |
if ($changed) { |
if ($changed) { |
my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$cdom,$cnum); |
my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$cdom,$cnum); |
unless ($putres eq 'ok') { |
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); |
return ($changed,$errormsg); |
} |
} |
|
|
sub extedit_form { |
sub extedit_form { |
my ($supplementalflag,$residx,$orig_url,$orig_title,$pathitem,$helpitem,$caller, |
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') { |
if ($type ne 'tool') { |
$type = 'ext'; |
$type = 'ext'; |
} |
} |
Line 313 sub extedit_form {
|
Line 333 sub extedit_form {
|
$tabid = 'ee'; |
$tabid = 'ee'; |
} |
} |
my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle, |
my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle, |
$legend,$urlelem,$toolelem,%toolattr); |
$windivstyle,$linktextstyle,$explanationstyle,$labelstyle,$titlestyle, |
|
$appendstyle,$legend,$urlelem,$toolelem,%toolattr); |
$formname = 'new'.$type; |
$formname = 'new'.$type; |
$toggle = $type; |
$toggle = $type; |
$fieldsetid = 'upload'.$type.'form'; |
$fieldsetid = 'upload'.$type.'form'; |
$urlid = $type.'url'; |
$urlid = $type.'url'; |
map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight'); |
map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight', |
|
'crstitlediv','crslabeldiv','crsappenddiv', |
|
'crstitle','crslabel','crsappend','windiv', |
|
'linktextdiv','explanationdiv','linktext', |
|
'explanation','providerurl'); |
$dispdivstyle = 'display:none'; |
$dispdivstyle = 'display:none'; |
$dimendivstyle = '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) { |
if ($supplementalflag) { |
$formname = 'newsupp'.$type; |
$formname = 'newsupp'.$type; |
$toggle = 'supp'.$type; |
$toggle = 'supp'.$type; |
Line 328 sub extedit_form {
|
Line 359 sub extedit_form {
|
$urlid = 'supp'.$type.'url'; |
$urlid = 'supp'.$type.'url'; |
map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr)); |
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); |
$crsappend,$fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget, |
|
$linktext,$explanation,$providerurl,%chkstate); |
$fieldsetstyle = 'display: none;'; |
$fieldsetstyle = 'display: none;'; |
$action = '/adm/coursedocs'; |
$action = '/adm/coursedocs'; |
|
my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http'); |
|
my $rows = 2; |
|
my $cols = 20; |
if ($residx) { |
if ($residx) { |
if ($caller eq 'direct') { |
if ($caller eq 'direct') { |
$fieldsetstyle = 'display: block;'; |
$fieldsetstyle = 'display: block;'; |
$action = '/adm/extresedit'; |
$action = '/adm/extresedit'; |
|
$rows = 10; |
|
$cols = 45; |
if ($type eq 'tool') { |
if ($type eq 'tool') { |
$legend = $lt{'ee'}; |
$legend = $lt{'ee'}; |
} else { |
} else { |
Line 362 sub extedit_form {
|
Line 399 sub extedit_form {
|
$srcclass = ' class="LC_nobreak"'; |
$srcclass = ' class="LC_nobreak"'; |
if ($type eq 'ext') { |
if ($type eq 'ext') { |
$extsrc = '<span class="LC_docs_ext_edit">'.$lt{'ul'}.' </span>'; |
$extsrc = '<span class="LC_docs_ext_edit">'.$lt{'ul'}.' </span>'; |
$preview = ' <a class="LC_docs_ext_edit" href="javascript:extUrlPreview('."'$urlid'".');">'.$lt{'pr'}.'</a>'; |
$preview = ' <a class="LC_docs_ext_edit" href="javascript:extUrlPreview('."'$urlid','$protocol'".');">'.$lt{'pr'}.'</a>'; |
} |
} |
$title = '<span class="LC_docs_ext_edit">'.$lt{'ti'}.' </span>'; |
$title = '<span class="LC_docs_ext_edit">'.$lt{'ti'}.' </span>'; |
$save = $lt{'sv'}; |
$save = $lt{'sv'}; |
Line 384 sub extedit_form {
|
Line 421 sub extedit_form {
|
$orig_url = 'http://'; |
$orig_url = 'http://'; |
$orig_title = $lt{'ex'}; |
$orig_title = $lt{'ex'}; |
$extsrc = $lt{'ul'}.':<br />'; |
$extsrc = $lt{'ul'}.':<br />'; |
$preview = '<input type="button" name="view" value="'.$lt{'pr'}.'" onclick="javascript:extUrlPreview('."'$urlid'".');" />'; |
$preview = '<input type="button" name="view" value="'.$lt{'pr'}.'" onclick="javascript:extUrlPreview('."'$urlid','$protocol'".');"'.$disabled.' />'; |
$save = $lt{'al'}; |
$save = $lt{'al'}; |
} else { |
} else { |
$orig_title = $lt{'et'}; |
$orig_title = $lt{'et'}; |
$save = $lt{'at'}; |
$save = $lt{'at'}; |
$orig_url = "/adm/$cdom/$cnum/new/exttool"; |
$orig_url = "/adm/$cdom/$cnum/new/ext\.tool"; |
} |
} |
$pathitem .= '<br />'; |
$pathitem .= '<br />'; |
} |
} |
$formid = $formname; |
$formid = $formname; |
if ($type eq 'ext') { |
if ($type eq 'ext') { |
$urlelem = '<input type="text" size="'.$size.'" name="exturl" id="'.$urlid.'" value="'.$orig_url.'" />'; |
$urlelem = '<input type="text" size="'.$size.'" name="exturl" id="'.$urlid.'" value="'.$orig_url.'"'.$disabled.' />'; |
} else { |
} else { |
my $class = 'LC_nobreak'; |
my $class = 'LC_nobreak'; |
if ($residx) { |
if ($residx) { |
$class = 'LC_docs_ext_edit LC_nobreak'; |
$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 $marker = $1; |
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); |
my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum); |
if ($toolhash{'id'}) { |
if ($toolhash{'id'}) { |
$dispdivstyle = 'display:block'; |
|
if (ref($ltitools) eq 'HASH') { |
if (ref($ltitools) eq 'HASH') { |
if (keys(%{$ltitools})) { |
if (keys(%{$ltitools})) { |
if (ref($ltitools->{$toolhash{'id'}}) eq 'HASH') { |
if (ref($ltitools->{$toolhash{'id'}}) eq 'HASH') { |
Line 414 sub extedit_form {
|
Line 450 sub extedit_form {
|
if ($icon) { |
if ($icon) { |
$image = '<img src="'.$icon.'" alt="'.$tooltitle.'" />'; |
$image = '<img src="'.$icon.'" alt="'.$tooltitle.'" />'; |
} |
} |
|
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'}; |
$tooltarget = $toolhash{'target'}; |
if ($tooltarget eq 'window') { |
if ($tooltarget eq 'window') { |
$dimendivstyle = 'display:block'; |
$dimendivstyle = 'display:block'; |
|
$windivstyle = 'display:block'; |
$chkstate{'window'} = 'checked="checked" '; |
$chkstate{'window'} = 'checked="checked" '; |
|
} elsif ($tooltarget eq 'tab') { |
|
$windivstyle = 'display:block'; |
|
$chkstate{'tab'} = 'checked="checked" '; |
} else { |
} else { |
$chkstate{'iframe'} = 'checked="checked" '; |
$chkstate{'iframe'} = 'checked="checked" '; |
} |
} |
$width = $toolhash{'width'}; |
$width = $toolhash{'width'}; |
$height = $toolhash{'height'}; |
$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'}->{'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 = '<span class="LC_nobreak">'.$image.' '.$tooltitle.'</span><br />'; |
$toolelem = '<span class="LC_nobreak">'.$image.' '.$tooltitle.'</span><br />'; |
} |
} |
} |
} |
Line 432 sub extedit_form {
|
Line 502 sub extedit_form {
|
} else { |
} else { |
$toolelem = '<span class="LC_docs_ext_edit">'."\n". |
$toolelem = '<span class="LC_docs_ext_edit">'."\n". |
'<select name="exttoolid" id="LC_exttoolid" onchange="javascript:updateExttool(this,'. |
'<select name="exttoolid" id="LC_exttoolid" onchange="javascript:updateExttool(this,'. |
'this.form,'."'$supplementalflag'".');">'."\n". |
'this.form,'."'$supplementalflag'".');"'.$disabled.'>'."\n". |
'<option value="" selected="selected">'.&mt('Select').'</option>'; |
'<option value="" selected="selected">'.&mt('Select').'</option>'; |
my %bynum; |
my %bynum; |
if (ref($ltitools) eq 'HASH') { |
if (ref($ltitools) eq 'HASH') { |
Line 452 sub extedit_form {
|
Line 522 sub extedit_form {
|
} |
} |
} |
} |
} |
} |
$toolelem .= '</select></span>'; |
$toolelem .= '</select></span><br />'; |
|
$crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'}; |
|
$crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'}; |
|
$crsappend = ''; |
} |
} |
$toolelem .= '<div id="'.$toolattr{'dispdiv'}.'" style="'.$dispdivstyle.'">'. |
$toolelem .= '<div id="'.$toolattr{'dispdiv'}.'" style="'.$dispdivstyle.'">'. |
'<span class="'.$class.'">'.&mt('Display target:').' '. |
'<span class="'.$class.'">'.&mt('Display target:').' '. |
'<label><input type="radio" name="exttooltarget" value="iframe" '.$chkstate{'iframe'}.'onclick="updateTooldim(this.form,'. |
'<label><input type="radio" name="exttooltarget" value="iframe" '.$chkstate{'iframe'}.'onclick="updateTooldim(this.form,'. |
"'$toolattr{dimendiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}'".');">'.&mt('iframe').'</label>'.(' 'x2). |
"'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}', |
|
'$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('iframe').'</label>'.(' 'x2). |
|
'<label><input type="radio" name="exttooltarget" value="tab" '.$chkstate{'tab'}.'onclick="updateTooldim(this.form,'. |
|
"'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}', |
|
'$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('tab').'</label>'.(' 'x2). |
'<label><input type="radio" name="exttooltarget" value="window" '.$chkstate{'window'}.'onclick="updateTooldim(this.form,'. |
'<label><input type="radio" name="exttooltarget" value="window" '.$chkstate{'window'}.'onclick="updateTooldim(this.form,'. |
"'$toolattr{dimendiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}'".');">'.&mt('window').'</label>'. |
"'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}', |
'</span><div id="'.$toolattr{'dimendiv'}.'" style="'.$dimendivstyle.'">'. |
'$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('window').'</label></span>'. |
'<span class="'.$class.'">'. |
'<div id="'.$toolattr{'dimendiv'}.'" style="'.$dimendivstyle.'"><span class="'.$class.'">'. |
&mt('Width').'<input type="text" id="'.$toolattr{'dimenwidth'}.'" name="exttoolwidth" value="'.$width.'">'.(' 'x2). |
&mt('Width').': <input type="text" size="4" id="'.$toolattr{'dimenwidth'}.'" name="exttoolwidth" value="'.$width.'"'.$disabled.' />'.(' 'x2). |
&mt('Height').'<input type="text" id="'.$toolattr{'dimenheight'}.'" name="exttoolheight" value="'.$height.'"></span>'."\n". |
&mt('Height').': <input type="text" size="4" id="'.$toolattr{'dimenheight'}.'" name="exttoolheight" value="'.$height.'"'.$disabled.' /></span>'."\n". |
'</div></div>'; |
'</div></div>'; |
|
$toolelem .= '<div id="'.$toolattr{'windiv'}.'" style="'.$windivstyle.'">'. |
|
'<div id="'.$toolattr{'linktextdiv'}.'" class="LC_left_float" style="'.$linktextstyle.'">'. |
|
'<span class="'.$class.'">'.&mt('Link Text').'</span><br /><input type="text" size="25" id="'.$toolattr{'linktext'}. |
|
'" name="exttoollinktext" value="'.$linktext.'"'.$disabled.' />'. |
|
'</div><div id="'.$toolattr{'explanationdiv'}.'" class="LC_left_float" style="'.$explanationstyle.'">'. |
|
'<span class="'.$class.'">'.&mt('Explanation').'</span><br />'. |
|
'<textarea rows="'.$rows.'" cols="'.$cols.'" id="'.$toolattr{'explanation'}.'" name="exttoolexplanation" '.$disabled.'>'. |
|
$explanation.'</textarea></div><div style="padding:0;clear:both;margin:0;border:0"></div>'. |
|
'</div>'; |
|
$toolelem .= '<div id="'.$toolattr{'crslabeldiv'}.'" style="'.$labelstyle.'">'. |
|
'<span class="'.$class.'">'.&mt('Course label:').' '. |
|
'<input type="text" id="'.$toolattr{'crslabel'}.'" name="exttoollabel" value="'.$crslabel.'"'.$disabled.' /></span><br />'. |
|
'</div>'. |
|
'<div id="'.$toolattr{'crstitlediv'}.'" style="'.$titlestyle.'">'. |
|
'<span class="'.$class.'">'.&mt('Course title:').' '. |
|
'<input type="text" id="'.$toolattr{'crstitle'}.'" name="exttooltitle" value="'.$crstitle.'"'.$disabled.' /></span><br />'. |
|
'</div>'. |
|
'<div id="'.$toolattr{'crsappenddiv'}.'" style="'.$appendstyle.'">'. |
|
'<span class="'.$class.'">'.&mt('Append to URL[_1]', |
|
'<span id="'.$toolattr{'providerurl'}.'"> ('.$providerurl.')<br /></span>'). |
|
'<input type="text" id="'.$toolattr{'crsappend'}.'" size="30" name="exttoolappend" value="'.$crsappend.'"'.$disabled.' /></span><br />'. |
|
'</div>'; |
} |
} |
my $chooser = $toolelem; |
my $chooser = $toolelem; |
if ($type eq 'ext') { |
if ($type eq 'ext') { |
Line 487 $chooser
|
Line 586 $chooser
|
<div> |
<div> |
<span$srcclass> |
<span$srcclass> |
$title |
$title |
<input type="text" size="$size" name="exttitle" value="$orig_title" /> |
<input type="text" size="$size" name="exttitle" value="$orig_title" $disabled /> |
<input type="hidden" name="importdetail" value="" /> |
<input type="hidden" name="importdetail" value="" /> |
$pathitem |
$pathitem |
$hiddenelem |
$hiddenelem |
<input type="button" value="$save" onclick="javascript:setExternal(this.form,'$residx','$type','$orig_url');" /> |
<input type="button" value="$save" onclick="javascript:setExternal(this.form,'$residx','$type','$orig_url','$supplementalflag');" $disabled /> |
</span> |
</span> |
</div> |
</div> |
</fieldset> |
</fieldset> |
Line 505 ENDFORM
|
Line 604 ENDFORM
|
} |
} |
|
|
sub display_editor { |
sub display_editor { |
my ($url,$folderpath,$symb,$idx,$type,$cdom,$cnum) = @_; |
my ($url,$folderpath,$symb,$idx,$type,$cdom,$cnum,$hostname) = @_; |
my ($residx,$supplementalflag,$title,$pathitem,$output,$js); |
my ($residx,$supplementalflag,$title,$pathitem,$output,$js,$navmap); |
if ($folderpath =~ /^supplemental/) { |
if ($folderpath =~ /^supplemental/) { |
$supplementalflag = 1; |
$supplementalflag = 1; |
$residx = $idx; |
$residx = $idx; |
Line 516 sub display_editor {
|
Line 615 sub display_editor {
|
(my $map,$residx,my $res) = |
(my $map,$residx,my $res) = |
&Apache::lonnet::decode_symb($symb); |
&Apache::lonnet::decode_symb($symb); |
$title = &Apache::lonnet::gettitle($symb); |
$title = &Apache::lonnet::gettitle($symb); |
my $path = &Apache::loncommon::symb_to_docspath($symb); |
my $path = &Apache::loncommon::symb_to_docspath($symb,\$navmap); |
$pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($path,'<>&"').'" />'; |
$pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($path,'<>&"').'" />'; |
} |
} |
my %ltitools; |
my %ltitools; |
if ($type eq 'tool') { |
if ($type eq 'tool') { |
%ltitools = &Apache::lonnet::get_domain_ltitools($cdom); |
%ltitools = &Apache::lonnet::get_domain_lti($cdom,'consumer'); |
} |
} |
$js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript()); |
$js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript()); |
my $args = { 'force_register' => $env{'form.register'} }; |
my $args = { 'force_register' => $env{'form.register'} }; |
|
if ($hostname) { |
|
$args->{'hostname'} = $hostname; |
|
} |
my $description = 'External Resource Editor'; |
my $description = 'External Resource Editor'; |
if ($type eq 'tool') { |
if ($type eq 'tool') { |
$description = 'External Tool Editor'; |
$description = 'External Tool Editor'; |
Line 543 sub extedit_javascript {
|
Line 645 sub extedit_javascript {
|
if (ref($toolsref) eq 'HASH') { |
if (ref($toolsref) eq 'HASH') { |
my $num = scalar(keys(%{$toolsref})); |
my $num = scalar(keys(%{$toolsref})); |
$toolsjs = " var ltitools = new Array($num);\n". |
$toolsjs = " var ltitools = new Array($num);\n". |
|
" var ltitoolsUrl = new Array($num);\n". |
" var ltitoolsTarget = new Array($num);\n". |
" var ltitoolsTarget = new Array($num);\n". |
" var ltitoolsWidth = new Array($num);\n". |
" var ltitoolsWidth = new Array($num);\n". |
" var ltitoolsHeight = new Array($num);\n"; |
" var ltitoolsHeight = new Array($num);\n". |
|
" var ltitoolsLinkDef = new Array($num);\n". |
|
" var ltitoolsExplainDef = new Array($num);\n". |
|
" var ltitoolsDisplay = new Array($num);\n". |
|
" var ltitoolsLink = new Array($num);\n". |
|
" var ltitoolsExplain = new Array($num);\n". |
|
" var ltitoolsLabel = new Array($num);\n". |
|
" var ltitoolsTitle = new Array($num);\n"; |
|
" var ltitoolsAppend = new Array($num);\n"; |
my $i = 0; |
my $i = 0; |
foreach my $key (sort { $a <=> $b } keys(%{$toolsref})) { |
foreach my $key (sort { $a <=> $b } keys(%{$toolsref})) { |
if (ref($toolsref->{$key})) { |
if (ref($toolsref->{$key}) eq 'HASH') { |
my $target = $toolsref->{$key}->{'target'}; |
if (ref($toolsref->{$key}->{'display'}) eq 'HASH') { |
my $width = $toolsref->{$key}->{'width'}; |
my $target = $toolsref->{$key}->{'display'}->{'target'}; |
my $height = $toolsref->{$key}->{'height'}; |
my $width = $toolsref->{$key}->{'display'}->{'width'}; |
$toolsjs .= ' ltitools['.$i.'] = '."'$key';\n". |
my $height = $toolsref->{$key}->{'display'}->{'height'}; |
' ltitoolsTarget['.$i.'] = '."'$target';\n". |
my $linkdef = $toolsref->{$key}->{'display'}->{'linktext'}; |
' ltitoolsWidth['.$i.'] = '."'$width';\n". |
my $explaindef = $toolsref->{$key}->{'display'}->{'explanation'}; |
' ltitoolsHeight['.$i.'] = '."'$height';\n"; |
my $providerurl; |
|
if ($toolsref->{$key}->{'url'} =~ m{://}) { |
|
(my $prot,my $host,$providerurl) = ($toolsref->{$key}->{'url'} =~ m{^([^/]+)://([^/]+)(|/.+)$}); |
|
} else { |
|
$providerurl = $toolsref->{$key}->{'url'}; |
|
} |
|
$providerurl = &LONCAPA::map::qtunescape($providerurl); |
|
$toolsjs .= ' ltitools['.$i.'] = '."'$key';\n". |
|
' ltitoolsTarget['.$i.'] = '."'$target';\n". |
|
' ltitoolsWidth['.$i.'] = '."'$width';\n". |
|
' ltitoolsHeight['.$i.'] = '."'$height';\n". |
|
' ltitoolsLinkDef['.$i.'] = '."'$linkdef';\n". |
|
' ltitoolsExplainDef['.$i.'] = '."'$explaindef';\n". |
|
' ltitoolsUrl['.$i.'] = '."'$providerurl';\n"; |
|
} |
|
if (ref($toolsref->{$key}->{'crsconf'}) eq 'HASH') { |
|
my $display = $toolsref->{$key}->{'crsconf'}->{'target'}; |
|
$toolsjs .= ' ltitoolsDisplay['.$i.'] = '."'$display';\n"; |
|
my $linktext = $toolsref->{$key}->{'crsconf'}->{'linktext'}; |
|
$toolsjs .= ' ltitoolsLink['.$i.'] = '."'$linktext';\n"; |
|
my $explanation = $toolsref->{$key}->{'crsconf'}->{'explanation'}; |
|
$toolsjs .= ' ltitoolsExplain['.$i.'] = '."'$explanation';\n"; |
|
my $label = $toolsref->{$key}->{'crsconf'}->{'label'}; |
|
$toolsjs .= ' ltitoolsLabel['.$i.'] = '."'$label';\n"; |
|
my $title = $toolsref->{$key}->{'crsconf'}->{'title'}; |
|
$toolsjs .= ' ltitoolsTitle['.$i.'] = '."'$title';\n"; |
|
my $append = $toolsref->{$key}->{'crsconf'}->{'append'}; |
|
$toolsjs .= ' ltitoolsAppend['.$i.'] = '."'$append';\n"; |
|
} |
|
|
$i++; |
$i++; |
} |
} |
} |
} |
Line 575 ENDREGEXP
|
Line 715 ENDREGEXP
|
|
|
var regexp = $urlregexp; |
var regexp = $urlregexp; |
|
|
function setExternal(extform,residx,type,exttoolurl) { |
function setExternal(extform,residx,type,exttoolurl,supplementalflag) { |
var title=extform.exttitle.value; |
var title=extform.exttitle.value; |
if (!String.trim) { |
if (!String.trim) { |
String.prototype.trim = function() {return this.replace(\/^\\s+|\\s+$\/g, "");}; } |
String.prototype.trim = function() {return this.replace(\/^\\s+|\\s+$\/g, "");}; } |
Line 610 function setExternal(extform,residx,type
|
Line 750 function setExternal(extform,residx,type
|
} |
} |
info += ':'+toolid; |
info += ':'+toolid; |
} |
} |
if (extform.exttooltarget.length) { |
var prefix = ''; |
for (var i=0; i<extform.exttooltarget.length; i++) { |
if (supplementalflag == 1) { |
if (extform.exttooltarget[i].checked) { |
prefix = 'supp'; |
if (extform.exttooltarget[i].value == 'window') { |
} |
var width = extform.exttoolwidth.value; |
var dispdiv = prefix+'tooldispdiv'; |
width.trim(); |
var windiv = prefix+'toolwindiv'; |
var height = extform.exttoolheight.value; |
if (residx > 0) { |
height.trim(); |
dispdiv += '_'+residx; |
info += ':window:'+width+':'+height; |
windiv += '_'+residx; |
} else { |
} |
info += ':iframe'; |
if (document.getElementById(dispdiv)) { |
|
if (document.getElementById(dispdiv).style.display == 'block') { |
|
if (extform.exttooltarget.length) { |
|
for (var i=0; i<extform.exttooltarget.length; i++) { |
|
if (extform.exttooltarget[i].checked) { |
|
if (extform.exttooltarget[i].value == 'window') { |
|
var width = extform.exttoolwidth.value; |
|
width.trim(); |
|
var height = extform.exttoolheight.value; |
|
height.trim(); |
|
info += ':window:'+width+':'+height; |
|
} else if (extform.exttooltarget[i].value == 'tab') { |
|
info += ':tab::'; |
|
} else { |
|
info += ':iframe::'; |
|
} |
|
} |
} |
} |
} |
} |
|
} else { |
|
info += ':::'; |
|
} |
|
} else { |
|
info += ':::'; |
|
} |
|
if (document.getElementById(windiv)) { |
|
if (document.getElementById(windiv).style.display == 'block') { |
|
var linktextdiv = prefix+'toollinktextdiv'; |
|
var explanationdiv = prefix+'toolexplanationdiv'; |
|
if (residx > 0) { |
|
linktextdiv += '_'+residx; |
|
explanationdiv += '_'+residx; |
|
} |
|
if (document.getElementById(linktextdiv).style.display == 'inline') { |
|
var linktext = extform.exttoollinktext.value; |
|
linktext.trim(); |
|
info += ':'+escape(linktext); |
|
} else { |
|
info += ':'; |
|
} |
|
if (document.getElementById(explanationdiv).style.display == 'inline') { |
|
var explaintext = extform.exttoolexplanation.value; |
|
explaintext.trim(); |
|
info += ':'+escape(explaintext); |
|
} else { |
|
info += ':'; |
|
} |
|
} else { |
|
info += '::'; |
} |
} |
|
} else { |
|
info += '::'; |
|
} |
|
var labelinput = prefix+'toolcrslabel'; |
|
var titleinput = prefix+'toolcrstitle'; |
|
var appendinput = prefix+'toolcrsappend'; |
|
if (residx > 0) { |
|
labelinput += '_'+residx; |
|
titleinput += '_'+residx; |
|
appendinput += '_'+residx; |
|
} |
|
if (document.getElementById(labelinput)) { |
|
var crslabel = document.getElementById(labelinput).value; |
|
crslabel.trim(); |
|
info += ':'+escape(crslabel); |
|
} else { |
|
info += ':'; |
|
} |
|
if (document.getElementById(titleinput)) { |
|
var crstitle = document.getElementById(titleinput).value; |
|
crstitle.trim(); |
|
info += ':'+escape(crstitle); |
|
} else { |
|
info += ':'; |
|
} |
|
if (document.getElementById(appendinput)) { |
|
var crsappend = document.getElementById(appendinput).value; |
|
crsappend.trim(); |
|
info += ':'+escape(crsappend); |
|
} else { |
|
info += ':'; |
} |
} |
info=escape(info); |
info=escape(info); |
if (residx > 0) { |
if (residx > 0) { |
Line 648 function editext(residx,type) {
|
Line 865 function editext(residx,type) {
|
return; |
return; |
} |
} |
|
|
function extUrlPreview(caller) { |
function extUrlPreview(caller,protocol) { |
if (document.getElementById(caller)) { |
if (document.getElementById(caller)) { |
var url = document.getElementById(caller).value; |
var url = document.getElementById(caller).value; |
if (regexp.test(url)) { |
if (regexp.test(url)) { |
openMyModal(url,500,400,'yes'); |
var http_regex = /^http\:\/\//gi; |
|
if ((protocol == 'https') && (http_regex.test(url))) { |
|
window.open(url,"externalpreview","height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1"); |
|
} else { |
|
openMyModal(url,500,400,'yes'); |
|
} |
} else { |
} else { |
alert("$js_lt{'invurl'}"); |
alert("$js_lt{'invurl'}"); |
} |
} |
Line 666 function updateExttool(caller,form,suppl
|
Line 888 function updateExttool(caller,form,suppl
|
} |
} |
dispdiv = prefix+'tooldispdiv'; |
dispdiv = prefix+'tooldispdiv'; |
dimendiv = prefix+'tooldimendiv'; |
dimendiv = prefix+'tooldimendiv'; |
widthinput = prefix+'toolwidth'; |
widthinput = prefix+'tooldimenwidth'; |
heightinput = prefix+'toolheight'; |
heightinput = prefix+'tooldimenheight'; |
|
labeldiv = prefix+'toolcrslabeldiv'; |
|
titlediv = prefix+'toolcrstitlediv'; |
|
appenddiv = prefix+'toolcrsappenddiv'; |
|
providerurl = prefix+'toolproviderurl'; |
|
labelinput = prefix+'toolcrslabel'; |
|
titleinput = prefix+'toolcrstitle'; |
|
appendinput = prefix+'toolcrsappend'; |
|
windiv = prefix+'toolwindiv'; |
|
linktextdiv = prefix+'toollinktextdiv'; |
|
linktextinput = prefix+'toollinktext'; |
|
explanationdiv = prefix+'toolexplanationdiv'; |
|
explanationinput = prefix+'toolexplanation'; |
if (document.getElementById(dispdiv)) { |
if (document.getElementById(dispdiv)) { |
var toolpick = caller.options[caller.selectedIndex].value; |
var toolpick = caller.options[caller.selectedIndex].value; |
$toolsjs |
$toolsjs |
Line 678 function updateExttool(caller,form,suppl
|
Line 912 function updateExttool(caller,form,suppl
|
if (document.getElementById(dimendiv)) { |
if (document.getElementById(dimendiv)) { |
document.getElementById(dimendiv).style.display = 'none'; |
document.getElementById(dimendiv).style.display = 'none'; |
} |
} |
} else { |
if (document.getElementById(windiv)) { |
if (document.getElementById(dispdiv)) { |
document.getElementById(windiv).style.display = 'none'; |
document.getElementById(dispdiv).style.display = 'block'; |
} |
|
if (document.getElementById(linktextdiv)) { |
|
document.getElementById(linktextdiv).style.display = 'none'; |
|
} |
|
if (document.getElementById(explanationdiv)) { |
|
document.getElementById(explanationdiv).style.display = 'none'; |
} |
} |
|
if (document.getElementById(labeldiv)) { |
|
document.getElementById(labeldiv).style.display = 'none'; |
|
} |
|
if (document.getElementById(titlediv)) { |
|
document.getElementById(titlediv).style.display = 'none'; |
|
} |
|
if (document.getElementById(appenddiv)) { |
|
document.getElementById(appenddiv).style.display = 'none'; |
|
} |
|
} else { |
if (ltitools.length > 0) { |
if (ltitools.length > 0) { |
for (var j=0; j<ltitools.length; j++) { |
for (var j=0; j<ltitools.length; j++) { |
if (ltitools[j] == toolpick) { |
if (ltitools[j] == toolpick) { |
if (form.exttooltarget.length) { |
if (document.getElementById(dispdiv)) { |
for (var k=0; k<form.exttooltarget.length; k++) { |
if (ltitoolsDisplay[j]) { |
if (form.exttooltarget[k].value == ltitoolsTarget[j]) { |
document.getElementById(dispdiv).style.display = 'block'; |
form.exttooltarget[k].checked = true; |
if (form.exttooltarget.length) { |
break; |
for (var k=0; k<form.exttooltarget.length; k++) { |
|
if (form.exttooltarget[k].value == ltitoolsTarget[j]) { |
|
form.exttooltarget[k].checked = true; |
|
break; |
|
} |
|
} |
} |
} |
} |
} |
|
var dimen = 'none'; |
|
var dimenwidth = ''; |
|
var dimenheight = ''; |
|
if ((ltitoolsDisplay[j]) && (ltitoolsTarget[j] == 'window')) { |
|
dimen = 'block'; |
|
dimenwidth = ltitoolsWidth[j]; |
|
dimenheight = ltitoolsHeight[j]; |
|
} |
|
if (document.getElementById(dimendiv)) { |
|
document.getElementById(dimendiv).style.display = dimen; |
|
} |
|
if (document.getElementById(widthinput)) { |
|
document.getElementById(widthinput).value = dimenwidth; |
|
} |
|
if (document.getElementById(heightinput)) { |
|
document.getElementById(heightinput).value = dimenheight; |
|
} |
} |
} |
if (ltitoolsTarget[j] == 'window') { |
if (document.getElementById(windiv)) { |
dimen = 'block'; |
if ((ltitoolsTarget[j] == 'window') || (ltitoolsTarget[j] == 'tab')) { |
dimenwidth = ltitoolsWidth[j]; |
document.getElementById(windiv).style.display = 'block'; |
dimenheight = ltitoolsHeight[j]; |
} else { |
} else { |
document.getElementById(windiv).style.display = 'none'; |
dimen = 'none'; |
} |
dimenwidth = ''; |
if (document.getElementById(linktextdiv)) { |
dimenheight = ''; |
if (ltitoolsLink[j]) { |
|
document.getElementById(linktextdiv).style.display = 'inline'; |
|
} else { |
|
document.getElementById(linktextdiv).style.display = 'none'; |
|
} |
|
} |
|
if (document.getElementById(linktextinput)) { |
|
if (ltitoolsLink[j]) { |
|
document.getElementById(linktextinput).value = ltitoolsLinkDef[j]; |
|
} else { |
|
document.getElementById(linktextinput).value = ''; |
|
} |
|
} |
|
if (document.getElementById(explanationdiv)) { |
|
if (ltitoolsExplain[j]) { |
|
document.getElementById(explanationdiv).style.display = 'inline'; |
|
} else { |
|
document.getElementById(explanationdiv).style.display = 'none'; |
|
} |
|
} |
|
if (document.getElementById(explanationinput)) { |
|
if (ltitoolsExplain[j]) { |
|
document.getElementById(explanationinput).value = ltitoolsExplainDef[j]; |
|
} else { |
|
document.getElementById(explananationinput).value = ''; |
|
} |
|
} |
} |
} |
if (document.getElementById(dimendiv)) { |
if (document.getElementById(labeldiv)) { |
document.getElementById(dimendiv).style.display = dimen; |
if (ltitoolsLabel[j]) { |
|
document.getElementById(labeldiv).style.display = 'inline'; |
|
} else { |
|
document.getElementById(labeldiv).style.display = 'none'; |
|
} |
} |
} |
if (document.getElementById(widthinput)) { |
if (document.getElementById(titlediv)) { |
document.getElementById(widthinput).value = dimenwidth; |
if (ltitoolsTitle[j]) { |
|
document.getElementById(titlediv).style.display = 'inline'; |
|
} else { |
|
document.getElementById(titlediv).style.display = 'none'; |
|
} |
} |
} |
if (document.getElementById(heightinput)) { |
if (document.getElementById(appenddiv)) { |
document.getElementById(heightinput).value = dimenheight; |
if (ltitoolsAppend[j]) { |
|
document.getElementById(appenddiv).style.display = 'inline'; |
|
if (document.getElementById(providerurl)) { |
|
if ((ltitoolsUrl[j] != '') && (ltitoolsUrl[j] != null)) { |
|
document.getElementById(providerurl).innerHTML = ' ('+ltitoolsUrl[j]+')<br />'; |
|
} |
|
} |
|
} else { |
|
document.getElementById(appenddiv).style.display = 'none'; |
|
if (document.getElementById(providerurl)) { |
|
document.getElementById(providerurl).innerHTML = ''; |
|
} |
|
} |
} |
} |
|
break; |
} |
} |
break; |
|
} |
} |
} |
} |
} |
} |
} |
} |
} |
} |
|
|
function updateTooldim(form,dimendiv,widthinput,heightinput) { |
function updateTooldim(form,dimendiv,windiv,widthinput,heightinput,linkinput,explaininput) { |
if (form.exttooltarget.length) { |
if (form.exttooltarget.length) { |
for (var i=0; i<form.exttooltarget.length; i++) { |
for (var i=0; i<form.exttooltarget.length; i++) { |
if (form.exttooltarget[i].checked) { |
if (form.exttooltarget[i].checked) { |
var dimen = 'none'; |
var dimen = 'none'; |
|
var linkconf = 'none'; |
if (form.exttooltarget[i].value == 'window') { |
if (form.exttooltarget[i].value == 'window') { |
dimen = 'block'; |
dimen = 'block'; |
|
linkconf = 'block'; |
} else { |
} else { |
if (document.getElementById(widthinput)) { |
if (form.exttooltarget[i].value == 'tab') { |
document.getElementById(widthinput).value = ''; |
linkconf = 'block'; |
} |
} else { |
if (document.getElementById(heightinput)) { |
if (document.getElementById(widthinput)) { |
document.getElementById(heightinput).value = ''; |
document.getElementById(widthinput).value = ''; |
|
} |
|
if (document.getElementById(heightinput)) { |
|
document.getElementById(heightinput).value = ''; |
|
} |
|
if (document.getElementById(linkinput)) { |
|
document.getElementById(linkinput).value = ''; |
|
} |
|
if (document.getElementById(explaininput)) { |
|
document.getElementById(explaininput).value = ''; |
|
} |
} |
} |
} |
} |
if (document.getElementById(dimendiv)) { |
if (document.getElementById(dimendiv)) { |
document.getElementById(dimendiv).style.display = dimen; |
document.getElementById(dimendiv).style.display = dimen; |
} |
} |
|
if (document.getElementById(windiv)) { |
|
document.getElementById(windiv).style.display = linkconf; |
|
} |
break; |
break; |
} |
} |
} |
} |