Annotation of rat/lonratedt.pm, revision 1.6

1.1       www         1: # The LearningOnline Network with CAPA
                      2: # Edit Handler for RAT Maps
1.5       www         3: #
1.6     ! www         4: # $Id: lonratedt.pm,v 1.5 2001/11/29 19:23:49 www 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.1       www        28: # (TeX Content Handler
                     29: #
                     30: # 05/29/00,05/30 Gerd Kortemeyer)
1.4       www        31: # 7/1,6/30 Gerd Kortemeyer
1.1       www        32: 
                     33: package Apache::lonratedt;
                     34: 
                     35: use strict;
                     36: use Apache::Constants qw(:common);
1.3       www        37: use Apache::lonnet;
1.1       www        38: 
1.3       www        39: # --------------------------------------------------------- Build up RAT screen
                     40: sub ratedt {
                     41:   my ($r,$url)=@_;
1.1       www        42:   $r->print(<<ENDDOCUMENT);
                     43: 
                     44: <html>
1.2       harris41   45: <head>
                     46: <script language="JavaScript">
                     47:     var flag=0;
                     48: </script>
                     49: </head>
1.1       www        50: <frameset rows="1,50,*" border=0>
                     51: <frame name=server src="$url/loadonly/ratserver" noresize noscroll>
                     52: <frame name=code src="/adm/rat/code.html">
                     53: <frame name=mapout src="/adm/rat/map.html">
                     54: </frameset>
                     55: </html>
                     56: 
                     57: ENDDOCUMENT
1.3       www        58: }
                     59: 
                     60: sub smpedt {
                     61:    my ($r,$fn)=@_;
                     62:    $r->print(<<ENDSMPHEAD);
                     63: <html>
1.6     ! www        64: <head>
        !            65: <script>
        !            66: var srch;
        !            67: var srchflag=-1; // 1 means currently open
        !            68:                  // 0 means closed (but has been open)
        !            69:                  // -1 means never yet opened/defined
        !            70: var srchmode='';
        !            71: 
        !            72: var idx;
        !            73: var idxflag=-1; // 1 means currently open
        !            74:                  // 0 means closed (but has been open)
        !            75:                  // -1 means never yet opened/defined
        !            76: var idxmode='';
        !            77: 
        !            78: // ------------------------------------------------------ Clears indexer window
        !            79: function idxclear() {
        !            80:   idx.document.clear();
        !            81: }
        !            82: 
        !            83: // ------------------------------------------------------- Clears search window
        !            84: function srchclear() {
        !            85:   srch.document.clear();
        !            86: }
        !            87: 
        !            88: // ------------------------------------------------------ Closes indexer window
        !            89: function idxclose() {
        !            90:   if (idx && !idx.closed) {
        !            91:     idxflag=0;
        !            92:     idx.close();
        !            93:   }
        !            94: }
        !            95: 
        !            96: // ------------------------------------------------------- Closes search window
        !            97: function srchclose() {
        !            98:   if (srch && !srch.closed) {
        !            99:     srchflag=0;
        !           100:     srch.close();
        !           101:   }
        !           102: }
        !           103: 
        !           104: // -------------------------------------------------------- Open indexer window
        !           105: function idxopen(mode) {
        !           106:    var options="scrollbars=1,resizable=1,menubar=0";
        !           107:    idxmode=mode;
        !           108:    idxflag=1;
        !           109:    idx=open("/res/?launch=1&mode=simple&catalogmode="+mode,"idxout",options);
        !           110:    idx.focus();
        !           111: }
        !           112: 
        !           113: // --------------------------------------------------------- Open search window
        !           114: function srchopen(mode) {
        !           115:    var options="scrollbars=1,resizable=1,menubar=0";
        !           116:    srchmode=mode;
        !           117:    srchflag=1;
        !           118:    srch=open("/adm/searchcat?launch=1&mode=simple&catalogmode="+mode,"srchout",options);
        !           119:    srch.focus();
        !           120: }
        !           121: // ----------------------------------------------------- launch indexer browser
        !           122: function groupsearch() {
        !           123:    srchcheck('groupsearch');
        !           124: }
        !           125: 
        !           126: function groupimport() {
        !           127:    idxcheck('groupimport');
        !           128: }
        !           129: // ------------------------------------------------------- Do srch status check
        !           130: function srchcheck(mode) {
        !           131:    if (!srch || srch.closed || srchmode!=mode) {
        !           132:       srchopen(mode);
        !           133:    }
        !           134:    srch.focus();
        !           135: }
        !           136: 
        !           137: // -------------------------------------------------------- Do idx status check
        !           138: function idxcheck(mode) {
        !           139:    if (!idx || idx.closed || idxmode!=mode) {
        !           140:       idxopen(mode);
        !           141:    }
        !           142:    idx.focus();
        !           143: }
        !           144: </script>
        !           145: </head>                 
1.3       www       146: <body bgcolor='#FFFFFF'>
                    147: <form method=post>
                    148: <input type=submit name=forceadv 
1.6     ! www       149: value="Advanced Map Editing - Graphical Resource Assembly Tool"><hr>
        !           150: This is the future site of the great simple RAT
        !           151: <a href="javascript:groupsearch()">Group Search</a>
        !           152: <a href="javascript:groupimport()">Group Import</a>
        !           153: 
1.3       www       154: ENDSMPHEAD
1.6     ! www       155: 
1.3       www       156:     $r->print(
                    157:       '<input type=submit name=forcesmp value="Store"></form></body></html>');
                    158: }
                    159: 
1.4       www       160: sub nodir {
                    161:    my ($r,$dir)=@_;
                    162:    $dir=~s/^\/home\/\w+\/public\_html//;
                    163:    $r->print(<<ENDNODIR);
                    164: <html>
                    165: <body bgcolor='#FFFFFF'>
                    166: <h1>No such directory: $dir</h1>
                    167: </body>
                    168: </html>
                    169: ENDNODIR
                    170: }
                    171: 
1.3       www       172: # ================================================================ Main Handler
                    173: 
                    174: sub handler {
                    175:   my $r=shift;
                    176:   $r->content_type('text/html');
                    177:   $r->send_http_header;
                    178: 
                    179:   return OK if $r->header_only;
                    180: 
                    181:   my $url=$r->uri;
                    182:   my $fn=&Apache::lonnet::filelocation('',$url);
                    183: 
1.4       www       184:   my ($dir)=($fn=~/^(.+)\/[^\/]+$/);
                    185:   unless (-e $dir) {
                    186:       &nodir($r,$dir);
                    187:       return OK;
                    188:   }
1.3       www       189:   my $adv=0;
                    190: 
                    191:   unless ($ENV{'form.forcesmp'}) {
                    192:      if ($ENV{'form.forceadv'}) {
                    193:         $adv=1;
                    194:      } elsif (my $fh=Apache::File->new($fn)) {
                    195: 	 my $allmap=join('',<$fh>);
                    196:          $adv=($allmap=~/\<map[^\>]+mode\s*\=\s*(\'|\")rat/is);
                    197:      }
                    198:   }
                    199: 
                    200:   if ($adv) {
                    201:       &ratedt($r,$url);
                    202:   } else {
                    203:       &smpedt($r,$fn);
                    204:   }
1.1       www       205:   return OK;
                    206: }
                    207: 
                    208: 1;
                    209: __END__
                    210: 
                    211: 
                    212: 
                    213: 
                    214: 
                    215: 
                    216: 

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