Annotation of loncom/interface/lonextresedit.pm, revision 1.18
1.1 raeburn 1: # The LearningOnline Network
2: # Documents
3: #
1.18 ! raeburn 4: # $Id: lonextresedit.pm,v 1.17 2017/05/06 15:47:48 raeburn Exp $
1.1 raeburn 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
29: package Apache::lonextresedit;
30:
31: use strict;
32: use Apache::Constants qw(:common :http);
33: use HTML::Entities;
34: use Apache::lonlocal;
35: use Apache::lonnet;
36: use Apache::loncommon;
37: use Apache::lonhtmlcommon;
38: use Apache::lonuserstate;
39: use LONCAPA::map();
40: use LONCAPA qw(:DEFAULT :match);
41:
42: sub handler {
43: my $r=shift;
44: &Apache::loncommon::content_type($r,'text/html');
45: $r->send_http_header;
46:
47: return OK if $r->header_only;
48:
49: # Check for access
50: if (! &Apache::lonnet::allowed('mdc',$env{'request.course.id'})) {
51: $env{'user.error.msg'}=
52: $r->uri.":mdc:0:0:Cannot modify course content.";
53: return HTTP_NOT_ACCEPTABLE;
54: }
55:
56: my $cdom = $env{'course.'.$env{'request.course.id'}.'.domain'};
57: my $cnum = $env{'course.'.$env{'request.course.id'}.'.num'};
58: my $chome = $env{'course.'.$env{'request.course.id'}.'.home'};
1.9 raeburn 59: my ($supplementalflag,$updated,$output,$errormsg,$residx,$url,$title,
60: $symb,$type);
1.5 raeburn 61: if (($env{'form.folderpath'} =~ /^supplemental/) && ($env{'form.suppurl'})) {
62: $supplementalflag = 1;
1.18 ! raeburn 63: if (&unescape($env{'form.suppurl'}) =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {
1.9 raeburn 64: $type = 'tool';
65: }
1.7 raeburn 66: }
1.5 raeburn 67: if (($supplementalflag) || ($env{'form.symb'} =~ /^uploaded/)) {
1.7 raeburn 68: ($updated,$output,$errormsg,$residx,$url,$title,$symb) =
1.1 raeburn 69: &process_changes($supplementalflag,$cdom,$cnum,$chome);
70: if ($supplementalflag) {
1.9 raeburn 71: if ($url ne &unescape($env{'form.suppurl'})) {
1.1 raeburn 72: $env{'form.suppurl'} = $url;
73: }
74: if ($title ne $env{'form.title'}) {
75: $env{'form.title'} = $title;
76: }
1.5 raeburn 77: $env{'form.idx'} = $residx;
1.1 raeburn 78: } else {
79: if ($symb ne $env{'form.symb'}) {
80: $env{'form.symb'} = $symb;
81: }
1.18 ! raeburn 82: if ($url =~ m{/adm/$cdom/$cnum/\d+/ext\.tool$}) {
1.9 raeburn 83: $type = 'tool';
84: }
1.1 raeburn 85: }
86: } else {
87: $errormsg = &mt('Information about external resource to edit is missing.');
88: }
89: if ($updated) {
1.9 raeburn 90: my $msg = &mt('External Resource updated');
91: if ($type eq 'tool') {
92: $msg = &mt('External Tool updated');
93: }
94: $output = &Apache::lonhtmlcommon::confirm_success($msg);
1.1 raeburn 95: }
96: if ($errormsg) {
97: $errormsg = '<p class="LC_error">'.$errormsg.'</p>';
98: }
1.9 raeburn 99: my %ltitools;
100: if ($type eq 'tool') {
101: %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);
102: }
1.1 raeburn 103: my $js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript());
104: my $pathitem = '<input type="hidden" name="folderpath" value="'.
105: &HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
1.9 raeburn 106: my $description = 'External Resource Editor';
107: if ($type eq 'tool') {
108: $description = 'External Tool Editor';
109: }
110: $r->print(&Apache::loncommon::start_page($description,$js).
1.1 raeburn 111: '<div class="LC_left_float">'.
112: $output.
113: $errormsg.
114: &extedit_form($supplementalflag,$residx,$url,$title,$pathitem,undef,
1.9 raeburn 115: 'direct',$env{'form.symb'},$type,$cdom,$cnum,\%ltitools).
1.1 raeburn 116: '</div>'.&Apache::loncommon::end_page());
117: return OK;
118: }
119:
120: sub process_changes {
121: my ($supplementalflag,$cdom,$cnum,$chome) = @_;
1.9 raeburn 122: my ($folder,$container,$output,$errormsg,$updated,$symb,$oldidx,$oldurl,$type,
123: $oldtitle,$newidx,$newurl,$newtitle,$residx,$url,$title,$marker,$args);
1.1 raeburn 124: if ($env{'form.symb'}) {
125: $symb = $env{'form.symb'};
1.5 raeburn 126: (my $map,$oldidx,$oldurl)=&Apache::lonnet::decode_symb($symb);
1.1 raeburn 127: if ($map =~ m{^uploaded/$cdom/$cnum/(default(_\d+|))\.(sequence|page)$}) {
128: $folder = $1;
129: $container = $3;
130: }
131: $oldtitle = &Apache::lonnet::gettitle($env{'form.symb'});
1.9 raeburn 132: if ($oldurl =~ m{^ext/(.+)$}) {
133: my $external = $1;
134: if ($external =~ m{^https://}) {
135: $oldurl = $external;
136: } else {
137: $oldurl = 'http://'.$oldurl;
138: }
139: $type = 'ext';
140: } else {
141: $type = 'tool';
142: }
1.1 raeburn 143: } elsif ($env{'form.folderpath'}) {
144: $folder = &unescape( (split('&',$env{'form.folderpath'}))[-2] );
145: $oldurl = &unescape($env{'form.suppurl'});
146: $oldtitle = &unescape($env{'form.title'});
147: $container = 'sequence';
148: $supplementalflag = 1;
1.18 ! raeburn 149: if ($oldurl =~ m{^/adm/$cdom/$cnum/\d+/ext\.tool$}) {
1.9 raeburn 150: $type = 'tool';
1.5 raeburn 151: } else {
1.9 raeburn 152: $type = 'ext';
1.5 raeburn 153: }
154: }
155: $url = $oldurl;
156: $title = $oldtitle;
157: if ($env{'form.importdetail'}) {
158: ($newtitle,$newurl,$newidx) =
159: map {&unescape($_)} split(/\=/,$env{'form.importdetail'});
1.18 ! raeburn 160: if ($newurl =~ m{^(/adm/$cdom/$cnum/(\d+)/ext\.tool)\:?(.*)$}) {
1.9 raeburn 161: $newurl = $1;
162: $marker = $2;
163: $args = $3;
164: }
1.5 raeburn 165: }
166: if ($supplementalflag) {
167: $residx = $newidx;
168: } else {
169: $residx = $oldidx;
170: }
1.1 raeburn 171: if ($folder && $container) {
172: if ($env{'form.importdetail'}) {
1.5 raeburn 173: my ($errtext,$fatal,$mismatchedid,@imports);
174: if (!$supplementalflag) {
175: if (($oldidx) && ($oldidx != $newidx)) {
176: $mismatchedid = 1;
177: }
1.1 raeburn 178: }
179: if ($mismatchedid) {
180: $errormsg = 'Wrong item identifier';
181: } elsif (($newtitle eq $oldtitle) && ($newurl eq $oldurl)) {
1.9 raeburn 182: if ($type eq 'tool') {
183: if ($args) {
184: ($updated,$errormsg) = &update_exttool($marker,$cdom,$cnum,$args);
185: unless ($updated) {
186: $output = &mt('No change');
187: }
188: } else {
189: $output = &mt('No change');
190: }
191: } else {
192: $output = &mt('No change');
193: }
1.1 raeburn 194: } else {
195: my $map = "/uploaded/$cdom/$cnum/$folder.$container";
196: my ($errtext,$fatal) = &LONCAPA::map::mapread($map);
197: if ($fatal) {
198: $errormsg = &mt('Update failed: [_1].',$errtext);
199: } else {
200: my $saveurl = &LONCAPA::map::qtunescape($newurl);
201: my $savetitle = &LONCAPA::map::qtunescape($newtitle);
1.9 raeburn 202: my $ext = 'true';
203: if ($type eq 'tool') {
204: if ($args) {
205: ($updated,$errormsg) = &update_exttool($marker,$cdom,$cnum,$args);
206: }
207: $ext = 'false';
208: }
1.1 raeburn 209: $LONCAPA::map::resources[$residx] =
1.9 raeburn 210: join(':', ($savetitle,$saveurl,$ext,'normal','res'));
1.1 raeburn 211: my ($outtext,$errtext) = &LONCAPA::map::storemap($map,1);
212: if ($errtext) {
213: $errormsg = &mt('Update failed: [_1].',$errtext);
214: } else {
215: $updated = 1;
1.5 raeburn 216: $title = $newtitle;
217: if ($newurl ne $oldurl) {
218: $url = $newurl;
1.9 raeburn 219: if ($ext eq 'true') {
220: $newurl =~ s{^http://}{};
221: $newurl = "ext/$newurl";
222: }
1.5 raeburn 223: }
1.1 raeburn 224: if (!$supplementalflag) {
225: if ($newurl ne $oldurl) {
1.5 raeburn 226: $symb = &Apache::lonnet::encode_symb($map,$residx,$newurl);
1.1 raeburn 227: } else {
228: $symb = $env{'form.symb'};
229: if ($symb) {
230: &Apache::lonnet::devalidate_title_cache($symb);
231: }
232: }
233: }
1.5 raeburn 234: my ($furl,$ferr) =
235: &Apache::lonuserstate::readmap("$cdom/$cnum");
1.1 raeburn 236: if ($ferr) {
237: $errormsg = &mt('Reload failed: [_1].',$ferr);
238: } else {
1.5 raeburn 239: unless ($supplementalflag) {
240: &Apache::loncommon::update_content_constraints($cdom,$cnum,$chome,$cdom.'_'.$cnum);
241: }
1.1 raeburn 242: }
243: }
244: }
245: }
246: } else {
247: $output = &mt('No change');
248: }
249: } else {
1.9 raeburn 250: if ($type eq 'tool') {
251: $errormsg = &mt('Information about current external tool is incomplete.');
252: } else {
253: $errormsg = &mt('Information about current external resource is incomplete.');
254: }
1.1 raeburn 255: }
1.5 raeburn 256: return ($updated,$output,$errormsg,$residx,$url,$title,$symb);
1.1 raeburn 257: }
258:
1.9 raeburn 259: sub update_exttool {
260: my ($marker,$cdom,$cnum,$args) = @_;
261: my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
1.10 raeburn 262: my (%newhash,$changed,@deleted,$errormsg);
1.16 raeburn 263: ($newhash{'target'},$newhash{'width'},$newhash{'height'},$newhash{'linktext'},$newhash{'explanation'},
264: $newhash{'crslabel'},$newhash{'crstitle'}) = split(/:/,$args);
265: foreach my $item ('linktext','explanation','crslabel','crstitle') {
266: $newhash{$item} = &unescape($newhash{$item});
267: }
1.9 raeburn 268: my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
1.16 raeburn 269: foreach my $item ('target','width','height','linktext','explanation','crslabel','crstitle') {
1.9 raeburn 270: $newhash{$item} =~ s/^\s+//;
271: $newhash{$item} =~ s/\s+$//;
1.16 raeburn 272: if (($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) {
1.9 raeburn 273: if ($newhash{'target'} eq 'iframe') {
274: $newhash{$item} = '';
275: }
276: }
277: if ($toolhash{$item} ne $newhash{$item}) {
278: if ($newhash{$item} eq '') {
1.10 raeburn 279: unless (($item eq 'target') ||
1.16 raeburn 280: ((($item eq 'width') || ($item eq 'height') || ($item eq 'linktext') || ($item eq 'explanation')) &&
1.10 raeburn 281: (($newhash{'target'} eq 'window') ||
282: (($newhash{'target'} eq '') && ($toolhash{'target'} eq 'window'))))) {
283: delete($toolhash{$item});
284: push(@deleted,$item);
285: $changed = 1;
286: }
1.9 raeburn 287: } else {
288: $toolhash{$item} = $newhash{$item};
1.10 raeburn 289: $changed = 1;
1.9 raeburn 290: }
291: }
292: }
293: if ($changed) {
294: my $putres = &Apache::lonnet::put('exttool_'.$marker,\%toolhash,$cdom,$cnum);
295: unless ($putres eq 'ok') {
1.10 raeburn 296: $errormsg = &mt('Failed to save updated settings.').' '.&mt('Error: [_1].',$putres);
1.9 raeburn 297: }
298: }
1.10 raeburn 299: if (@deleted) {
300: &Apache::lonnet::del('exttool_'.$marker,\@deleted,$cdom,$cnum);
301: }
1.9 raeburn 302: return ($changed,$errormsg);
303: }
304:
1.1 raeburn 305: sub extedit_form {
1.9 raeburn 306: my ($supplementalflag,$residx,$orig_url,$orig_title,$pathitem,$helpitem,$caller,
1.11 raeburn 307: $symb,$type,$cdom,$cnum,$ltitools,$disabled) = @_;
1.9 raeburn 308: if ($type ne 'tool') {
309: $type = 'ext';
310: }
1.1 raeburn 311: my %lt = &Apache::lonlocal::texthash(
312: ex => 'External Resource',
1.9 raeburn 313: et => 'External Tool',
1.1 raeburn 314: ed => 'Edit',
315: ee => 'External Resource Editor',
1.9 raeburn 316: te => 'External Tool Editor',
1.1 raeburn 317: pr => 'Preview',
318: sv => 'Save',
319: ul => 'URL',
320: ti => 'Title',
321: al => 'Add Link',
1.9 raeburn 322: at => 'Add Tool',
1.1 raeburn 323: );
324: my $tabid = 'aa';
325: my $size = 60;
326: if ($supplementalflag) {
327: $tabid = 'ee';
1.9 raeburn 328: }
329: my ($formname,$formid,$toggle,$fieldsetid,$urlid,$dispdivstyle,$dimendivstyle,
1.16 raeburn 330: $windivstyle,$linktextstyle,$explanationstyle,$labelstyle,$titlestyle,
331: $legend,$urlelem,$toolelem,%toolattr);
1.9 raeburn 332: $formname = 'new'.$type;
333: $toggle = $type;
334: $fieldsetid = 'upload'.$type.'form';
335: $urlid = $type.'url';
1.10 raeburn 336: map { $toolattr{$_} = $type.$_; } ('dispdiv','dimendiv','dimenwidth','dimenheight',
1.16 raeburn 337: 'crstitlediv','crslabeldiv','crstitle','crslabel',
338: 'windiv','linktextdiv','explanationdiv','linktext',
339: 'explanation');
1.9 raeburn 340: $dispdivstyle = 'display:none';
341: $dimendivstyle = 'display:none';
1.16 raeburn 342: $windivstyle = 'display:none';
343: $linktextstyle = 'display:none';
344: $explanationstyle = 'display:none';
1.10 raeburn 345: $labelstyle = 'display:none';
346: $titlestyle = 'display:none';
1.9 raeburn 347: if ($supplementalflag) {
348: $formname = 'newsupp'.$type;
349: $toggle = 'supp'.$type;
350: $fieldsetid = 'uploadsupp'.$type.'form';
351: $urlid = 'supp'.$type.'url';
352: map { $toolattr{$_} = 'supp'.$toolattr{$_}; } (keys(%toolattr));
1.1 raeburn 353: }
1.10 raeburn 354: my ($link,$legend,$active,$srcclass,$extsrc,$preview,$title,$save,$crstitle,$crslabel,
1.16 raeburn 355: $fieldsetstyle,$action,$hiddenelem,$form,$width,$height,$tooltarget,
356: $linktext,$explanation,%chkstate);
1.1 raeburn 357: $fieldsetstyle = 'display: none;';
358: $action = '/adm/coursedocs';
1.14 raeburn 359: my $protocol = ($ENV{'SERVER_PORT'} == 443?'https':'http');
1.16 raeburn 360: my $rows = 2;
361: my $cols = 20;
1.1 raeburn 362: if ($residx) {
363: if ($caller eq 'direct') {
364: $fieldsetstyle = 'display: block;';
365: $action = '/adm/extresedit';
1.16 raeburn 366: $rows = 10;
367: $cols = 45;
1.9 raeburn 368: if ($type eq 'tool') {
369: $legend = $lt{'ee'};
370: } else {
371: $legend = $lt{'te'};
372: }
373: $legend = '<legend>'.$legend.'</legend>';
1.1 raeburn 374: if ($symb) {
375: $hiddenelem = '<input type="hidden" name="symb" value="'.$symb.'" />';
376: } elsif ($supplementalflag) {
377: $hiddenelem = '<input type="hidden" name="suppurl" value="'.
378: &HTML::Entities::encode(&escape($orig_url),'<>&"').'" />'."\n".
379: '<input type="hidden" name="title" value="'.
380: &HTML::Entities::encode(&escape($orig_title),'<>&"').'" />';
381: }
1.9 raeburn 382: } else {
383: $link = '<a class="LC_docs_ext_edit" href="javascript:editext('."'$residx','$type'".');">'.$lt{'ed'}.'</a> '."\n";
1.1 raeburn 384: $size = 40;
1.3 raeburn 385: $active = '<input type="hidden" name="active" value="'.$tabid.'" />';
1.1 raeburn 386: }
1.9 raeburn 387: $formname = 'edit'.$type.'_'.$residx;
388: $fieldsetid = 'upload'.$type.$residx;
389: $urlid = $type.'url_'.$residx;
390: map { $toolattr{$_} .= '_'.$residx; } (keys(%toolattr));
1.1 raeburn 391: $srcclass = ' class="LC_nobreak"';
1.9 raeburn 392: if ($type eq 'ext') {
393: $extsrc = '<span class="LC_docs_ext_edit">'.$lt{'ul'}.' </span>';
1.14 raeburn 394: $preview = ' <a class="LC_docs_ext_edit" href="javascript:extUrlPreview('."'$urlid','$protocol'".');">'.$lt{'pr'}.'</a>';
1.9 raeburn 395: }
1.1 raeburn 396: $title = '<span class="LC_docs_ext_edit">'.$lt{'ti'}.' </span>';
397: $save = $lt{'sv'};
398: } else {
1.9 raeburn 399: $link = $lt{'ex'};
400: if ($type eq 'tool') {
401: $link = $lt{'et'};
402: }
403: $link = '<a class="LC_menubuttons_link" href="javascript:toggleUpload('."'$toggle'".');">'.$link.'</a>'.$helpitem;
404: if ($type eq 'tool') {
405: $legend = $lt{'te'};
406: } else {
407: $legend = $lt{'ee'};
408: }
409: $legend = '<legend>'.$legend.'</legend>';
1.1 raeburn 410: $title = $lt{'ti'}.':<br />';
411: $residx = 0;
1.9 raeburn 412: if ($type eq 'ext') {
413: $orig_url = 'http://';
414: $orig_title = $lt{'ex'};
415: $extsrc = $lt{'ul'}.':<br />';
1.14 raeburn 416: $preview = '<input type="button" name="view" value="'.$lt{'pr'}.'" onclick="javascript:extUrlPreview('."'$urlid','$protocol'".');"'.$disabled.' />';
1.9 raeburn 417: $save = $lt{'al'};
418: } else {
419: $orig_title = $lt{'et'};
420: $save = $lt{'at'};
1.18 ! raeburn 421: $orig_url = "/adm/$cdom/$cnum/new/ext\.tool";
1.9 raeburn 422: }
1.1 raeburn 423: $pathitem .= '<br />';
424: }
1.9 raeburn 425: $formid = $formname;
426: if ($type eq 'ext') {
1.11 raeburn 427: $urlelem = '<input type="text" size="'.$size.'" name="exturl" id="'.$urlid.'" value="'.$orig_url.'"'.$disabled.' />';
1.9 raeburn 428: } else {
429: my $class = 'LC_nobreak';
430: if ($residx) {
431: $class = 'LC_docs_ext_edit LC_nobreak';
1.18 ! raeburn 432: if ($orig_url =~ m{^/adm/$cdom/$cnum/(\d+)/ext\.tool$}) {
1.9 raeburn 433: my $marker = $1;
434: my %toolhash=&Apache::lonnet::dump('exttool_'.$marker,$cdom,$cnum);
435: if ($toolhash{'id'}) {
436: if (ref($ltitools) eq 'HASH') {
437: if (keys(%{$ltitools})) {
438: if (ref($ltitools->{$toolhash{'id'}}) eq 'HASH') {
439: my $tooltitle = $ltitools->{$toolhash{'id'}}->{'title'};
440: my $icon = $ltitools->{$toolhash{'id'}}->{'image'};
441: my $image;
442: if ($icon) {
443: $image = '<img src="'.$icon.'" alt="'.$tooltitle.'" />';
444: }
445: $tooltarget = $toolhash{'target'};
446: if ($tooltarget eq 'window') {
447: $dimendivstyle = 'display:block';
1.16 raeburn 448: $windivstyle = 'display:block';
1.9 raeburn 449: $chkstate{'window'} = 'checked="checked" ';
450: } else {
451: $chkstate{'iframe'} = 'checked="checked" ';
452: }
453: $width = $toolhash{'width'};
454: $height = $toolhash{'height'};
1.16 raeburn 455: $linktext = $toolhash{'linktext'};
456: $explanation = $toolhash{'explanation'};
1.10 raeburn 457: if (ref($ltitools->{$toolhash{'id'}}->{'crsconf'}) eq 'HASH') {
458: if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'title'}) {
459: $crstitle = $toolhash{'crstitle'};
460: $titlestyle = 'display:inline';
461: }
462: if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'label'}) {
463: $crslabel = $toolhash{'crslabel'};
464: $labelstyle = 'display:inline';
465: }
466: if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'target'}) {
467: $dispdivstyle = 'display:block';
468: }
1.16 raeburn 469: if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'linktext'}) {
470: $linktextstyle = 'padding:0;display:inline';
471: }
472: if ($ltitools->{$toolhash{'id'}}->{'crsconf'}->{'explanation'}) {
473: $explanationstyle = 'padding:0;display:inline';
474: }
1.10 raeburn 475: }
1.9 raeburn 476: $toolelem = '<span class="LC_nobreak">'.$image.' '.$tooltitle.'</span><br />';
477: }
478: }
479: }
480: }
481: }
482: } else {
483: $toolelem = '<span class="LC_docs_ext_edit">'."\n".
484: '<select name="exttoolid" id="LC_exttoolid" onchange="javascript:updateExttool(this,'.
1.11 raeburn 485: 'this.form,'."'$supplementalflag'".');"'.$disabled.'>'."\n".
1.9 raeburn 486: '<option value="" selected="selected">'.&mt('Select').'</option>';
487: my %bynum;
488: if (ref($ltitools) eq 'HASH') {
489: foreach my $id (keys(%{$ltitools})) {
490: if (ref($ltitools->{$id}) eq 'HASH') {
491: my $order = $ltitools->{$id}->{'order'};
492: $bynum{$order} = [$id,$ltitools->{$id}];
493: }
494: }
495: }
496: foreach my $item (sort { $a <=> $b } keys(%bynum)) {
497: if (ref($bynum{$item}) eq 'ARRAY') {
498: if (ref($bynum{$item}->[1]) eq 'HASH') {
499: my $tooltitle = $bynum{$item}->[1]->{'title'};
500: my $icon = $bynum{$item}->[1]->{'image'};
501: $toolelem .= '<option value="'.$bynum{$item}->[0].'">'.$tooltitle.'</option>';
502: }
503: }
504: }
1.10 raeburn 505: $toolelem .= '</select></span><br />';
506: $crslabel = $env{'course.'.$cdom.'_'.$cnum.'.internal.coursecode'};
507: $crstitle = $env{'course.'.$cdom.'_'.$cnum.'.description'};
1.9 raeburn 508: }
509: $toolelem .= '<div id="'.$toolattr{'dispdiv'}.'" style="'.$dispdivstyle.'">'.
510: '<span class="'.$class.'">'.&mt('Display target:').' '.
511: '<label><input type="radio" name="exttooltarget" value="iframe" '.$chkstate{'iframe'}.'onclick="updateTooldim(this.form,'.
1.16 raeburn 512: "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
513: '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('iframe').'</label>'.(' 'x2).
1.9 raeburn 514: '<label><input type="radio" name="exttooltarget" value="window" '.$chkstate{'window'}.'onclick="updateTooldim(this.form,'.
1.16 raeburn 515: "'$toolattr{dimendiv}','$toolattr{windiv}','$toolattr{dimenwidth}','$toolattr{dimenheight}',
516: '$toolattr{linktext}','$toolattr{explanation}'".');"'.$disabled.' />'.&mt('window').'</label></span>'.
517: '<div id="'.$toolattr{'dimendiv'}.'" style="'.$dimendivstyle.'"><span class="'.$class.'">'.
518: &mt('Width').': <input type="text" size="4" id="'.$toolattr{'dimenwidth'}.'" name="exttoolwidth" value="'.$width.'"'.$disabled.' />'.(' 'x2).
519: &mt('Height').': <input type="text" size="4" id="'.$toolattr{'dimenheight'}.'" name="exttoolheight" value="'.$height.'"'.$disabled.' /></span>'."\n".
520: '</div></div>';
521: $toolelem .= '<div id="'.$toolattr{'windiv'}.'" style="'.$windivstyle.'">'.
522: '<div id="'.$toolattr{'linktextdiv'}.'" class="LC_left_float" style="'.$linktextstyle.'">'.
523: '<span class="'.$class.'">'.&mt('Link Text').'</span><br /><input type="text" size="25" id="'.$toolattr{'linktext'}.
524: '" name="exttoollinktext" value="'.$linktext.'"'.$disabled.' />'.
525: '</div><div id="'.$toolattr{'explanationdiv'}.'" class="LC_left_float" style="'.$explanationstyle.'">'.
526: '<span class="'.$class.'">'.&mt('Explanation').'</span><br />'.
527: '<textarea rows="'.$rows.'" cols="'.$cols.'" id="'.$toolattr{'explanation'}.'" name="exttoolexplanation" '.$disabled.'>'.
528: $explanation.'</textarea></div><div style="padding:0;clear:both;margin:0;border:0"></div>'.
529: '</div>';
530: $toolelem .= '<div id="'.$toolattr{'crslabeldiv'}.'" style="'.$labelstyle.'">'.
1.10 raeburn 531: '<span class="'.$class.'">'.&mt('Course label:').' '.
1.16 raeburn 532: '<input type="text" id="'.$toolattr{'crslabel'}.'" name="exttoollabel" value="'.$crslabel.'"'.$disabled.' /></span><br />'.
1.10 raeburn 533: '</div>'.
534: '<div id="'.$toolattr{'crstitlediv'}.'" style="'.$titlestyle.'">'.
535: '<span class="'.$class.'">'.&mt('Course title:').' '.
1.16 raeburn 536: '<input type="text" id="'.$toolattr{'crstitle'}.'" name="exttooltitle" value="'.$crstitle.'"'.$disabled.' /></span><br />'.
1.10 raeburn 537: '</div>';
1.9 raeburn 538: }
539: my $chooser = $toolelem;
540: if ($type eq 'ext') {
541: $chooser = "
542: <div>
543: <span$srcclass>
544: $extsrc
545: $urlelem
546: $preview
547: </span>
548: </div>
549: ";
550: }
1.3 raeburn 551: $form = <<ENDFORM;
1.9 raeburn 552: <form action="$action" method="post" name="$formname" id="$formid">
1.2 raeburn 553: <fieldset id="$fieldsetid" style="$fieldsetstyle">
1.1 raeburn 554: $legend
555: $active
1.9 raeburn 556: $chooser
557: <div>
1.1 raeburn 558: <span$srcclass>
559: $title
1.11 raeburn 560: <input type="text" size="$size" name="exttitle" value="$orig_title" $disabled />
1.1 raeburn 561: <input type="hidden" name="importdetail" value="" />
562: $pathitem
563: $hiddenelem
1.13 raeburn 564: <input type="button" value="$save" onclick="javascript:setExternal(this.form,'$residx','$type','$orig_url','$supplementalflag');" $disabled />
1.1 raeburn 565: </span>
1.9 raeburn 566: </div>
1.1 raeburn 567: </fieldset>
568: </form>
569: ENDFORM
1.3 raeburn 570: if (wantarray) {
571: return ($link,$form);
572: } else {
573: return $link.$form;
574: }
1.1 raeburn 575: }
576:
577: sub display_editor {
1.15 raeburn 578: my ($url,$folderpath,$symb,$idx,$type,$cdom,$cnum,$hostname) = @_;
1.12 raeburn 579: my ($residx,$supplementalflag,$title,$pathitem,$output,$js,$navmap);
1.1 raeburn 580: if ($folderpath =~ /^supplemental/) {
581: $supplementalflag = 1;
582: $residx = $idx;
583: $title = &unescape($env{'form.title'});
584: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($folderpath,'<>&"').'" />';
585: } elsif ($symb =~ /^uploaded/) {
586: (my $map,$residx,my $res) =
587: &Apache::lonnet::decode_symb($symb);
588: $title = &Apache::lonnet::gettitle($symb);
1.12 raeburn 589: my $path = &Apache::loncommon::symb_to_docspath($symb,\$navmap);
1.4 raeburn 590: $pathitem = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($path,'<>&"').'" />';
1.1 raeburn 591: }
1.9 raeburn 592: my %ltitools;
593: if ($type eq 'tool') {
594: %ltitools = &Apache::lonnet::get_domain_ltitools($cdom);
595: }
596: $js = &Apache::lonhtmlcommon::scripttag(&extedit_javascript());
1.1 raeburn 597: my $args = { 'force_register' => $env{'form.register'} };
1.15 raeburn 598: if ($hostname) {
599: $args->{'hostname'} = $hostname;
600: }
1.9 raeburn 601: my $description = 'External Resource Editor';
602: if ($type eq 'tool') {
603: $description = 'External Tool Editor';
604: }
605: return &Apache::loncommon::start_page($description,$js,$args).
1.1 raeburn 606: '<div class="LC_left_float">'.
1.9 raeburn 607: &extedit_form($supplementalflag,$residx,$url,$title,$pathitem,undef,'direct',
608: $symb,$type,$cdom,$cnum,\%ltitools).
1.1 raeburn 609: '</div>'.
610: &Apache::loncommon::end_page();
611: }
612:
613: sub extedit_javascript {
1.9 raeburn 614: my ($toolsref) = @_;
615: my $toolsjs;
616: if (ref($toolsref) eq 'HASH') {
617: my $num = scalar(keys(%{$toolsref}));
618: $toolsjs = " var ltitools = new Array($num);\n".
619: " var ltitoolsTarget = new Array($num);\n".
620: " var ltitoolsWidth = new Array($num);\n".
1.10 raeburn 621: " var ltitoolsHeight = new Array($num);\n".
1.16 raeburn 622: " var ltitoolsLinkDef = new Array($num);\n".
623: " var ltitoolsExplainDef = new Array($num);\n".
1.10 raeburn 624: " var ltitoolsDisplay = new Array($num);\n".
1.16 raeburn 625: " var ltitoolsLink = new Array($num);\n".
626: " var ltitoolsExplain = new Array($num);\n".
1.10 raeburn 627: " var ltitoolsLabel = new Array($num);\n".
628: " var ltitoolsTitle = new Array($num);\n";
1.9 raeburn 629: my $i = 0;
630: foreach my $key (sort { $a <=> $b } keys(%{$toolsref})) {
1.16 raeburn 631: if (ref($toolsref->{$key}) eq 'HASH') {
632: if (ref($toolsref->{$key}->{'display'}) eq 'HASH') {
633: my $target = $toolsref->{$key}->{'display'}->{'target'};
634: my $width = $toolsref->{$key}->{'display'}->{'width'};
635: my $height = $toolsref->{$key}->{'display'}->{'height'};
636: my $linkdef = $toolsref->{$key}->{'display'}->{'linktext'};
637: my $explaindef = $toolsref->{$key}->{'display'}->{'explanation'};
638: $toolsjs .= ' ltitools['.$i.'] = '."'$key';\n".
639: ' ltitoolsTarget['.$i.'] = '."'$target';\n".
640: ' ltitoolsWidth['.$i.'] = '."'$width';\n".
641: ' ltitoolsHeight['.$i.'] = '."'$height';\n".
642: ' ltitoolsLinkDef['.$i.'] = '."'$linkdef';\n".
643: ' ltitoolsExplainDef['.$i.'] = '."'$explaindef';\n";
644: }
1.10 raeburn 645: if (ref($toolsref->{$key}->{'crsconf'}) eq 'HASH') {
646: my $display = $toolsref->{$key}->{'crsconf'}->{'target'};
647: $toolsjs .= ' ltitoolsDisplay['.$i.'] = '."'$display';\n";
1.16 raeburn 648: my $linktext = $toolsref->{$key}->{'crsconf'}->{'linktext'};
649: $toolsjs .= ' ltitoolsLink['.$i.'] = '."'$linktext';\n";
650: my $explanation = $toolsref->{$key}->{'crsconf'}->{'explanation'};
651: $toolsjs .= ' ltitoolsExplain['.$i.'] = '."'$explanation';\n";
1.10 raeburn 652: my $label = $toolsref->{$key}->{'crsconf'}->{'label'};
653: $toolsjs .= ' ltitoolsLabel['.$i.'] = '."'$label';\n";
654: my $title = $toolsref->{$key}->{'crsconf'}->{'title'};
655: $toolsjs .= ' ltitoolsTitle['.$i.'] = '."'$title';\n";
656: }
1.9 raeburn 657: $i++;
658: }
659: }
660: }
1.8 damieng 661: my %js_lt = &Apache::lonlocal::texthash(
1.1 raeburn 662: invurl => 'Invalid URL',
663: titbl => 'Title is blank',
1.9 raeburn 664: invtool => 'Please select an external tool',
1.1 raeburn 665: );
1.8 damieng 666: &js_escape(\%js_lt);
1.1 raeburn 667:
668: my $urlregexp = <<'ENDREGEXP';
669: /^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
670: ENDREGEXP
671:
672: return <<ENDJS;
673:
674: var regexp = $urlregexp;
675:
1.10 raeburn 676: function setExternal(extform,residx,type,exttoolurl,supplementalflag) {
1.1 raeburn 677: var title=extform.exttitle.value;
678: if (!String.trim) {
679: String.prototype.trim = function() {return this.replace(\/^\\s+|\\s+$\/g, "");}; }
680: if (title == null || title.trim()=="") {
1.8 damieng 681: alert("$js_lt{'titbl'}");
1.1 raeburn 682: extform.exttitle.focus();
683: return;
684: }
1.9 raeburn 685: if (type == 'ext') {
686: var url=extform.exturl.value;
687: if (!regexp.test(url)) {
688: alert("$js_lt{'invurl'}");
689: extform.exturl.focus();
690: return;
691: } else {
692: url = escape(url);
693: title = escape(title);
694: if (residx > 0) {
695: eval("extform.importdetail.value=title+'='+url+'='+residx;extform.submit();");
696: } else {
697: eval("extform.importdetail.value=title+'='+url;extform.submit();");
698: }
699: }
700: } else {
1.7 raeburn 701: title = escape(title);
1.9 raeburn 702: var info = exttoolurl;
703: if (residx == 0) {
704: var toolid = parseInt(extform.exttoolid.options[extform.exttoolid.selectedIndex].value);
705: if (isNaN(toolid)) {
706: alert("$js_lt{'invtool'}");
707: return;
708: }
709: info += ':'+toolid;
710: }
1.10 raeburn 711: var prefix = '';
712: if (supplementalflag == 1) {
713: prefix = 'supp';
714: }
715: var dispdiv = prefix+'tooldispdiv';
1.16 raeburn 716: var windiv = prefix+'toolwindiv';
1.10 raeburn 717: if (residx > 0) {
718: dispdiv += '_'+residx;
1.16 raeburn 719: windiv += '_'+residx;
1.10 raeburn 720: }
721: if (document.getElementById(dispdiv)) {
722: if (document.getElementById(dispdiv).style.display == 'block') {
723: if (extform.exttooltarget.length) {
724: for (var i=0; i<extform.exttooltarget.length; i++) {
725: if (extform.exttooltarget[i].checked) {
726: if (extform.exttooltarget[i].value == 'window') {
727: var width = extform.exttoolwidth.value;
728: width.trim();
729: var height = extform.exttoolheight.value;
730: height.trim();
1.16 raeburn 731: info += ':window:'+width+':'+height;
1.10 raeburn 732: } else {
733: info += ':iframe::';
734: }
735: }
1.9 raeburn 736: }
737: }
1.10 raeburn 738: } else {
739: info += ':::';
1.9 raeburn 740: }
1.10 raeburn 741: } else {
742: info += ':::';
743: }
1.16 raeburn 744: if (document.getElementById(windiv)) {
745: if (document.getElementById(windiv).style.display == 'block') {
746: var linktextdiv = prefix+'toollinktextdiv';
747: var explanationdiv = prefix+'toolexplanationdiv';
748: if (residx > 0) {
749: linktextdiv += '_'+residx;
750: explanationdiv += '_'+residx;
751: }
752: if (document.getElementById(linktextdiv).style.display == 'inline') {
753: var linktext = extform.exttoollinktext.value;
754: linktext.trim();
755: info += ':'+escape(linktext);
756: } else {
757: info += ':';
758: }
759: if (document.getElementById(explanationdiv).style.display == 'inline') {
760: var explaintext = extform.exttoolexplanation.value;
761: explaintext.trim();
762: info += ':'+escape(explaintext);
763: } else {
764: info += ':';
765: }
766: } else {
767: info += '::';
768: }
769: } else {
770: info += '::';
771: }
1.10 raeburn 772: var labelinput = prefix+'toolcrslabel';
773: var titleinput = prefix+'toolcrstitle';
774: if (residx > 0) {
775: labelinput += '_'+residx;
776: titleinput += '_'+residx;
777: }
778: if (document.getElementById(labelinput)) {
779: var crslabel = document.getElementById(labelinput).value;
780: crslabel.trim();
781: info += ':'+escape(crslabel);
782: } else {
783: info += ':';
784: }
785: if (document.getElementById(titleinput)) {
786: var crstitle = document.getElementById(titleinput).value;
787: crstitle.trim();
788: info += ':'+escape(crstitle);
789: } else {
790: info += ':';
1.9 raeburn 791: }
792: info=escape(info);
1.1 raeburn 793: if (residx > 0) {
1.9 raeburn 794: eval("extform.importdetail.value=title+'='+info+'='+residx;extform.submit();");
1.1 raeburn 795: } else {
1.9 raeburn 796: eval("extform.importdetail.value=title+'='+info;extform.submit();");
1.1 raeburn 797: }
798: }
799: }
800:
1.9 raeburn 801: function editext(residx,type) {
802: if (document.getElementById('upload'+type+residx)) {
803: var curr = document.getElementById('upload'+type+residx).style.display;
1.1 raeburn 804: if (curr == 'none') {
805: disp = 'block';
806: } else {
807: disp = 'none';
808: }
1.9 raeburn 809: document.getElementById('upload'+type+residx).style.display=disp;
1.1 raeburn 810: }
811: resize_scrollbox('contentscroll','1','1');
812: return;
813: }
814:
1.14 raeburn 815: function extUrlPreview(caller,protocol) {
1.1 raeburn 816: if (document.getElementById(caller)) {
817: var url = document.getElementById(caller).value;
818: if (regexp.test(url)) {
1.14 raeburn 819: var http_regex = /^http\:\/\//gi;
820: if ((protocol == 'https') && (http_regex.test(url))) {
821: window.open(url,"externalpreview","height=400,width=500,scrollbars=1,resizable=1,menubar=0,location=1");
822: } else {
823: openMyModal(url,500,400,'yes');
824: }
1.1 raeburn 825: } else {
1.8 damieng 826: alert("$js_lt{'invurl'}");
1.1 raeburn 827: }
828: }
829: }
830:
1.9 raeburn 831: function updateExttool(caller,form,supplementalflag) {
832: var prefix = '';
833: if (supplementalflag == 1) {
834: prefix = 'supp';
835: }
836: dispdiv = prefix+'tooldispdiv';
837: dimendiv = prefix+'tooldimendiv';
1.16 raeburn 838: widthinput = prefix+'tooldimenwidth';
839: heightinput = prefix+'tooldimenheight';
1.10 raeburn 840: labeldiv = prefix+'toolcrslabeldiv';
841: titlediv = prefix+'toolcrstitlediv';
842: labelinput = prefix+'toolcrslabel';
843: titleinput = prefix+'toolcrstitle';
1.16 raeburn 844: windiv = prefix+'toolwindiv';
845: linktextdiv = prefix+'toollinktextdiv';
846: linktextinput = prefix+'toollinktext';
847: explanationdiv = prefix+'toolexplanationdiv';
848: explanationinput = prefix+'toolexplanation';
1.9 raeburn 849: if (document.getElementById(dispdiv)) {
850: var toolpick = caller.options[caller.selectedIndex].value;
851: $toolsjs
852: if (toolpick == '') {
853: if (document.getElementById(dispdiv)) {
854: document.getElementById(dispdiv).style.display = 'none';
855: }
856: if (document.getElementById(dimendiv)) {
857: document.getElementById(dimendiv).style.display = 'none';
858: }
1.16 raeburn 859: if (document.getElementById(windiv)) {
860: document.getElementById(windiv).style.display = 'none';
861: }
862: if (document.getElementById(linktextdiv)) {
863: document.getElementById(linktextdiv).style.display = 'none';
864: }
865: if (document.getElementById(explanationdiv)) {
866: document.getElementById(explanationdiv).style.display = 'none';
867: }
1.10 raeburn 868: if (document.getElementById(labeldiv)) {
869: document.getElementById(labeldiv).style.display = 'none';
870: }
871: if (document.getElementById(titlediv)) {
872: document.getElementById(titlediv).style.display = 'none';
873: }
1.9 raeburn 874: } else {
875: if (ltitools.length > 0) {
876: for (var j=0; j<ltitools.length; j++) {
877: if (ltitools[j] == toolpick) {
1.10 raeburn 878: if (document.getElementById(dispdiv)) {
879: if (ltitoolsDisplay[j]) {
880: document.getElementById(dispdiv).style.display = 'block';
881: if (form.exttooltarget.length) {
882: for (var k=0; k<form.exttooltarget.length; k++) {
883: if (form.exttooltarget[k].value == ltitoolsTarget[j]) {
884: form.exttooltarget[k].checked = true;
885: break;
886: }
887: }
888: }
1.16 raeburn 889: }
890: var dimen = 'none';
891: var dimenwidth = '';
892: var dimenheight = '';
893: if ((ltitoolsDisplay[j]) && (ltitoolsTarget[j] == 'window')) {
894: dimen = 'block';
895: dimenwidth = ltitoolsWidth[j];
896: dimenheight = ltitoolsHeight[j];
897: }
898: if (document.getElementById(dimendiv)) {
899: document.getElementById(dimendiv).style.display = dimen;
900: }
901: if (document.getElementById(widthinput)) {
902: document.getElementById(widthinput).value = dimenwidth;
903: }
904: if (document.getElementById(heightinput)) {
905: document.getElementById(heightinput).value = dimenheight;
906: }
907: }
908: if (document.getElementById(windiv)) {
909: if (ltitoolsTarget[j] == 'window') {
910: document.getElementById(windiv).style.display = 'block';
911: } else {
912: document.getElementById(windiv).style.display = 'none';
913: }
914: if (document.getElementById(linktextdiv)) {
1.17 raeburn 915: if (ltitoolsLink[j]) {
1.16 raeburn 916: document.getElementById(linktextdiv).style.display = 'inline';
1.10 raeburn 917: } else {
1.16 raeburn 918: document.getElementById(linktextdiv).style.display = 'none';
1.10 raeburn 919: }
1.16 raeburn 920: }
921: if (document.getElementById(linktextinput)) {
1.17 raeburn 922: if (ltitoolsLink[j]) {
1.16 raeburn 923: document.getElementById(linktextinput).value = ltitoolsLinkDef[j];
924: } else {
925: document.getElementById(linktextinput).value = '';
1.10 raeburn 926: }
1.16 raeburn 927: }
928: if (document.getElementById(explanationdiv)) {
1.17 raeburn 929: if (ltitoolsExplain[j]) {
1.16 raeburn 930: document.getElementById(explanationdiv).style.display = 'inline';
931: } else {
932: document.getElementById(explanationdiv).style.display = 'none';
1.10 raeburn 933: }
1.16 raeburn 934: }
935: if (document.getElementById(explanationinput)) {
1.17 raeburn 936: if (ltitoolsExplain[j]) {
1.16 raeburn 937: document.getElementById(explanationinput).value = ltitoolsExplainDef[j];
938: } else {
939: document.getElementById(explananationinput).value = '';
1.9 raeburn 940: }
941: }
942: }
1.10 raeburn 943: if (document.getElementById(labeldiv)) {
944: if (ltitoolsLabel[j]) {
945: document.getElementById(labeldiv).style.display = 'inline';
946: } else {
947: document.getElementById(labeldiv).style.display = 'none';
948: }
1.9 raeburn 949: }
1.10 raeburn 950: if (document.getElementById(titlediv)) {
951: if (ltitoolsTitle[j]) {
952: document.getElementById(titlediv).style.display = 'inline';
953: } else {
954: document.getElementById(titlediv).style.display = 'none';
955: }
1.9 raeburn 956: }
1.10 raeburn 957: break;
1.9 raeburn 958: }
959: }
960: }
961: }
962: }
963: }
964:
1.16 raeburn 965: function updateTooldim(form,dimendiv,windiv,widthinput,heightinput,linkinput,explaininput) {
1.9 raeburn 966: if (form.exttooltarget.length) {
967: for (var i=0; i<form.exttooltarget.length; i++) {
968: if (form.exttooltarget[i].checked) {
969: var dimen = 'none';
1.17 raeburn 970: var linkconf = 'none';
1.9 raeburn 971: if (form.exttooltarget[i].value == 'window') {
972: dimen = 'block';
1.16 raeburn 973: linkconf = 'block';
1.9 raeburn 974: } else {
975: if (document.getElementById(widthinput)) {
976: document.getElementById(widthinput).value = '';
977: }
978: if (document.getElementById(heightinput)) {
979: document.getElementById(heightinput).value = '';
980: }
1.16 raeburn 981: if (document.getElementById(linkinput)) {
982: document.getElementById(linkinput).value = '';
983: }
984: if (document.getElementById(explaininput)) {
985: document.getElementById(explaininput).value = '';
986: }
1.9 raeburn 987: }
988: if (document.getElementById(dimendiv)) {
989: document.getElementById(dimendiv).style.display = dimen;
990: }
1.16 raeburn 991: if (document.getElementById(windiv)) {
992: document.getElementById(windiv).style.display = linkconf;
1.17 raeburn 993: }
1.9 raeburn 994: break;
995: }
996: }
997: }
998: }
999:
1.1 raeburn 1000: ENDJS
1001:
1002: }
1003:
1004: 1;
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>