Diff for /loncom/interface/groupsort.pm between versions 1.43 and 1.44

version 1.43, 2006/06/08 13:56:31 version 1.44, 2006/06/19 09:40:17
Line 191  sub readfromfile { Line 191  sub readfromfile {
     return ($shash,$thash);      return ($shash,$thash);
 }  }
   
   # --------------------------------------------------------- Read from bookmarks
   
   sub readfrombookmarks {
       my ($r,$shash,$thash)=@_;
       my %bookmarks=&Apache::lonnet::dump('bookmarks');
   # the bookmark "hash" is just one entry
   # it's a javascript program code with arguments like ('title','url');
       my @bookmarks=($bookmarks{'bookmarks'}=~/\((?:\'([^\']+)\'\,\'([^\']+)\'|\"([^\"]+)\"\,\"([^\"]+)\")\)\;/g);
       my $order=1;
       for (my $index=0;$index<($#bookmarks+1)/2;$index++) {
           if ($bookmarks[$index*2+1]) {
       $$thash{$bookmarks[$index*2+1]}=$bookmarks[$index*2];
       $$thash{$bookmarks[$index*2+1]}=~s/^LON\-CAPA\s+//;
       $$shash{$bookmarks[$index*2+1]}=$order;
       $order++;
    }
       }
       return ($shash,$thash);
   }
   
 # ---------------------------------------------------------------- Main Handler  # ---------------------------------------------------------------- Main Handler
 sub handler {  sub handler {
     my $r = shift;      my $r = shift;
     
    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},     &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},
      ['acts','mode','readfile','recover']);       ['acts','mode','readfile','recover','bookmarks']);
     # color scheme      # color scheme
     my $fileclr = '#ffffe6';      my $fileclr = '#ffffe6';
     my $titleclr = '#ddffff';      my $titleclr = '#ddffff';
Line 209  sub handler { Line 229  sub handler {
     my $finishimport='';      my $finishimport='';
     my $begincondition='';      my $begincondition='';
     my $endcondition='';      my $endcondition='';
     if ($env{'form.readfile'}) {      if (($env{'form.readfile'}) || ($env{'form.bookmarks'}))  {
         $begincondition='if (eval("document.forms.groupsort.include"+num+".checked")) {';          $begincondition='if (eval("document.forms.groupsort.include"+num+".checked")) {';
  $endcondition='}';   $endcondition='}';
     }      }
Line 293  END Line 313  END
   
     if ($env{'form.readfile'}) {      if ($env{'form.readfile'}) {
  &readfromfile($r,\%shash,\%thash,\%nhash);   &readfromfile($r,\%shash,\%thash,\%nhash);
       } elsif ($env{'form.bookmarks'}) {
    &readfrombookmarks($r,\%shash,\%thash);
     } else {      } else {
  &readfromdb($r,\%shash,\%thash);   &readfromdb($r,\%shash,\%thash);
     }      }
   
     my $ctr = 0;      my $ctr = 0;
     my $clen = scalar(keys %shash);      my $clen = scalar(keys %shash);
     if (($clen > 1) || ($env{'form.readfile'})) {      if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
  my %lt=&Apache::lonlocal::texthash(   my %lt=&Apache::lonlocal::texthash(
  'fin'=> 'Finalize order of resources',   'fin'=> 'Finalize order of resources',
  'ci' => 'Continue Import',   'ci' => 'Continue Import',
Line 322  END Line 344  END
 <input type="hidden" name="newval" value="" />  <input type="hidden" name="newval" value="" />
 <input type="hidden" name="mode" value="$env{'form.mode'}" />  <input type="hidden" name="mode" value="$env{'form.mode'}" />
 <input type="hidden" name="readfile" value="$env{'form.readfile'}" />  <input type="hidden" name="readfile" value="$env{'form.readfile'}" />
   <input type="hidden" name="bookmarks" value="$env{'form.bookmarks'}" />
 <input type="hidden" name="recover" value="$env{'form.recover'}" />  <input type="hidden" name="recover" value="$env{'form.recover'}" />
 END  END
   
Line 342  END Line 365  END
 END  END
         $r->print("<table border='0'><tr><td bgcolor='#eeeeee'>");          $r->print("<table border='0'><tr><td bgcolor='#eeeeee'>");
  $r->print("<table border=0><tr>\n");   $r->print("<table border=0><tr>\n");
  if ($env{'form.readfile'}) {    if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) { 
     $r->print("<td bgcolor='$titleclr'><b>$lt{'in'}</b></td>\n");      $r->print("<td bgcolor='$titleclr'><b>$lt{'in'}</b></td>\n");
  } else {    } else { 
     $r->print("<td colspan='2' bgcolor='$titleclr'><b>$lt{'co'}</b></td>\n");       $r->print("<td colspan='2' bgcolor='$titleclr'><b>$lt{'co'}</b></td>\n"); 
Line 365  END Line 388  END
  my $key=$_;   my $key=$_;
  $ctr++;   $ctr++;
  my $iconname=&Apache::loncommon::icon($key);   my $iconname=&Apache::loncommon::icon($key);
  if (($clen > 1) || ($env{'form.readfile'})) {   if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
     $r->print("<tr><td bgcolor='$fileclr'>");      $r->print("<tr><td bgcolor='$fileclr'>");
             if ($env{'form.readfile'}) {              if (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
  $r->print(&checkbox($ctr-1));   $r->print(&checkbox($ctr-1));
     } else {      } else {
  $r->print(&movers($clen,$ctr));   $r->print(&movers($clen,$ctr));
     }      }
  }   }
  $r->print(&hidden($ctr-1,$thash{$key},$key));   $r->print(&hidden($ctr-1,$thash{$key},$key));
  if (($clen > 1)  || ($env{'form.readfile'})) {   if (($clen > 1)  || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
     $r->print("</td>");      $r->print("</td>");
             unless ($env{'form.readfile'}) {              unless (($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
  $r->print("<td bgcolor='$fileclr'>".   $r->print("<td bgcolor='$fileclr'>".
   &select_box($clen,$ctr).    &select_box($clen,$ctr).
   "</td>");    "</td>");
Line 388  END Line 411  END
     $r->print("$key</td></tr>\n");      $r->print("$key</td></tr>\n");
  }    } 
     }      }
     if (($clen > 1) || ($env{'form.readfile'})) {      if (($clen > 1) || ($env{'form.readfile'}) || ($env{'form.bookmarks'})) {
  $r->print("</table></td></tr></table></form>");   $r->print("</table></td></tr></table></form>");
     } else {      } else {
  $r->print(<<END);   $r->print(<<END);

Removed from v.1.43  
changed lines
  Added in v.1.44


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