Annotation of rat/lonratedt.pm, revision 1.66
1.1 www 1: # The LearningOnline Network with CAPA
2: # Edit Handler for RAT Maps
1.5 www 3: #
1.66 ! albertel 4: # $Id: lonratedt.pm,v 1.65 2005/04/07 06:56:27 albertel Exp $
1.5 www 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: #
1.55 www 28:
1.1 www 29:
30: package Apache::lonratedt;
1.46 bowersj2 31:
32: =pod
33:
34: =head1 NAME
35:
36: Apache::lonratedt: advanced resource assembly tool
37:
38: =head1 SYNOPSIS
39:
40: lonratedt provides the routines and the handler for the Advanced
41: Resource Assembly Tool (RAT), and ties the various pieces together
42: with Javascript.
43:
44: =head1 OVERVIEW
45:
46: =head2 Map Representation
47:
48: =begin latex
49:
50: %
51: \begin{figure}
52: \begin{center}\includegraphics[%
53: width=0.55\paperwidth,bb = 0 0 200 100, draft, type=eps]{Map_Example}\end{center}
54:
55:
56: \caption{\label{Map_In_Advanced_Editor}Example of a Map in the Advanced Editor}
57: \end{figure}
58: %
59: \begin{figure}
60: \begin{lyxcode}
61: <map>
62:
63: ~~<resource~id=\char`\"{}1\char`\"{}
64:
65: ~~~~src=\char`\"{}/res/msu/korte/phy231welcome.html\char`\"{}
66:
67: ~~~~type=\char`\"{}start\char`\"{}
68:
69: ~~~~title=\char`\"{}Start\char`\"{}>
70:
71: ~~~~</resource>
72:
73: ~~<resource~id=\char`\"{}2\char`\"{}
74:
75: ~~~~src=\char`\"{}\char`\"{}~type=\char`\"{}finish\char`\"{}
76:
77: ~~~~title=\char`\"{}Finish\char`\"{}>
78:
79: ~~~~</resource>
80:
81: ~~<resource~id=\char`\"{}6\char`\"{}
82:
83: ~~~~src=\char`\"{}/res/msu/korte/tests/units.problem\char`\"{}
84:
85: ~~~~type=\char`\"{}mandatory\char`\"{}
86:
87: ~~~~title=\char`\"{}Physical~Units~Test\char`\"{}>
88:
89: ~~~~</resource>
90:
91: ~~<resource~id=\char`\"{}9\char`\"{}
92:
93: ~~~~src=\char`\"{}/res/msu/korte/chapters/onedim.sequence\char`\"{}
94:
95: ~~~~title=\char`\"{}Motion~in~One~Dimension\char`\"{}>
96:
97: ~~~~</resource>
98:
99: ~~<resource~id=\char`\"{}11\char`\"{}
100:
101: ~~~~src=\char`\"{}/res/msu/bauer/bridges/units.sequence\char`\"{}
102:
103: ~~~~title=\char`\"{}Physical~Units~Refresher\char`\"{}>
104:
105: ~~~~</resource>
106:
107: ~~<condition~id=\char`\"{}19\char`\"{}
108:
109: ~~~~type=\char`\"{}stop\char`\"{}
110:
111: ~~~~value=\char`\"{}user.assessments{[}this./res/msu/korte/tests/units.problem{]}.status=solved\char`\"{}>
112:
113: ~~~~</condition>
114:
115: ~~<link~from=\char`\"{}1\char`\"{}~to=\char`\"{}6\char`\"{}></link>
116:
117: ~~<link~from=\char`\"{}6\char`\"{}~to=\char`\"{}9\char`\"{}~condition=\char`\"{}19\char`\"{}></link>
118:
119: ~~<link~from=\char`\"{}6\char`\"{}~to=\char`\"{}11\char`\"{}></link>
120:
121: ~~<link~from=\char`\"{}11\char`\"{}~to=\char`\"{}6\char`\"{}></link>
122:
123: ~~</map>
124: \end{lyxcode}
125:
126: \caption{\label{XML}XML for Map in Figure \ref{Map_In_Advanced_Editor}}
127: \end{figure}
128:
129: =end latex
130:
131: Fig. "XML for Map in Figure" shows the XML representation of the
132: resource map shown in Fig. "Example of a Map in the Advanced Editor",
133: which is the format in which maps are stored. In the figure, however,
134: additional graphical map layout information generated by the Advanced
135: Resource Assembly Tool is not displayed. This graphical information is
136: optional to re-generate the same graphical layout when the map is
137: brought up again in the Resource Assembly Tool, and is not needed for
138: any other system functionality.
139:
140: Maps can be generated by tools other than the Resource Assembly
141: Tool. In particular, an author might have some other representation of
142: a course sequence, which can be converted into a map using scripts. If
143: this map then were to be brought up in the Resource Assembly Tool, the
144: Tool would automatically generate a graphical layout for it. Each
145: entry of the map (resources, conditions and links) is stored in a
146: separate tag.
147:
148: Resources and conditionsX<conditions> have to have unique ID
149: numbers. These numbers are automatically generated by the Resource
150: Assembly Tool when the entry is first created, or added to the entries
151: when a map generated outside the Resource Assembly Tool is first
152: retrieved. They can also be assigned by custom scripts or added in by
153: hand.
154:
155: In the XML example, entry 1 is the start resource of the map. When
156: this map is accessed, the source (src) URL of this tag will be the
157: first resource rendered. Entry 2 is the finish resource of this
158: map. This resource will be the last resource in the sequence of
159: resources. Entry 6 is a problem resource with the given URL and title,
160: as well as the priority "mandatory". Entry 19 is a condition, which is
161: used by the link between entries 6, the problem, and 9, a
162: sequence. I<The final syntax for conditions has not yet been
163: determined.>
164:
165: =cut
1.1 www 166:
167: use strict;
168: use Apache::Constants qw(:common);
1.3 www 169: use Apache::lonnet;
1.7 www 170: use Apache::lonratsrv;
1.30 www 171: use Apache::lonsequence;
1.34 www 172: use Apache::loncommon;
1.47 www 173: use Apache::lonlocal;
1.34 www 174: use File::Copy;
1.1 www 175:
1.54 www 176: use vars qw(@order @resources @resparms);
1.8 www 177:
178:
179: # Mapread read maps into global arrays @links and @resources, determines status
1.10 www 180: # sets @order - pointer to resources in right order
181: # sets @resources - array with the resources with correct idx
182: #
1.8 www 183: sub mapread {
184: my $fn=shift;
185:
1.10 www 186: my @links;
1.8 www 187: undef @links;
188: undef @resources;
1.10 www 189: undef @order;
1.58 www 190: undef @resparms;
1.23 www 191: @resources=('');
192: @order=();
1.58 www 193: @resparms=();
1.8 www 194:
195: my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,'');
196: if ($errtext) { return ($errtext,2); }
197:
1.9 www 198: # -------------------------------------------------------------------- Read map
1.8 www 199: foreach (split(/\<\&\>/,$outtext)) {
1.9 www 200: my ($command,$number,$content)=split(/\<\:\>/,$_);
1.8 www 201: if ($command eq 'objcont') {
1.9 www 202: $resources[$number]=$content;
1.8 www 203: }
204: if ($command eq 'objlinks') {
1.9 www 205: $links[$number]=$content;
1.31 www 206: }
207: if ($command eq 'objparms') {
1.55 www 208: if ($resparms[$number]) {
209: $resparms[$number].='&&&'.$content;
210: } else {
211: $resparms[$number]=$content;
212: }
1.9 www 213: }
214: }
215: # ------------------------------------------------------- Is this a linear map?
216: my @starters=();
217: my @endings=();
218: undef @starters;
219: undef @endings;
220:
221: foreach (@links) {
222: if (defined($_)) {
223: my ($start,$end,$cond)=split(/\:/,$_);
224: if ((defined($starters[$start])) || (defined($endings[$end]))) {
1.8 www 225: return
1.49 sakharuk 226: (&mt('Map has branchings. Use advanced editor.'),1);
1.8 www 227: }
1.9 www 228: $starters[$start]=1;
229: $endings[$end]=1;
230: if ($cond) {
1.8 www 231: return
1.49 sakharuk 232: (&mt('Map has conditions. Use advanced editor.'),1);
1.8 www 233: }
234: }
235:
236: }
1.23 www 237: for (my $i=1; $i<=$#resources; $i++) {
1.10 www 238: if (defined($resources[$i])) {
239: unless (($starters[$i]) || ($endings[$i])) {
240: return
1.49 sakharuk 241: (&mt('Map has unconnected resources. Use advanced editor.'),1);
1.10 www 242: }
243: }
244: }
1.38 www 245: # ---------------------------------------------- Did we just read an empty map?
246: if ($#resources<1) {
247: undef $resources[0];
248: $resources[1]=':::start';
249: $resources[2]=':::finish';
250: }
1.10 www 251: # -------------------------------------------------- This is a linear map, sort
252:
253: my $startidx=0;
254: my $endidx=0;
255: for (my $i=0; $i<=$#resources; $i++) {
256: if (defined($resources[$i])) {
257: my ($title,$url,$ext,$type)=split(/\:/,$resources[$i]);
258: if ($type eq 'start') { $startidx=$i; }
259: if ($type eq 'finish') { $endidx=$i; }
260: }
261: }
262: my $k=0;
263: my $currentidx=$startidx;
264: $order[$k]=$currentidx;
265: for (my $i=0; $i<=$#resources; $i++) {
266: foreach (@links) {
267: my ($start,$end)=split(/\:/,$_);
268: if ($start==$currentidx) {
269: $currentidx=$end;
270: $k++;
271: $order[$k]=$currentidx;
272: last;
273: }
274: }
275: if ($currentidx==$endidx) { last; }
276: }
1.8 www 277: return $errtext;
278: }
279:
1.16 www 280: # ---------------------------------------------- Read a map as well as possible
1.28 www 281: # Also used by the sequence handler
282: # Call lonsequence::attemptread to read from resource space
283: #
1.16 www 284: sub attemptread {
285: my $fn=shift;
286:
287: my @links;
288: undef @links;
289: my @theseres;
290: undef @theseres;
291:
292: my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,'');
293: if ($errtext) { return @theseres }
294:
295: # -------------------------------------------------------------------- Read map
296: foreach (split(/\<\&\>/,$outtext)) {
297: my ($command,$number,$content)=split(/\<\:\>/,$_);
298: if ($command eq 'objcont') {
299: $theseres[$number]=$content;
300: }
301: if ($command eq 'objlinks') {
302: $links[$number]=$content;
303: }
304: }
305:
306: # --------------------------------------------------------------- Sort, sort of
307:
1.17 www 308: my @objsort=();
309: undef @objsort;
1.16 www 310:
1.17 www 311: my @data1=();
312: my @data2=();
313: undef @data1;
314: undef @data2;
315:
316: my $k;
317: my $kj;
318: my $j;
319: my $ij;
320:
321: for ($k=1;$k<=$#theseres;$k++) {
322: if (defined($theseres[$k])) {
323: $objsort[$#objsort+1]=$k;
324: }
325: }
1.16 www 326:
1.17 www 327: for ($k=1;$k<=$#links;$k++) {
328: if (defined($links[$k])) {
329: @data1=split(/\:/,$links[$k]);
330: $kj=-1;
331: for (my $j=0;$j<=$#objsort;$j++) {
332: if ((split(/\:/,$objsort[$j]))[0]==$data1[0]) {
333: $kj=$j;
334: }
335: }
336: if ($kj!=-1) { $objsort[$kj].=':'.$data1[1]; }
337: }
338: }
339: for ($k=0;$k<=$#objsort;$k++) {
340: for ($j=0;$j<=$#objsort;$j++) {
341: if ($k!=$j) {
342: @data1=split(/\:/,$objsort[$k]);
343: @data2=split(/\:/,$objsort[$j]);
344: my $dol=$#data1+1;
345: my $dtl=$#data2+1;
346: if ($dol+$dtl<1000) {
347: for ($kj=1;$kj<$dol;$kj++) {
348: if ($data1[$kj]==$data2[0]) {
349: for ($ij=1;$ij<$dtl;$ij++) {
350: $data1[$#data1+1]=$data2[$ij];
351: }
352: }
353: }
354: for ($kj=1;$kj<$dtl;$kj++) {
355: if ($data2[$kj]==$data1[0]) {
356: for ($ij=1;$ij<$dol;$ij++) {
357: $data2[$#data2+1]=$data1[$ij];
358: }
359: }
360: }
361: $objsort[$k]=join(':',@data1);
362: $objsort[$j]=join(':',@data2);
363: }
364: }
365: }
366: }
367: # ---------------------------------------------------------------- Now sort out
1.16 www 368:
1.17 www 369: @objsort=sort {
370: my @data1=split(/\:/,$a);
371: my @data2=split(/\:/,$b);
372: my $rvalue=0;
373: my $k;
374: for ($k=1;$k<=$#data1;$k++) {
375: if ($data1[$k]==$data2[0]) { $rvalue--; }
376: }
377: for ($k=1;$k<=$#data2;$k++) {
378: if ($data2[$k]==$data1[0]) { $rvalue++; }
379: }
380: if ($rvalue==0) { $rvalue=$#data2-$#data1; }
381: $rvalue;
382: } @objsort;
383:
384: my @outres=();
385: undef @outres;
386:
387: for ($k=0;$k<=$#objsort;$k++) {
388: $outres[$k]=$theseres[(split(/\:/,$objsort[$k]))[0]];
389: }
390: return @outres;
1.16 www 391: }
392:
1.3 www 393: # --------------------------------------------------------- Build up RAT screen
394: sub ratedt {
395: my ($r,$url)=@_;
1.63 raeburn 396: my $frameset = '<frameset rows="1,70,*" border="0">';
1.65 albertel 397: if ($env{'environment.remote'} eq 'off') {
1.63 raeburn 398: $frameset = '<frameset rows="1,250,*" border="0">';
399: }
1.1 www 400: $r->print(<<ENDDOCUMENT);
401:
402: <html>
1.2 harris41 403: <head>
404: <script language="JavaScript">
405: var flag=0;
406: </script>
407: </head>
1.63 raeburn 408: $frameset
1.1 www 409: <frame name=server src="$url/loadonly/ratserver" noresize noscroll>
1.63 raeburn 410: <frame name=code src="$url/loadonly/adveditmenu">
1.1 www 411: <frame name=mapout src="/adm/rat/map.html">
412: </frameset>
413: </html>
414:
415: ENDDOCUMENT
1.3 www 416: }
417:
1.8 www 418: # ---------------------------------------------------------------- Make buttons
419:
420: sub buttons {
421: my $adv=shift;
422: my $output='<form method=post>';
423: if ($adv==1) {
1.52 www 424: $output.='<input type=submit name=forceadv value="'.&mt('Edit').'">'.
425: &Apache::loncommon::help_open_topic('Sequence_Advanced_Editor_Creation');;
1.8 www 426: } else {
427: unless ($adv==2) {
1.52 www 428: $output.='<input type=submit name=forcesmp value="'.&mt('Simple Edit').'">'.
429: &Apache::loncommon::help_open_topic('Sequence_Simple_Editor_Creation');
1.8 www 430: }
1.52 www 431: $output.='<input type=submit name=forceadv value="'.&mt('Advanced Edit').'">'.
432: &Apache::loncommon::help_open_topic('Sequence_Advanced_Editor_Creation');
1.8 www 433: }
434: return $output.'</form><hr>';
435: }
436:
1.20 www 437: # ----------------------------------------------------------- Paste into target
438: # modifies @order, @resources
439:
440: sub pastetarget {
441: my ($after,@which)=@_;
442: my @insertorder=();
443: foreach (@which) {
444: if (defined($_)) {
445: my ($name,$url)=split(/\=/,$_);
1.21 www 446: $name=&Apache::lonnet::unescape($name);
447: $url=&Apache::lonnet::unescape($url);
448: if ($url) {
449: my $idx=$#resources+1;
450: $insertorder[$#insertorder+1]=$idx;
451: my $ext='false';
452: if ($url=~/^http\:\/\//) { $ext='true'; }
453: $url=~s/\:/\:/g;
1.37 www 454: $name=~s/\:/\:/g;
1.21 www 455: $resources[$idx]=$name.':'.$url.':'.$ext.':normal:res';
456: }
1.20 www 457: }
458: }
1.23 www 459: my @oldorder=splice(@order,$after);
460: @order=(@order,@insertorder,@oldorder);
1.21 www 461: }
462:
463: # ------------------------------------------------ Get start and finish correct
464: # modifies @resources
465:
466: sub startfinish {
1.43 www 467: # Remove all start and finish
1.21 www 468: foreach (@order) {
469: my ($name,$url,$ext)=split(/\:/,$resources[$_]);
1.22 www 470: if ($url=~/http\&colon\:\/\//) { $ext='true'; }
1.21 www 471: $resources[$_]=$name.':'.$url.':'.$ext.':normal:res';
472: }
1.43 www 473: # Garbage collection
474: my $stillchange=1;
475: while (($#order>1) && ($stillchange)) {
476: $stillchange=0;
477: for (my $i=0;$i<=$#order;$i++) {
478: my ($name,$url,$ext)=split(/\:/,$resources[$order[$i]]);
479: unless ($url) {
480: # Take out empty resource
481: for (my $j=$i+1;$j<=$#order;$j++) {
482: $order[$j-1]=$order[$j];
483: }
484: $#order--;
485: $stillchange=1;
486: last;
487: }
488: }
489: }
490: # Put in a start resource
1.23 www 491: my ($name,$url,$ext)=split(/\:/,$resources[$order[0]]);
492: $resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res';
1.43 www 493: # Make sure this has at least start and finish
1.33 www 494: if ($#order==0) {
495: $resources[$#resources+1]='::false';
496: $order[1]=$#resources;
497: }
1.43 www 498: # Make the last one a finish resource
1.42 www 499: ($name,$url,$ext)=split(/\:/,$resources[$order[$#order]]);
1.21 www 500: $resources[$order[$#order]]=$name.':'.$url.':'.$ext.':finish:res';
1.20 www 501: }
502:
1.22 www 503: # ------------------------------------------------------------------- Store map
504:
505: sub storemap {
1.34 www 506: my $realfn=shift;
1.35 www 507: my $fn=$realfn;
508: # unless this is forced to work from the original file, use a temporary file
509: # instead
510: unless (shift) {
511: $fn=$realfn.'.tmp';
512: unless (-e $fn) {
513: copy($realfn,$fn);
514: }
1.34 www 515: }
1.35 www 516: # store data either into tmp or real file
1.22 www 517: &startfinish();
518: my $output='graphdef<:>no';
519: my $k=1;
520: for (my $i=0; $i<=$#order; $i++) {
521: if (defined($resources[$order[$i]])) {
522: $output.='<&>objcont<:>'.$order[$i].'<:>'.$resources[$order[$i]];
523: }
1.54 www 524: if (defined($resparms[$order[$i]])) {
1.55 www 525: foreach (split('&&&',$resparms[$order[$i]])) {
526: if ($_) {
527: $output.='<&>objparms<:>'.$order[$i].'<:>'.$_;
528: }
529: }
1.54 www 530: }
1.22 www 531: if (defined($order[$i+1])) {
532: if (defined($resources[$order[$i+1]])) {
533: $output.='<&>objlinks<:>'.$k.'<:>'.
534: $order[$i].':'.$order[$i+1].':0';
535: $k++;
536: }
537: }
538: }
1.23 www 539: $output=~s/http\&colon\;\/\///g;
1.65 albertel 540: $env{'form.output'}=$output;
1.22 www 541: return
542: &Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,''));
543: }
544:
1.56 www 545: # ------------------------------------------ Store and get parameters in global
546:
547: sub storeparameter {
548: my ($to,$name,$value,$ptype)=@_;
549: my $newentry='';
550: my $nametype='';
551: foreach (split('&&&',$resparms[$to])) {
552: my ($thistype,$thisname,$thisvalue)=split('___',$_);
553: if ($thisname) {
554: unless ($thisname eq $name) {
555: $newentry.=$_.'&&&';
556: } else {
557: $nametype=$thistype;
558: }
559: }
560: }
561: unless ($ptype) { $ptype=$nametype; }
562: unless ($ptype) { $ptype='string'; }
563: $newentry.=$ptype.'___'.$name.'___'.$value;
1.57 www 564: $resparms[$to]=$newentry;
565: }
566:
567: sub delparameter {
568: my ($to,$name)=@_;
569: my $newentry='';
570: my $nametype='';
571: foreach (split('&&&',$resparms[$to])) {
572: my ($thistype,$thisname,$thisvalue)=split('___',$_);
573: if ($thisname) {
574: unless ($thisname eq $name) {
575: $newentry.=$_.'&&&';
576: }
577: }
578: }
1.56 www 579: $resparms[$to]=$newentry;
580: }
581:
582: sub getparameter {
1.58 www 583: my ($to,$name)=@_;
1.56 www 584: my $value=undef;
585: my $ptype=undef;
586: foreach (split('&&&',$resparms[$to])) {
587: my ($thistype,$thisname,$thisvalue)=split('___',$_);
588: if ($thisname eq $name) {
589: $value=$thisvalue;
590: $ptype=$thistype;
591: }
592: }
593: return ($value,$ptype);
594: }
595:
596: # ----------------------------------------------------------------- Edit script
1.32 www 597: sub editscript {
598: my $mode=shift;
1.51 www 599: my $resurl=&Apache::loncommon::lastresurl();
1.32 www 600: return(<<ENDSCRIPT);
601: var srch;
602: var srchflag=-1; // 1 means currently open
603: // 0 means closed (but has been open)
604: // -1 means never yet opened/defined
605: var srchmode='';
606:
607: var idx;
608: var idxflag=-1; // 1 means currently open
609: // 0 means closed (but has been open)
610: // -1 means never yet opened/defined
611: var idxmode='';
612:
613: // ------------------------------------------------------ Clears indexer window
614: function idxclear() {
615: idx.document.clear();
616: }
617:
618: // ------------------------------------------------------- Clears search window
619: function srchclear() {
620: srch.document.clear();
621: }
622:
623: // ------------------------------------------------------ Closes indexer window
624: function idxclose() {
625: if (idx && !idx.closed) {
626: idxflag=0;
627: idx.close();
628: }
629: }
630:
631: // ------------------------------------------------------- Closes search window
632: function srchclose() {
633: if (srch && !srch.closed) {
634: srchflag=0;
635: srch.close();
636: }
637: }
638:
639: // -------------------------------------------------------- Open indexer window
640: function idxopen(mode) {
641: var options="scrollbars=1,resizable=1,menubar=0";
642: idxmode=mode;
643: idxflag=1;
1.51 www 644: idx=open("$resurl/?launch=1&mode=$mode&catalogmode="+mode,"idxout",options);
1.32 www 645: idx.focus();
646: }
647:
648: // --------------------------------------------------------- Open search window
649: function srchopen(mode) {
650: var options="scrollbars=1,resizable=1,menubar=0";
651: srchmode=mode;
652: srchflag=1;
653: srch=open("/adm/searchcat?launch=1&mode=$mode&catalogmode="+mode,"srchout",options);
654: srch.focus();
655: }
656: // ----------------------------------------------------- launch indexer browser
657: function groupsearch() {
658: srchcheck('groupsearch');
659: }
660:
661: function groupimport() {
662: idxcheck('groupimport');
663: }
664: // ------------------------------------------------------- Do srch status check
665: function srchcheck(mode) {
666: if (!srch || srch.closed || srchmode!=mode) {
667: srchopen(mode);
668: }
669: srch.focus();
670: }
671:
672: // -------------------------------------------------------- Do idx status check
673: function idxcheck(mode) {
674: if (!idx || idx.closed || idxmode!=mode) {
675: idxopen(mode);
676: }
677: idx.focus();
678: }
679:
680:
681: var editbrowser;
682: function openbrowser(formname,elementname,only,omit) {
1.51 www 683: var url = '$resurl/?';
1.32 www 684: if (editbrowser == null) {
685: url += 'launch=1&';
686: }
687: url += 'catalogmode=interactive&';
688: url += 'mode=edit&';
689: url += 'form=' + formname + '&';
690: if (only != null) {
691: url += 'only=' + only + '&';
692: }
693: if (omit != null) {
694: url += 'omit=' + omit + '&';
695: }
696: url += 'element=' + elementname + '';
697: var title = 'Browser';
698: var options = 'scrollbars=1,resizable=1,menubar=0';
699: options += ',width=700,height=600';
700: editbrowser = open(url,title,options,'1');
701: editbrowser.focus();
702: }
703: ENDSCRIPT
704: }
1.20 www 705: # ------------------------------------------------------- Simple edit processor
706:
1.3 www 707: sub smpedt {
1.22 www 708: my ($r,$url,$errtext)=@_;
1.8 www 709: my $buttons=&buttons(2);
1.34 www 710: my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp';
711: my $targetmsg='';
1.65 albertel 712: if ($env{'form.save'}) {
1.34 www 713: copy($tmpfn,&Apache::lonnet::filelocation('',$url));
714: unlink($tmpfn);
1.35 www 715: my ($errtext,$fatal)=
716: &mapread(&Apache::lonnet::filelocation('',$url),'');
1.60 www 717: unless ($fatal) {
718: $targetmsg='<b>'.&mt('Saved.').'</b><br />';
719: } else {
720: $targetmsg='<b>'.&mt('An error occured while saving.').'</b><br />';
721: }
1.34 www 722: }
1.65 albertel 723: if ($env{'form.revert'}) {
1.60 www 724: $targetmsg='<b>'.&mt('Reverted.').'</b><br />';
1.34 www 725: unlink($tmpfn);
1.35 www 726: my ($errtext,$fatal)=
727: &mapread(&Apache::lonnet::filelocation('',$url),'');
1.34 www 728: }
729: if (-e $tmpfn) {
730: $targetmsg=
1.49 sakharuk 731: '<b><font color="red">'.&mt('You are working with an unsaved version of your map.').'</font></b><br>';
1.34 www 732: my ($errtext,$fatal)=&mapread($tmpfn,'');
733: }
1.12 www 734: # ---------------------------------------------------------- Process form input
735:
1.66 ! albertel 736: my @importselect=&Apache::loncommon::get_env_multiple('form.importsel');
! 737: my @targetselect=&Apache::loncommon::get_env_multiple('form.target');
1.13 www 738: # ============================================================ Process commands
1.12 www 739:
1.65 albertel 740: my $targetdetail=$env{'form.targetdetail'};
741: my $importdetail=$env{'form.curimpdetail'};
1.13 www 742:
743: # ---------------------------------------------------- Importing from groupsort
1.65 albertel 744: if (($env{'form.importdetail'}) && (!$env{'form.impfortarget'})) {
1.13 www 745:
1.14 www 746: $importdetail='';
1.65 albertel 747: my @curimport=split(/\&/,$env{'form.curimpdetail'});
1.13 www 748:
749: my $lastsel;
750:
751: if (defined($importselect[-1])) {
752: $lastsel=$importselect[-1];
753: } else {
754: $lastsel=$#curimport;
755: }
756:
757: for (my $i=0;$i<=$lastsel;$i++) {
758: my ($name,$url)=split(/\=/,$curimport[$i]);
759: if ($url) {
1.18 www 760: $importdetail.='&'.$name.'='.$url;
1.13 www 761: }
762: }
763:
1.65 albertel 764: $importdetail.='&'.$env{'form.importdetail'};
1.13 www 765:
766: for (my $i=$lastsel+1;$i<=$#curimport;$i++) {
767: my ($name,$url)=split(/\=/,$curimport[$i]);
768: if ($url) {
1.18 www 769: $importdetail.='&'.$name.'='.$url;
1.13 www 770: }
771: }
772: $importdetail=~s/\&+/\&/g;
773: $importdetail=~s/^\&//;
774:
1.14 www 775: # ------------------------------------------------------------------- Clear all
1.65 albertel 776: } elsif ($env{'form.clear'}) {
1.14 www 777: $importdetail='';
778: # ------------------------------------------------------------ Discard selected
1.65 albertel 779: } elsif ($env{'form.discard'}) {
1.14 www 780: $importdetail='';
1.65 albertel 781: my @curimport=split(/\&/,$env{'form.curimpdetail'});
1.14 www 782: foreach (@importselect) {
783: $curimport[$_]='';
784: }
785: for (my $i=0;$i<=$#curimport;$i++) {
786: my ($name,$url)=split(/\=/,$curimport[$i]);
787: if ($url) {
1.18 www 788: $importdetail.='&'.$name.'='.$url;
1.14 www 789: }
790: }
1.17 www 791: # --------------------------------------------------------- Loading another map
1.65 albertel 792: } elsif ($env{'form.loadmap'}) {
1.17 www 793: $importdetail='';
1.65 albertel 794: my @curimport=split(/\&/,$env{'form.curimpdetail'});
1.17 www 795:
796: my $lastsel;
797:
798: if (defined($importselect[-1])) {
799: $lastsel=$importselect[-1];
800: } else {
801: $lastsel=$#curimport;
802: }
803:
804: for (my $i=0;$i<=$lastsel;$i++) {
805: my ($name,$url)=split(/\=/,$curimport[$i]);
806: if ($url) {
1.18 www 807: $importdetail.='&'.$name.'='.$url;
1.17 www 808: }
809: }
810:
811: foreach (
1.65 albertel 812: &Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
1.17 www 813: my ($name,$url)=split(/\:/,$_);
814: if ($url) {
815: $importdetail.='&'.&Apache::lonnet::escape($name).'='.
816: &Apache::lonnet::escape($url);
817: }
818: }
819:
820: for (my $i=$lastsel+1;$i<=$#curimport;$i++) {
821: my ($name,$url)=split(/\=/,$curimport[$i]);
822: if ($url) {
1.18 www 823: $importdetail.='&'.$name.'='.$url;
1.17 www 824: }
825: }
826: $importdetail=~s/\&+/\&/g;
827: $importdetail=~s/^\&//;
828:
1.20 www 829: # ------------------------------------------------ Groupimport/search to target
1.65 albertel 830: } elsif ($env{'form.importdetail'}) {
1.20 www 831: my $lastsel;
832: if (defined($targetselect[-1])) {
833: $lastsel=$targetselect[-1];
834: } else {
1.23 www 835: $lastsel=$#order+1;
1.20 www 836: }
1.65 albertel 837: &pastetarget($lastsel,split(/\&/,$env{'form.importdetail'}));
1.22 www 838: &storemap(&Apache::lonnet::filelocation('',$url));
1.20 www 839: # ------------------------------------------------------------------------- Cut
1.65 albertel 840: } elsif (($env{'form.cut'}) || ($env{'form.copy'})) {
1.25 www 841: $importdetail='';
1.65 albertel 842: my @curimport=split(/\&/,$env{'form.curimpdetail'});
1.25 www 843:
844: my $lastsel;
845:
846: if (defined($importselect[-1])) {
847: $lastsel=$importselect[-1];
848: } else {
849: $lastsel=$#curimport;
850: }
851:
852: for (my $i=0;$i<=$lastsel;$i++) {
853: my ($name,$url)=split(/\=/,$curimport[$i]);
854: if ($url) {
855: $importdetail.='&'.$name.'='.$url;
856: }
857: }
858:
859: foreach (@targetselect) {
860: my ($name,$url)=split(/\:/,$resources[$order[$_-1]]);
861: if ($url) {
862: $importdetail.='&'.&Apache::lonnet::escape($name).'='.
863: &Apache::lonnet::escape($url);
864: }
865: }
866:
867: for (my $i=$lastsel+1;$i<=$#curimport;$i++) {
868: my ($name,$url)=split(/\=/,$curimport[$i]);
869: if ($url) {
870: $importdetail.='&'.$name.'='.$url;
871: }
872: }
873: $importdetail=~s/\&+/\&/g;
874: $importdetail=~s/^\&//;
875:
1.65 albertel 876: if ($env{'form.cut'}) {
1.25 www 877: my @neworder=();
878: for (my $i=0;$i<=$#order;$i++) {
879: my $include=1;
880: foreach (@targetselect) {
881: if ($_-1==$i) { $include=0; }
882: }
883: if ($include) { $neworder[$#neworder+1]=$order[$i]; }
884: }
885: @order=@neworder;
886: &storemap(&Apache::lonnet::filelocation('',$url));
887: }
888:
1.20 www 889: # ----------------------------------------------------------------------- Paste
1.65 albertel 890: } elsif ($env{'form.paste'}) {
1.24 www 891: my $lastsel;
892: if (defined($targetselect[-1])) {
893: $lastsel=$targetselect[-1];
894: } else {
895: $lastsel=$#order+1;
896: }
897: my @newsequence;
1.65 albertel 898: my @curimport=split(/\&/,$env{'form.curimpdetail'});
1.24 www 899: foreach (@importselect) {
900: $newsequence[$#newsequence+1]=$curimport[$_];
901: }
902: &pastetarget($lastsel,@newsequence);
903: &storemap(&Apache::lonnet::filelocation('',$url));
1.39 www 904: # -------------------------------------------------------------------- Move up
1.65 albertel 905: } elsif ($env{'form.moveup'}) {
1.39 www 906: foreach (sort @targetselect) {
907: if ($_-1>0) {
908: my $movethis=$order[$_-1];
909: $order[$_-1]=$order[$_-2];
910: $order[$_-2]=$movethis;
911: }
912: }
913: &storemap(&Apache::lonnet::filelocation('',$url));
914: # ------------------------------------------------------------------ Move down
1.65 albertel 915: } elsif ($env{'form.movedown'}) {
1.39 www 916: foreach (reverse sort @targetselect) {
917: if ($_-1<$#order) {
918: my $movethis=$order[$_-1];
919: $order[$_-1]=$order[$_];
920: $order[$_]=$movethis;
921: }
922: }
923: &storemap(&Apache::lonnet::filelocation('',$url));
924: # --------------------------------------------------------------------- Rename
1.65 albertel 925: } elsif ($env{'form.renameres'}) {
926: my $residx=$Apache::lonratedt::order[$env{'form.renameidx'}-1];
1.39 www 927: my ($name,@resrest)=split(/\:/,$Apache::lonratedt::resources[$residx]);
1.65 albertel 928: $name=$env{'form.renametitle'};
1.40 www 929: $name=~s/\:/\&colon\;/g;
1.41 www 930: $Apache::lonratedt::resources[$residx]=$name.':'.join(':',@resrest);
1.39 www 931: &storemap(&Apache::lonnet::filelocation('',$url));
1.13 www 932: }
1.12 www 933: # ------------------------------------------------------------ Assemble windows
1.20 www 934:
1.13 www 935: my $idx=-1;
1.34 www 936: $importdetail='&'.$importdetail;
937: $importdetail=~s/^\&+/\&/;
1.29 www 938: my $importwindow=
1.50 sakharuk 939: '<option value="-1"> ---- '.&mt('Import and Paste Area').' ---- </option>'.
1.29 www 940: join("\n",map {
1.13 www 941: $idx++;
942: if ($_) {
1.15 www 943: my ($name,$url)=split(/\=/,$_);
944: unless ($name) { $name=(split(/\//,$url))[-1]; }
945: unless ($name) { $name='EMPTY'; }
1.13 www 946: '<option value="'.$idx.'">'.&Apache::lonnet::unescape($name).
947: '</option>';
948: }
949: } split(/\&/,$importdetail));
1.12 www 950:
1.13 www 951: $idx=0;
1.39 www 952: $targetdetail='';
1.29 www 953: my $targetwindow=
1.49 sakharuk 954: '<option value="0"> ------- '.&mt('Target Edit Map').' ------- </option>'.
1.29 www 955: join("\n",map {
1.13 www 956: my ($name,$url)=split(/\:/,$resources[$_]);
1.15 www 957: unless ($name) { $name=(split(/\//,$url))[-1]; }
958: unless ($name) { $name='EMPTY'; }
1.13 www 959: $targetdetail.='&'.&Apache::lonnet::escape($name).'='.
960: &Apache::lonnet::escape($url);
961: $idx++;
1.37 www 962: $name=~s/\:/\:/g;
1.20 www 963: '<option value="'.$idx.'">'.$name.'</option>';
1.11 www 964: } @order);
965:
1.8 www 966: # ----------------------------------------------------- Start simple RAT screen
1.32 www 967: my $editscript=&editscript('simple');
1.61 albertel 968: my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,
1.65 albertel 969: ($env{'environment.remote'} ne 'off')).
1.59 albertel 970: &Apache::loncommon::help_open_menu('','Sequence_Simple_Editor_Creation','Sequence_Simple_Editor_Creation','',6,'RAT');
1.47 www 971: my %lt=&Apache::lonlocal::texthash(
972: 'sa' => 'Save',
973: 'nt' => 'New Title',
974: 'se' => 'Search',
975: 'im' => 'Import',
976: 'vi' => 'View',
977: 'lm' => 'Load Map',
978: 'ds' => 'Discard Selected',
979: 'ca' => 'Clear All',
980: 'ta' => 'Temporary Assembly Workspace',
981: 'rv' => 'Revert to Last Saved',
982: 'sa' => 'Save',
983: 'mu' => 'Move Up',
984: 'md' => 'Move Down',
985: 're' => 'Rename',
1.49 sakharuk 986: 'as' => 'after selected',
987: 'cs' => 'Cut selected',
988: 'ps' => 'Copy selected',
989: 'pas' => 'Paste after selected',
1.47 www 990: );
1.3 www 991: $r->print(<<ENDSMPHEAD);
992: <html>
1.6 www 993: <head>
994: <script>
1.15 www 995:
1.32 www 996: $editscript
1.19 www 997:
998: function openview(entry) {
999: var url=unescape((entry.split('='))[1]);
1.20 www 1000: var parts=new Array;
1001: parts=url.split(':');
1002: url=parts.join(':');
1.19 www 1003: if (url) { open(url,'cat'); }
1004: }
1005:
1006: function viewtarget() {
1007: openview((document.forms.simpleedit.targetdetail.value.split('&'))
1.34 www 1008: [document.forms.simpleedit.target.selectedIndex]);
1.19 www 1009: }
1010:
1011: function viewimport() {
1012: openview((document.forms.simpleedit.curimpdetail.value.split('&'))
1.34 www 1013: [document.forms.simpleedit.importsel.selectedIndex]);
1.19 www 1014: }
1015:
1.39 www 1016: function renametarget() {
1017: var selidx=document.forms.simpleedit.target.selectedIndex;
1018: var entry=(document.forms.simpleedit.targetdetail.value.split('&'))
1019: [selidx];
1.41 www 1020: var oldname=unescape((entry.split('='))[0]);
1021: var nameparts=oldname.split(':');
1022: oldname=unescape(nameparts.join(':'));
1023: nameparts=oldname.split('"');
1024: oldname=unescape(nameparts.join('"'));
1025: nameparts=oldname.split(''');
1026: oldname=unescape(nameparts.join("'"));
1.47 www 1027: newtitle=prompt('$lt{'nt'}',oldname);
1.39 www 1028: if (newtitle) {
1029: document.forms.simpleedit.renameres.value=1;
1030: document.forms.simpleedit.renameidx.value=selidx;
1031: document.forms.simpleedit.renametitle.value=newtitle;
1032: document.forms.simpleedit.submit();
1033: }
1034: }
1035:
1.6 www 1036: </script>
1037: </head>
1.34 www 1038: $bodytag
1.8 www 1039: $buttons
1.7 www 1040: <font color=red>$errtext</font>
1.13 www 1041: <form name=simpleedit method=post>
1.11 www 1042: <input type=hidden name=forcesmp value=1>
1.39 www 1043: <input type=hidden name=renameres value=0>
1044: <input type=hidden name=renametitle value=''>
1045: <input type=hidden name=renameidx value=0>
1.11 www 1046: <table>
1.47 www 1047: <tr><th width="40%">$lt{'ta'}</th>
1.12 www 1048: <th> </th>
1.37 www 1049: <th width="40%">File: $url</th></tr>
1.12 www 1050: <tr><td bgcolor="#FFFFCC">
1.47 www 1051: <input type=button onClick="javascript:groupsearch()" value="$lt{'se'}">
1052: <input type=button onClick="javascript:groupimport();" value="$lt{'im'}">
1.49 sakharuk 1053: $lt{'as'}
1.14 www 1054: <hr>
1.15 www 1055: <input type=text size=20 name=importmap>
1056: <input type=button
1057: onClick="javascript:openbrowser('simpleedit','importmap','sequence,page','')"
1.47 www 1058: value="Select Map"><input type=submit name=loadmap value="$lt{'lm'}"><hr>
1059: <input type=submit name="discard" value="$lt{'ds'}">
1060: <input type=submit name="clear" value="$lt{'ca'}">
1061: <input type=button onClick="javascript:viewimport()" value="$lt{'vi'}">
1.16 www 1062:
1.12 www 1063: </td><td> </td><td bgcolor="#FFFFCC">
1.16 www 1064:
1065: <input type=button onClick=
1.47 www 1066: "javascript:impfortarget.value=1;groupsearch()" value="$lt{'se'}">
1.16 www 1067: <input type=button onClick=
1.47 www 1068: "javascript:impfortarget.value=1;groupimport();" value="$lt{'im'}">
1.49 sakharuk 1069: $lt{'as'}
1.39 www 1070: <hr>
1.47 www 1071: <input type=submit name="moveup" value="$lt{'mu'}">
1072: <input type=submit name="movedown" value="$lt{'md'}">
1073: <input type=button onClick="javascript:renametarget()" value="$lt{'re'}">
1.34 www 1074: <hr>$targetmsg
1.47 www 1075: <input type=submit name="revert" value="$lt{'rv'}">
1076: <input type=submit name="save" value="$lt{'sa'}">
1077: <input type=button onClick="javascript:viewtarget()" value="$lt{'vi'}">
1.12 www 1078: </td></tr>
1.16 www 1079:
1.27 www 1080: <tr><td bgcolor="#FFFFCC"><select name="importsel" size=10 multiple>
1.12 www 1081: $importwindow
1082: </select>
1.11 www 1083: </td>
1.12 www 1084: <td bgcolor="#FFFFAA" align="center">
1.49 sakharuk 1085: $lt{'cs'}<br>
1.11 www 1086: <input type=submit name=cut value='<<<'><p>
1.12 www 1087: <hr>
1.49 sakharuk 1088: $lt{'ps'}<br>
1.25 www 1089: <input type=submit name=copy value='<--'><p>
1090: <hr>
1.49 sakharuk 1091: $lt{'pas'}<br>
1.25 www 1092: <input type=submit name=paste value='-->'>
1.11 www 1093: </td>
1.27 www 1094: <td bgcolor="#FFFFCC"><select name="target" size=10 multiple>
1.11 www 1095: $targetwindow
1096: </select>
1.12 www 1097: </table>
1.13 www 1098: <input type=hidden name=importdetail value="">
1099: <input type=hidden name=curimpdetail value="$importdetail">
1.12 www 1100: <input type=hidden name=targetdetail value="$targetdetail">
1.16 www 1101: <input type=hidden name=impfortarget value="0">
1.12 www 1102: </form>
1103: </body></html>
1.3 www 1104: ENDSMPHEAD
1105: }
1106:
1.11 www 1107: # ----------------------------------------------------------------- No such dir
1.4 www 1108: sub nodir {
1109: my ($r,$dir)=@_;
1110: $dir=~s/^\/home\/\w+\/public\_html//;
1111: $r->print(<<ENDNODIR);
1112: <html>
1113: <body bgcolor='#FFFFFF'>
1114: <h1>No such directory: $dir</h1>
1115: </body>
1116: </html>
1117: ENDNODIR
1118: }
1119:
1.8 www 1120: # ---------------------------------------------------------------- View Handler
1121:
1122: sub viewmap {
1.17 www 1123: my ($r,$url,$adv,$errtext)=@_;
1.34 www 1124: $r->print('<html>'.
1125: &Apache::loncommon::bodytag('Edit Content of a Map').
1.59 albertel 1126: &Apache::loncommon::help_open_menu('','','','',6,'RAT').
1.53 www 1127: &buttons($adv));
1.10 www 1128: if ($errtext) {
1.53 www 1129: $r->print($errtext.'<hr />');
1.10 www 1130: }
1.26 www 1131: my $idx=0;
1.34 www 1132: $r->print('<h1>'.$url.'</h1>');
1.44 www 1133: if ($adv) {
1.47 www 1134: $r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />');
1.44 www 1135: }
1.64 raeburn 1136: $r->print( '<table border="0" cellspacing="2" cellpadding="4">'.
1137: '<tr bgcolor="#DDDDDD"><th>'.&mt('Type').'</th>'.
1138: '<th>'.&mt('Title in map').'</th>'.
1139: '<th>'.&mt('Filename of resource').'</th>'.
1140: '<th>'.&mt('Link to published resource').'</th>'.
1141: '<th>'.&mt('Link to resource in Construction Space').'</th>'.
1142: '</tr>');
1143: my @backgroundColors = ("#FFFFFF", "#F6F6F6");
1.17 www 1144: foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {
1.9 www 1145: if (defined($_)) {
1.26 www 1146: $idx++;
1.62 albertel 1147: my ($title,$url,$cond)=split(/\:/,$_);
1148: if ($cond eq 'cond') { next; }
1.9 www 1149: $title=~s/\&colon\;/\:/g;
1150: $url=~s/\&colon\;/\:/g;
1.15 www 1151: unless ($title) { $title=(split(/\//,$url))[-1] };
1.64 raeburn 1152: unless ($title) { $title='<i>'.&mt('Empty').'</i>'; }
1153: my $resurl = &Apache::lonratsrv::qtescape($url);
1154: my $resfilepath = $Apache::lonnet::perlvar{'lonDocRoot'}.$resurl;
1155: my $filename;
1156: if ($resurl =~ m#/([^/]+)$#) {
1157: $filename = $1;
1158: }
1159: my $cstrurl = $resurl;
1160: $cstrurl =~ s#^/res/[^/]+/([^/]+)/#/priv/$1/#;
1161: my $bgcol = $idx%2;
1162: $r->print('<tr bgcolor='.$backgroundColors[$bgcol].'><td>'.
1163: '<img src="'.&Apache::loncommon::icon($resfilepath).
1164: '" /></td><td>'.&Apache::lonratsrv::qtescape($title).
1165: '</td><td>'.$filename.'</td><td>');
1166: if ($url) {
1167: if (-e $resfilepath) {
1168: $r->print('<a href="'.$resurl.'">'.&mt('Resource space').'</a>');
1169: } else {
1170: $r->print(&mt('unpublished'));
1171: }
1172: }
1173: $r->print('</td><td>');
1.9 www 1174: if ($url) {
1.64 raeburn 1175: $r->print('<a href="'.$cstrurl.'">'.
1176: &mt('Construction space').'</a>');
1.9 www 1177: }
1.64 raeburn 1178: $r->print('</td></tr>'."\n");
1.9 www 1179: }
1180: }
1.64 raeburn 1181: $r->print('</table>');
1.8 www 1182: $r->print('</body></html>');
1183: }
1184:
1.3 www 1185: # ================================================================ Main Handler
1186:
1187: sub handler {
1188: my $r=shift;
1.47 www 1189: &Apache::loncommon::content_type($r,'text/html');
1.3 www 1190: $r->send_http_header;
1191:
1192: return OK if $r->header_only;
1.65 albertel 1193: my $target = $env{'form.grade_target'};
1.48 albertel 1194: if ($target eq 'meta') {
1195: &Apache::loncommon::content_type($r,'text/html');
1196: $r->send_http_header;
1197: return OK;
1198: }
1199:
1.3 www 1200: my $url=$r->uri;
1201: my $fn=&Apache::lonnet::filelocation('',$url);
1202:
1.4 www 1203: my ($dir)=($fn=~/^(.+)\/[^\/]+$/);
1204: unless (-e $dir) {
1205: &nodir($r,$dir);
1206: return OK;
1207: }
1.8 www 1208:
1209: # ------------------------------------------- Determine which tools can be used
1.3 www 1210: my $adv=0;
1211:
1.65 albertel 1212: unless ($env{'form.forcesmp'}) {
1213: if ($env{'form.forceadv'}) {
1.3 www 1214: $adv=1;
1215: } elsif (my $fh=Apache::File->new($fn)) {
1216: my $allmap=join('',<$fh>);
1217: $adv=($allmap=~/\<map[^\>]+mode\s*\=\s*(\'|\")rat/is);
1218: }
1219: }
1220:
1.8 www 1221: my $errtext='';
1222: my $fatal=0;
1223:
1224: # -------------------------------------------------------------------- Load map
1225: ($errtext,$fatal)=&mapread($fn,$errtext);
1226:
1227: if ($fatal==1) { $adv=1; }
1228:
1229: # ----------------------------------- adv==1 now means "graphical MUST be used"
1230:
1.65 albertel 1231: if ($env{'form.forceadv'}) {
1.3 www 1232: &ratedt($r,$url);
1.65 albertel 1233: } elsif ($env{'form.forcesmp'}) {
1.22 www 1234: &smpedt($r,$url,$errtext);
1.3 www 1235: } else {
1.17 www 1236: &viewmap($r,$url,$adv,$errtext);
1.3 www 1237: }
1.1 www 1238: return OK;
1239: }
1240:
1241: 1;
1242: __END__
1243:
1244:
1245:
1246:
1247:
1248:
1249:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>