Diff for /rat/lonratedt.pm between versions 1.51 and 1.81

version 1.51, 2004/01/02 21:00:56 version 1.81, 2006/06/26 22:47:35
Line 25 Line 25
 #  #
 # http://www.lon-capa.org/  # http://www.lon-capa.org/
 #  #
 # (TeX Content Handler  
 #  
 # 05/29/00,05/30 Gerd Kortemeyer)  
 # 7/1,6/30 Gerd Kortemeyer  
   
 package Apache::lonratedt;  package Apache::lonratedt;
   
Line 36  package Apache::lonratedt; Line 33  package Apache::lonratedt;
   
 =head1 NAME  =head1 NAME
   
 Apache::lonratedt: advanced resource assembly tool  Apache::lonratedt: simple resource assembly tool
   
 =head1 SYNOPSIS  =head1 SYNOPSIS
   
Line 175  use Apache::lonsequence; Line 172  use Apache::lonsequence;
 use Apache::loncommon;  use Apache::loncommon;
 use Apache::lonlocal;  use Apache::lonlocal;
 use File::Copy;  use File::Copy;
   use lib '/home/httpd/lib/perl/';
   use LONCAPA;
    
   
 use vars qw(@order @resources);  use vars qw(@order @resources @resparms @zombies);
   
   
 # Mapread read maps into global arrays @links and @resources, determines status  # Mapread read maps into global arrays @links and @resources, determines status
Line 190  sub mapread { Line 190  sub mapread {
     undef @links;      undef @links;
     undef @resources;      undef @resources;
     undef @order;      undef @order;
       undef @resparms;
       undef @zombies;
   
     @resources=('');      @resources=('');
     @order=();      @order=();
       @resparms=();
       @zombies=();
   
     my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,'');      my ($outtext,$errtext)=&Apache::lonratsrv::loadmap($fn,'');
     if ($errtext) { return ($errtext,2); }      if ($errtext) { return ($errtext,2); }
Line 200  sub mapread { Line 205  sub mapread {
     foreach (split(/\<\&\>/,$outtext)) {      foreach (split(/\<\&\>/,$outtext)) {
  my ($command,$number,$content)=split(/\<\:\>/,$_);   my ($command,$number,$content)=split(/\<\:\>/,$_);
         if ($command eq 'objcont') {          if ($command eq 'objcont') {
     $resources[$number]=$content;      my ($title,$src,$ext,$type)=split(/\:/,$content);
       if ($ext eq 'cond') { next; }
       if ($type ne 'zombie') {
    $resources[$number]=$content;
       } else {
    $zombies[$number]=$content;
       }
         }          }
         if ($command eq 'objlinks') {          if ($command eq 'objlinks') {
             $links[$number]=$content;              $links[$number]=$content;
         }          }
         if ($command eq 'objparms') {          if ($command eq 'objparms') {
     return(&mt('Map has resource parameters. Use advanced editor.'),1);      if ($resparms[$number]) {
    $resparms[$number].='&&&'.$content;
       } else {
    $resparms[$number]=$content;
       }
         }          }
     }      }
 # ------------------------------------------------------- Is this a linear map?  # ------------------------------------------------------- Is this a linear map?
Line 293  sub attemptread { Line 308  sub attemptread {
     foreach (split(/\<\&\>/,$outtext)) {      foreach (split(/\<\&\>/,$outtext)) {
  my ($command,$number,$content)=split(/\<\:\>/,$_);   my ($command,$number,$content)=split(/\<\:\>/,$_);
         if ($command eq 'objcont') {          if ($command eq 'objcont') {
     $theseres[$number]=$content;      my ($title,$src,$ext,$type)=split(/\:/,$content);
       unless ($type eq 'zombie') {
    $theseres[$number]=$content;
       }
         }          }
         if ($command eq 'objlinks') {          if ($command eq 'objlinks') {
             $links[$number]=$content;              $links[$number]=$content;
Line 390  sub attemptread { Line 408  sub attemptread {
 # --------------------------------------------------------- Build up RAT screen  # --------------------------------------------------------- Build up RAT screen
 sub ratedt {  sub ratedt {
   my ($r,$url)=@_;    my ($r,$url)=@_;
   $r->print(<<ENDDOCUMENT);    my %layout = ('border' => "0");
       if ($env{'environment.remote'} eq 'off') {
 <html>        $layout{'rows'} = "1,250,*";
 <head>    } else {
 <script language="JavaScript">        $layout{'rows'} = "1,70,*";
     }
     my $js ='
   <script type="text/javascript">
     var flag=0;      var flag=0;
 </script>  </script>';
 </head>  
 <frameset rows="1,50,*" border=0>    my $start_page = 
 <frame name=server src="$url/loadonly/ratserver" noresize noscroll>        &Apache::loncommon::start_page('Edit Sequence',$js,
 <frame name=code src="/adm/rat/code.html">       {'frameset'    => 1,
 <frame name=mapout src="/adm/rat/map.html">        'add_entries' => \%layout});
 </frameset>    my $end_page = 
 </html>        &Apache::loncommon::end_page({'frameset' => 1});
   
     $r->print(<<ENDDOCUMENT);
   $start_page
   <frame name="server" src="$url/loadonly/ratserver" noresize="noresize"
          noscroll="noscroll" />
   <frame name="code" src="$url/loadonly/adveditmenu" />
   <frame name="mapout" src="/adm/rat/map.html" />
   $end_page
 ENDDOCUMENT  ENDDOCUMENT
 }  }
   
Line 414  sub buttons { Line 442  sub buttons {
     my $adv=shift;      my $adv=shift;
     my $output='<form method=post>';           my $output='<form method=post>';     
     if ($adv==1) {      if ($adv==1) {
  $output.='<input type=submit name=forceadv value="'.&mt('Edit').'">';   $output.='<input type=submit name=forceadv value="'.&mt('Edit').'">'.
       &Apache::loncommon::help_open_topic('Sequence_Advanced_Editor_Creation');;
     } else {      } else {
         unless ($adv==2) {          unless ($adv==2) {
            $output.='<input type=submit name=forcesmp value="'.&mt('Simple Edit').'">';             $output.='<input type=submit name=forcesmp value="'.&mt('Simple Edit').'">'.
       &Apache::loncommon::help_open_topic('Sequence_Simple_Editor_Creation');
         }          }
  $output.='<input type=submit name=forceadv value="'.&mt('Advanced Edit').'">';   $output.='<input type=submit name=forceadv value="'.&mt('Advanced Edit').'">'.
       &Apache::loncommon::help_open_topic('Sequence_Advanced_Editor_Creation');
     }      }
     return $output.'</form><hr>';      return $output.'</form><hr>';
 }  }
   
   # ------------------------------------- Revive zombie idx or get unused number
   
   sub getresidx {
       my $url=shift;
       my $max=1+($#resources>$#zombies?$#resources:$#zombies);
       unless ($url) { return $max; }
       for (my $i=0; $i<=$#zombies; $i++) {
    my ($title,$src,$ext,$type)=split(/\:/,$zombies[$i]);
    if ($src eq $url) {
       undef $zombies[$i];
       return $i;
    }
       }
       return $max;
   }
   
   # --------------------------------------------------------------- Make a zombie
   
   sub makezombie {
       my $idx=shift;
       my ($name,$url,$ext)=split(/\:/,$resources[$idx]);
       my $now=time;
       $zombies[$idx]=$name.
    ' [('.$now.','.$env{'user.name'}.','.$env{'user.domain'}.')]:'.
    $url.':'.$ext.':zombie';
   }
   
 # ----------------------------------------------------------- Paste into target  # ----------------------------------------------------------- Paste into target
 # modifies @order, @resources  # modifies @order, @resources
   
Line 433  sub pastetarget { Line 491  sub pastetarget {
     foreach (@which) {      foreach (@which) {
         if (defined($_)) {          if (defined($_)) {
     my ($name,$url)=split(/\=/,$_);      my ($name,$url)=split(/\=/,$_);
             $name=&Apache::lonnet::unescape($name);              $name=&unescape($name);
             $url=&Apache::lonnet::unescape($url);              $url=&unescape($url);
             if ($url) {              if ($url) {
        my $idx=$#resources+1;         my $idx=&getresidx($url);
                $insertorder[$#insertorder+1]=$idx;                 $insertorder[$#insertorder+1]=$idx;
                my $ext='false';                 my $ext='false';
                if ($url=~/^http\:\/\//) { $ext='true'; }                 if ($url=~/^http\:\/\//) { $ext='true'; }
Line 482  sub startfinish { Line 540  sub startfinish {
    $resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res';     $resources[$order[0]]=$name.':'.$url.':'.$ext.':start:res';
 # Make sure this has at least start and finish  # Make sure this has at least start and finish
    if ($#order==0) {     if ($#order==0) {
        $resources[$#resources+1]='::false';         $resources[&getresidx()]='::false';
        $order[1]=$#resources;         $order[1]=$#resources;
    }     }
 # Make the last one a finish resource  # Make the last one a finish resource
Line 511  sub storemap { Line 569  sub storemap {
         if (defined($resources[$order[$i]])) {          if (defined($resources[$order[$i]])) {
     $output.='<&>objcont<:>'.$order[$i].'<:>'.$resources[$order[$i]];      $output.='<&>objcont<:>'.$order[$i].'<:>'.$resources[$order[$i]];
         }          }
    if (defined($resparms[$order[$i]])) {
       foreach (split('&&&',$resparms[$order[$i]])) {
    if ($_) {
       $output.='<&>objparms<:>'.$order[$i].'<:>'.$_;
    }
       }
    }
         if (defined($order[$i+1])) {          if (defined($order[$i+1])) {
     if (defined($resources[$order[$i+1]])) {      if (defined($resources[$order[$i+1]])) {
                $output.='<&>objlinks<:>'.$k.'<:>'.                 $output.='<&>objlinks<:>'.$k.'<:>'.
Line 519  sub storemap { Line 584  sub storemap {
             }              }
         }          }
     }      }
       for (my $i=0; $i<=$#zombies; $i++) {
           if (defined($zombies[$i])) {
       $output.='<&>objcont<:>'.$i.'<:>'.$zombies[$i];
           }
       }
     $output=~s/http\&colon\;\/\///g;      $output=~s/http\&colon\;\/\///g;
     $ENV{'form.output'}=$output;      $env{'form.output'}=$output;
     return       return 
      &Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,''));       &Apache::lonratsrv::loadmap($fn,&Apache::lonratsrv::savemap($fn,''));
 }  }
   
   # ------------------------------------------ Store and get parameters in global
   
   sub storeparameter {
       my ($to,$name,$value,$ptype)=@_;
       my $newentry='';
       my $nametype='';
       foreach (split('&&&',$resparms[$to])) {
    my ($thistype,$thisname,$thisvalue)=split('___',$_);
    if ($thisname) {
       unless ($thisname eq $name) {
    $newentry.=$_.'&&&';
       } else {
    $nametype=$thistype;
       }
    }
       }
       unless ($ptype) { $ptype=$nametype; }
       unless ($ptype) { $ptype='string'; }
       $newentry.=$ptype.'___'.$name.'___'.$value;
       $resparms[$to]=$newentry;
   }
   
   sub delparameter {
       my ($to,$name)=@_;
       my $newentry='';
       my $nametype='';
       foreach (split('&&&',$resparms[$to])) {
    my ($thistype,$thisname,$thisvalue)=split('___',$_);
    if ($thisname) {
       unless ($thisname eq $name) {
    $newentry.=$_.'&&&';
       }
    }
       }
       $resparms[$to]=$newentry;
   }
   
   sub getparameter {
       my ($to,$name)=@_;
       my $value=undef;
       my $ptype=undef;
       foreach (split('&&&',$resparms[$to])) {
    my ($thistype,$thisname,$thisvalue)=split('___',$_);
    if ($thisname eq $name) {
       $value=$thisvalue;
       $ptype=$thistype;
    }
       }
       return ($value,$ptype);
   }
   
   # ----------------------------------------------------------------- Edit script
 sub editscript {  sub editscript {
     my $mode=shift;      my $mode=shift;
     my $resurl=&Apache::loncommon::lastresurl();      my $resurl=&Apache::loncommon::lastresurl();
Line 569  function srchclose() { Line 691  function srchclose() {
   
 // -------------------------------------------------------- Open indexer window  // -------------------------------------------------------- Open indexer window
 function idxopen(mode) {  function idxopen(mode) {
    var options="scrollbars=1,resizable=1,menubar=0";     var options="scrollbars=1,resizable=1,menubar=0,location=1,toolbar=1";
    idxmode=mode;     idxmode=mode;
    idxflag=1;     idxflag=1;
    idx=open("$resurl/?launch=1&mode=$mode&catalogmode="+mode,"idxout",options);     idx=open("$resurl/?launch=1&mode=$mode&catalogmode="+mode,"idxout",options);
    idx.focus();     idx.focus();
 }  }
   
   // ------------------------------------------------------ Open groupsort window
   function groupopen(url,recover,bookmarks) {
      var options="scrollbars=1,resizable=1,menubar=0";
      idxflag=1;
      idx=open("/adm/groupsort?mode=$mode&recover="+recover+"&readfile="+url+"&bookmarks="+bookmarks,"idxout",options);
      idx.focus();
   }
   
 // --------------------------------------------------------- Open search window  // --------------------------------------------------------- Open search window
 function srchopen(mode) {  function srchopen(mode) {
    var options="scrollbars=1,resizable=1,menubar=0";     var options="scrollbars=1,resizable=1,menubar=0";
Line 586  function srchopen(mode) { Line 716  function srchopen(mode) {
 }  }
 // ----------------------------------------------------- launch indexer browser  // ----------------------------------------------------- launch indexer browser
 function groupsearch() {  function groupsearch() {
    srchcheck('groupsearch');     srchcheck('import');
 }  }
   
 function groupimport() {  function groupimport() {
    idxcheck('groupimport');     idxcheck('import');
 }  }
   
 // ------------------------------------------------------- Do srch status check  // ------------------------------------------------------- Do srch status check
 function srchcheck(mode) {  function srchcheck(mode) {
    if (!srch || srch.closed || srchmode!=mode) {     if (!srch || srch.closed || srchmode!=mode) {
Line 640  sub smpedt { Line 771  sub smpedt {
    my $buttons=&buttons(2);     my $buttons=&buttons(2);
    my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp';     my $tmpfn=&Apache::lonnet::filelocation('',$url).'.tmp';
    my $targetmsg='';     my $targetmsg='';
    if ($ENV{'form.save'}) {     if ($env{'form.save'}) {
        $targetmsg='<b>Saving ...</b><br>';  
        copy($tmpfn,&Apache::lonnet::filelocation('',$url));         copy($tmpfn,&Apache::lonnet::filelocation('',$url));
        unlink($tmpfn);         unlink($tmpfn);
        my ($errtext,$fatal)=         my ($errtext,$fatal)=
                            &mapread(&Apache::lonnet::filelocation('',$url),'');                             &mapread(&Apache::lonnet::filelocation('',$url),'');
          unless ($fatal) {
      $targetmsg='<b>'.&mt('Saved.').'</b><br />';
          } else {
      $targetmsg='<b>'.&mt('An error occured while saving.').'</b><br />';
          }
    }     }
    if ($ENV{'form.revert'}) {     if ($env{'form.revert'}) {
        $targetmsg='<b>Reverting ...</b><br>';         $targetmsg='<b>'.&mt('Reverted.').'</b><br />';
        unlink($tmpfn);         unlink($tmpfn);
        my ($errtext,$fatal)=         my ($errtext,$fatal)=
                            &mapread(&Apache::lonnet::filelocation('',$url),'');                             &mapread(&Apache::lonnet::filelocation('',$url),'');
Line 660  sub smpedt { Line 795  sub smpedt {
    }     }
 # ---------------------------------------------------------- Process form input  # ---------------------------------------------------------- Process form input
   
    my @importselect=();     my @importselect=&Apache::loncommon::get_env_multiple('form.importsel');
    my @targetselect=();     my @targetselect=&Apache::loncommon::get_env_multiple('form.target');
    undef @importselect;  
    undef @targetselect;  
    if (defined($ENV{'form.importsel'})) {  
        if (ref($ENV{'form.importsel'})) {  
    @importselect=sort(@{$ENV{'form.importsel'}});  
        } else {  
            @importselect=($ENV{'form.importsel'});  
        }  
    }  
    if (defined($ENV{'form.target'})) {  
        if (ref($ENV{'form.target'})) {  
    @targetselect=sort(@{$ENV{'form.target'}});  
        } else {  
            @targetselect=($ENV{'form.target'});  
        }  
    }  
 # ============================================================ Process commands  # ============================================================ Process commands
   
    my $targetdetail=$ENV{'form.targetdetail'};     my $targetdetail=$env{'form.targetdetail'};
    my $importdetail=$ENV{'form.curimpdetail'};     my $importdetail=$env{'form.curimpdetail'};
   
 # ---------------------------------------------------- Importing from groupsort  # ---------------------------------------------------- Importing from groupsort
    if (($ENV{'form.importdetail'}) && (!$ENV{'form.impfortarget'})) {     if (($env{'form.importdetail'}) && (!$env{'form.impfortarget'})) {
   
        $importdetail='';         $importdetail='';
        my @curimport=split(/\&/,$ENV{'form.curimpdetail'});         my @curimport=split(/\&/,$env{'form.curimpdetail'});
   
        my $lastsel;         my $lastsel;
   
Line 704  sub smpedt { Line 823  sub smpedt {
    }     }
        }         }
   
       $importdetail.='&'.$ENV{'form.importdetail'};        $importdetail.='&'.$env{'form.importdetail'};
   
        for (my $i=$lastsel+1;$i<=$#curimport;$i++) {         for (my $i=$lastsel+1;$i<=$#curimport;$i++) {
            my ($name,$url)=split(/\=/,$curimport[$i]);             my ($name,$url)=split(/\=/,$curimport[$i]);
Line 716  sub smpedt { Line 835  sub smpedt {
        $importdetail=~s/^\&//;         $importdetail=~s/^\&//;
   
 # ------------------------------------------------------------------- Clear all  # ------------------------------------------------------------------- Clear all
    } elsif ($ENV{'form.clear'}) {     } elsif ($env{'form.clear'}) {
        $importdetail='';         $importdetail='';
 # ------------------------------------------------------------ Discard selected  # ------------------------------------------------------------ Discard selected
    } elsif ($ENV{'form.discard'}) {     } elsif ($env{'form.discard'}) {
        $importdetail='';         $importdetail='';
        my @curimport=split(/\&/,$ENV{'form.curimpdetail'});         my @curimport=split(/\&/,$env{'form.curimpdetail'});
        foreach (@importselect) {         foreach (@importselect) {
    $curimport[$_]='';     $curimport[$_]='';
        }         }
Line 732  sub smpedt { Line 851  sub smpedt {
    }     }
        }         }
 # --------------------------------------------------------- Loading another map  # --------------------------------------------------------- Loading another map
    } elsif ($ENV{'form.loadmap'}) {     } elsif ($env{'form.loadmap'}) {
        $importdetail='';         $importdetail='';
        my @curimport=split(/\&/,$ENV{'form.curimpdetail'});         my @curimport=split(/\&/,$env{'form.curimpdetail'});
   
        my $lastsel;         my $lastsel;
   
Line 752  sub smpedt { Line 871  sub smpedt {
        }         }
   
        foreach (         foreach (
     &Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$ENV{'form.importmap'}))) {      &Apache::lonsequence::attemptread(&Apache::lonnet::filelocation('',$env{'form.importmap'}))) {
    my ($name,$url)=split(/\:/,$_);     my ($name,$url)=split(/\:/,$_);
            if ($url) {             if ($url) {
               $importdetail.='&'.&Apache::lonnet::escape($name).'='.                $importdetail.='&'.&escape($name).'='.
          &Apache::lonnet::escape($url);           &escape($url);
   }    }
        }         }
   
Line 770  sub smpedt { Line 889  sub smpedt {
        $importdetail=~s/^\&//;         $importdetail=~s/^\&//;
   
 # ------------------------------------------------ Groupimport/search to target  # ------------------------------------------------ Groupimport/search to target
    } elsif ($ENV{'form.importdetail'}) {     } elsif ($env{'form.importdetail'}) {
        my $lastsel;         my $lastsel;
        if (defined($targetselect[-1])) {         if (defined($targetselect[-1])) {
    $lastsel=$targetselect[-1];     $lastsel=$targetselect[-1];
        } else {         } else {
            $lastsel=$#order+1;             $lastsel=$#order+1;
        }         }
        &pastetarget($lastsel,split(/\&/,$ENV{'form.importdetail'}));         &pastetarget($lastsel,split(/\&/,$env{'form.importdetail'}));
        &storemap(&Apache::lonnet::filelocation('',$url));         &storemap(&Apache::lonnet::filelocation('',$url));
 # ------------------------------------------------------------------------- Cut  # ------------------------------------------------------------------------- Cut
    } elsif (($ENV{'form.cut'}) || ($ENV{'form.copy'})) {     } elsif (($env{'form.cut'}) || ($env{'form.copy'})) {
        $importdetail='';         $importdetail='';
        my @curimport=split(/\&/,$ENV{'form.curimpdetail'});         my @curimport=split(/\&/,$env{'form.curimpdetail'});
   
        my $lastsel;         my $lastsel;
   
Line 802  sub smpedt { Line 921  sub smpedt {
        foreach (@targetselect) {         foreach (@targetselect) {
    my ($name,$url)=split(/\:/,$resources[$order[$_-1]]);     my ($name,$url)=split(/\:/,$resources[$order[$_-1]]);
            if ($url) {             if ($url) {
               $importdetail.='&'.&Apache::lonnet::escape($name).'='.                $importdetail.='&'.&escape($name).'='.
          &Apache::lonnet::escape($url);           &escape($url);
   }    }
        }         }
   
Line 816  sub smpedt { Line 935  sub smpedt {
        $importdetail=~s/\&+/\&/g;         $importdetail=~s/\&+/\&/g;
        $importdetail=~s/^\&//;         $importdetail=~s/^\&//;
   
        if ($ENV{'form.cut'}) {         if ($env{'form.cut'}) {
            my @neworder=();             my @neworder=();
            for (my $i=0;$i<=$#order;$i++) {             for (my $i=0;$i<=$#order;$i++) {
                my $include=1;                 my $include=1;
                foreach (@targetselect) {                 foreach (@targetselect) {
    if ($_-1==$i) { $include=0; }     if ($_-1==$i) { $include=0; }
                }                 }
                if ($include) { $neworder[$#neworder+1]=$order[$i]; }                 if ($include) { 
      $neworder[$#neworder+1]=$order[$i]; 
          } else {
      &makezombie($order[$i]);
          }
            }             }
            @order=@neworder;             @order=@neworder;
            &storemap(&Apache::lonnet::filelocation('',$url));                   &storemap(&Apache::lonnet::filelocation('',$url));      
        }         }
   
 # ----------------------------------------------------------------------- Paste  # ----------------------------------------------------------------------- Paste
    } elsif ($ENV{'form.paste'}) {     } elsif ($env{'form.paste'}) {
        my $lastsel;         my $lastsel;
        if (defined($targetselect[-1])) {         if (defined($targetselect[-1])) {
    $lastsel=$targetselect[-1];     $lastsel=$targetselect[-1];
Line 838  sub smpedt { Line 961  sub smpedt {
            $lastsel=$#order+1;             $lastsel=$#order+1;
        }         }
        my @newsequence;         my @newsequence;
        my @curimport=split(/\&/,$ENV{'form.curimpdetail'});         my @curimport=split(/\&/,$env{'form.curimpdetail'});
        foreach (@importselect) {         foreach (@importselect) {
           $newsequence[$#newsequence+1]=$curimport[$_];            $newsequence[$#newsequence+1]=$curimport[$_];
        }         }
        &pastetarget($lastsel,@newsequence);         &pastetarget($lastsel,@newsequence);
        &storemap(&Apache::lonnet::filelocation('',$url));         &storemap(&Apache::lonnet::filelocation('',$url));
 # -------------------------------------------------------------------- Move up   # -------------------------------------------------------------------- Move up 
    } elsif ($ENV{'form.moveup'}) {     } elsif ($env{'form.moveup'}) {
        foreach (sort @targetselect) {         foreach (sort @targetselect) {
            if ($_-1>0) {             if ($_-1>0) {
               my $movethis=$order[$_-1];                my $movethis=$order[$_-1];
Line 855  sub smpedt { Line 978  sub smpedt {
        }         }
        &storemap(&Apache::lonnet::filelocation('',$url));         &storemap(&Apache::lonnet::filelocation('',$url));
 # ------------------------------------------------------------------ Move down  # ------------------------------------------------------------------ Move down
    } elsif ($ENV{'form.movedown'}) {     } elsif ($env{'form.movedown'}) {
        foreach (reverse sort @targetselect) {         foreach (reverse sort @targetselect) {
            if ($_-1<$#order) {             if ($_-1<$#order) {
               my $movethis=$order[$_-1];                my $movethis=$order[$_-1];
Line 865  sub smpedt { Line 988  sub smpedt {
        }         }
        &storemap(&Apache::lonnet::filelocation('',$url));         &storemap(&Apache::lonnet::filelocation('',$url));
 # --------------------------------------------------------------------- Rename  # --------------------------------------------------------------------- Rename
    } elsif ($ENV{'form.renameres'}) {     } elsif ($env{'form.renameres'}) {
        my $residx=$Apache::lonratedt::order[$ENV{'form.renameidx'}-1];         my $residx=$Apache::lonratedt::order[$env{'form.renameidx'}-1];
        my ($name,@resrest)=split(/\:/,$Apache::lonratedt::resources[$residx]);         my ($name,@resrest)=split(/\:/,$Apache::lonratedt::resources[$residx]);
        $name=$ENV{'form.renametitle'};         $name=$env{'form.renametitle'};
        $name=~s/\:/\&colon\;/g;         $name=~s/\:/\&colon\;/g;
        $Apache::lonratedt::resources[$residx]=$name.':'.join(':',@resrest);         $Apache::lonratedt::resources[$residx]=$name.':'.join(':',@resrest);
        &storemap(&Apache::lonnet::filelocation('',$url));         &storemap(&Apache::lonnet::filelocation('',$url));
Line 886  sub smpedt { Line 1009  sub smpedt {
           my ($name,$url)=split(/\=/,$_);            my ($name,$url)=split(/\=/,$_);
           unless ($name) { $name=(split(/\//,$url))[-1]; }            unless ($name) { $name=(split(/\//,$url))[-1]; }
           unless ($name) { $name='EMPTY'; }            unless ($name) { $name='EMPTY'; }
           '<option value="'.$idx.'">'.&Apache::lonnet::unescape($name).            '<option value="'.$idx.'">'.&unescape($name).
                                     '</option>';                                      '</option>';
       }        }
    } split(/\&/,$importdetail));     } split(/\&/,$importdetail));
Line 899  sub smpedt { Line 1022  sub smpedt {
        my ($name,$url)=split(/\:/,$resources[$_]);         my ($name,$url)=split(/\:/,$resources[$_]);
        unless ($name) {  $name=(split(/\//,$url))[-1]; }         unless ($name) {  $name=(split(/\//,$url))[-1]; }
        unless ($name) { $name='EMPTY'; }         unless ($name) { $name='EMPTY'; }
        $targetdetail.='&'.&Apache::lonnet::escape($name).'='.         $targetdetail.='&'.&escape($name).'='.
                   &Apache::lonnet::escape($url);                    &escape($url);
        $idx++;         $idx++;
        $name=~s/\&colon;/\:/g;         $name=~s/\&colon;/\:/g;
        '<option value="'.$idx.'">'.$name.'</option>';         '<option value="'.$idx.'">'.$name.'</option>';
Line 908  sub smpedt { Line 1031  sub smpedt {
   
 # ----------------------------------------------------- Start simple RAT screen  # ----------------------------------------------------- Start simple RAT screen
    my $editscript=&editscript('simple');     my $editscript=&editscript('simple');
    my $bodytag=&Apache::loncommon::bodytag(undef,undef,undef,1);  
    my %lt=&Apache::lonlocal::texthash(     my %lt=&Apache::lonlocal::texthash(
       'sa' => 'Save',        'sa' => 'Save',
       'nt' => 'New Title',        'nt' => 'New Title',
       'se' => 'Search',        'se' => 'Search',
       'im' => 'Import',        'im' => 'Import',
                                         'bk' => 'Import Bookmarks',
       'vi' => 'View',        'vi' => 'View',
       'lm' => 'Load Map',        'lm' => 'Load Map',
       'ds' => 'Discard Selected',        'ds' => 'Discard Selected',
Line 928  sub smpedt { Line 1052  sub smpedt {
                                       'cs' => 'Cut selected',                                        'cs' => 'Cut selected',
                                       'ps' => 'Copy selected',                                        'ps' => 'Copy selected',
                                       'pas' => 'Paste after selected',                                        'pas' => 'Paste after selected',
                                         'reco' => 'Recover Deleted'
       );        );
    $r->print(<<ENDSMPHEAD);     my $js=<<ENDJS;
 <html>  <script type="text/javascript">
 <head>  
 <script>  
   
    $editscript     $editscript
   
Line 975  sub smpedt { Line 1098  sub smpedt {
    }     }
   
 </script>  </script>
 </head>                   ENDJS
 $bodytag  
       my $start_page = &Apache::loncommon::start_page(undef,$js).
           &Apache::loncommon::help_open_menu('Sequence_Simple_Editor_Creation',
      'Sequence_Simple_Editor_Creation',
      6,'RAT');    
       my $end_page = &Apache::loncommon::end_page();
   
       $r->print(<<ENDSMPHEAD);
   $start_page
 $buttons  $buttons
 <font color=red>$errtext</font>  <font color=red>$errtext</font>
 <form name=simpleedit method=post>  <form name=simpleedit method=post>
Line 1007  value="Select Map"><input type=submit na Line 1138  value="Select Map"><input type=submit na
 "javascript:impfortarget.value=1;groupsearch()" value="$lt{'se'}">  "javascript:impfortarget.value=1;groupsearch()" value="$lt{'se'}">
 <input type=button onClick=  <input type=button onClick=
 "javascript:impfortarget.value=1;groupimport();" value="$lt{'im'}">  "javascript:impfortarget.value=1;groupimport();" value="$lt{'im'}">
   <input type=button onClick=
   "javascript:impfortarget.value=1;groupopen(0,1,1);" value="$lt{'bk'}">
   <input type=button onClick=
   "javascript:impfortarget.value=1;groupopen('$url',1,0);" value="$lt{'reco'}">
 $lt{'as'}  $lt{'as'}
 <hr>  <hr>
 <input type=submit name="moveup" value="$lt{'mu'}">  <input type=submit name="moveup" value="$lt{'mu'}">
Line 1041  $targetwindow Line 1176  $targetwindow
 <input type=hidden name=targetdetail value="$targetdetail">  <input type=hidden name=targetdetail value="$targetdetail">
 <input type=hidden name=impfortarget value="0">  <input type=hidden name=impfortarget value="0">
 </form>  </form>
 </body></html>  $end_page
 ENDSMPHEAD  ENDSMPHEAD
 }  }
   
 # ----------------------------------------------------------------- No such dir  # ----------------------------------------------------------------- No such dir
 sub nodir {  sub nodir {
    my ($r,$dir)=@_;     my ($r,$dir)=@_;
    $dir=~s/^\/home\/\w+\/public\_html//;     $dir=~s{^/home/\w+/public_html}{};
    $r->print(<<ENDNODIR);     $r->print(&Apache::loncommon::start_page(undef,undef,
 <html>      {'only_body' => 1,
 <body bgcolor='#FFFFFF'>       'bgcolor'   => '#FFFFFF',}).
 <h1>No such directory: $dir</h1>       "<h1>No such directory: $dir</h1>".
 </body>       &Apache::loncommon::end_page());
 </html>  
 ENDNODIR  
 }  }
   
 # ---------------------------------------------------------------- View Handler  # ---------------------------------------------------------------- View Handler
   
 sub viewmap {  sub viewmap {
     my ($r,$url,$adv,$errtext)=@_;      my ($r,$url,$adv,$errtext)=@_;
     $r->print('<html>'.      $r->print(
      &Apache::loncommon::bodytag('Edit Content of a Map').        &Apache::loncommon::start_page('Edit Content of a Map').
      &buttons($adv));        &Apache::loncommon::help_open_menu('','',6,'RAT').
         &buttons($adv));
     if ($errtext) {      if ($errtext) {
  $r->print($errtext.'<hr>');   $r->print($errtext.'<hr />');
     }      }
     my $idx=0;      my $idx=0;
     $r->print('<h1>'.$url.'</h1>');      $r->print('<h1>'.$url.'</h1>');
     if ($adv) {      if ($adv) {
  $r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />');   $r->print('<p><b><font color="red">'.&mt('Map contents are not shown in order.').'</font></b></p><br />');
     }      }
       $r->print( '<table border="0" cellspacing="2" cellpadding="4">'.
                  '<tr bgcolor="#DDDDDD"><th>'.&mt('Type').'</th>'.
                  '<th>'.&mt('Title in map').'</th>'.
                  '<th>'.&mt('Filename of resource').'</th>'.
                  '<th>'.&mt('Link to published resource').'</th>'.
                  '<th>'.&mt('Link to resource in Construction Space').'</th>'.
                  '</tr>');
       my @backgroundColors = ("#FFFFFF", "#F6F6F6");
     foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {      foreach (&attemptread(&Apache::lonnet::filelocation('',$url))) {
  if (defined($_)) {   if (defined($_)) {
             $idx++;              $idx++;
     my ($title,$url)=split(/\:/,$_);      my ($title,$url,$cond)=split(/\:/,$_);
       if ($cond eq 'cond') { next; }
             $title=~s/\&colon\;/\:/g;              $title=~s/\&colon\;/\:/g;
             $url=~s/\&colon\;/\:/g;              $url=~s/\&colon\;/\:/g;
             unless ($title) { $title=(split(/\//,$url))[-1] };              unless ($title) { $title=(split(/\//,$url))[-1] };
             unless ($title) { $title='<i>Empty</i>'; }              unless ($title) { $title='<i>'.&mt('Empty').'</i>'; }
               my $resurl = &Apache::lonratsrv::qtescape($url);
               my $resfilepath = $Apache::lonnet::perlvar{'lonDocRoot'}.$resurl;
               my $filename; 
               if ($resurl =~ m#/([^/]+)$#) {
                   $filename = $1;
               }
               my $cstrurl = $resurl;
               $cstrurl =~ s#^/res/[^/]+/([^/]+)/#/priv/$1/#;
               my $bgcol = $idx%2; 
               $r->print('<tr bgcolor='.$backgroundColors[$bgcol].'><td>'.
                         '<img src="'.&Apache::loncommon::icon($resfilepath).
                         '" /></td><td>'.&Apache::lonratsrv::qtescape($title).
                         '</td><td>'.$filename.'</td><td>');
               if ($url) {
    $r->print('<a href="'.$resurl.'">'.&mt('Resource space').'</a>');
               }
               $r->print('</td><td>');
             if ($url) {              if ($url) {
  $r->print('<a href="'.&Apache::lonratsrv::qtescape($url).'">');                 $r->print('<a href="'.$cstrurl.'">'.
                            &mt('Construction space').'</a>');
             }              }
             $r->print(&Apache::lonratsrv::qtescape($title));              $r->print('</td></tr>'."\n");
             if ($url) { $r->print('</a>'); }  
     $r->print('<br>');  
         }          }
     }      }
     $r->print('</body></html>');      $r->print('</table>');
       $r->print(&Apache::loncommon::end_page());
 }  }
   
 # ================================================================ Main Handler  # ================================================================ Main Handler
Line 1100  sub handler { Line 1260  sub handler {
   $r->send_http_header;    $r->send_http_header;
   
   return OK if $r->header_only;    return OK if $r->header_only;
   my $target = $ENV{'form.grade_target'};    my $target = $env{'form.grade_target'};
   if ($target eq 'meta') {    if ($target eq 'meta') {
       &Apache::loncommon::content_type($r,'text/html');        &Apache::loncommon::content_type($r,'text/html');
       $r->send_http_header;        $r->send_http_header;
Line 1119  sub handler { Line 1279  sub handler {
 # ------------------------------------------- Determine which tools can be used  # ------------------------------------------- Determine which tools can be used
   my $adv=0;    my $adv=0;
   
   unless ($ENV{'form.forcesmp'}) {    unless ($env{'form.forcesmp'}) {
      if ($ENV{'form.forceadv'}) {       if ($env{'form.forceadv'}) {
         $adv=1;          $adv=1;
      } elsif (my $fh=Apache::File->new($fn)) {       } elsif (my $fh=Apache::File->new($fn)) {
  my $allmap=join('',<$fh>);   my $allmap=join('',<$fh>);
Line 1138  sub handler { Line 1298  sub handler {
   
 # ----------------------------------- adv==1 now means "graphical MUST be used"  # ----------------------------------- adv==1 now means "graphical MUST be used"
   
   if ($ENV{'form.forceadv'}) {    if ($env{'form.forceadv'}) {
       &ratedt($r,$url);        &ratedt($r,$url);
   } elsif ($ENV{'form.forcesmp'}) {    } elsif ($env{'form.forcesmp'}) {
       &smpedt($r,$url,$errtext);        &smpedt($r,$url,$errtext);
   } else {    } else {
       &viewmap($r,$url,$adv,$errtext);        &viewmap($r,$url,$adv,$errtext);

Removed from v.1.51  
changed lines
  Added in v.1.81


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>