[LON-CAPA-cvs] cvs: loncom / loncapa_apache.conf /publisher lonconstruct.pm lonpubmenu.pm

raeburn lon-capa-cvs@mail.lon-capa.org
Fri, 10 Dec 2004 14:57:48 -0000


This is a MIME encoded message

--raeburn1102690668
Content-Type: text/plain

raeburn		Fri Dec 10 09:57:48 2004 EDT

  Added files:                 
    /loncom/publisher	lonpubmenu.pm 

  Modified files:              
    /loncom	loncapa_apache.conf 
    /loncom/publisher	lonconstruct.pm 
  Log:
  Fix bug #3654.  Work on topframe in CSTR with remote. Static /publisher/publisher.html replaced with dynamic lonpubmenu.pm that includes appropriate buttons depending on whether page being displayed in lower frame is a directory listing or a resource.  Known issues: modifications required to language files to translate button names (see texthash in lonpubmenu.pm) 
  
  
--raeburn1102690668
Content-Type: text/plain
Content-Disposition: attachment; filename="raeburn-20041210095748.txt"

Index: loncom/loncapa_apache.conf
diff -u loncom/loncapa_apache.conf:1.100 loncom/loncapa_apache.conf:1.101
--- loncom/loncapa_apache.conf:1.100	Wed Nov 17 13:39:20 2004
+++ loncom/loncapa_apache.conf	Fri Dec 10 09:57:47 2004
@@ -1,7 +1,7 @@
 ##
 ## loncapa_apache.conf -- Apache HTTP LON-CAPA configuration file
 ##
-## $Id: loncapa_apache.conf,v 1.100 2004/11/17 18:39:20 raeburn Exp $
+## $Id: loncapa_apache.conf,v 1.101 2004/12/10 14:57:47 raeburn Exp $
 ##
 
 #
@@ -536,6 +536,16 @@
 ErrorDocument	  500 /adm/errorhandler
 </Location>
 
+<Location /adm/pubmenu>
+PerlAccessHandler       Apache::lonacc
+SetHandler perl-script
+PerlHandler Apache::lonpubmenu
+ErrorDocument     403 /adm/login
+ErrorDocument     404 /adm/notfound.html
+ErrorDocument     406 /adm/unauthorized
+ErrorDocument     500 /adm/errorhandler
+</Location>
+
 <Location /adm/unauthorized>
 PerlAccessHandler       Apache::lonacc
 SetHandler perl-script
Index: loncom/publisher/lonconstruct.pm
diff -u loncom/publisher/lonconstruct.pm:1.25 loncom/publisher/lonconstruct.pm:1.26
--- loncom/publisher/lonconstruct.pm:1.25	Wed Dec  1 12:10:55 2004
+++ loncom/publisher/lonconstruct.pm	Fri Dec 10 09:57:47 2004
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Construction Space Page Wrapper for Construction
 #
-# $Id: lonconstruct.pm,v 1.25 2004/12/01 17:10:55 albertel Exp $
+# $Id: lonconstruct.pm,v 1.26 2004/12/10 14:57:47 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -97,6 +97,10 @@
    return OK if $r->header_only;
 
    my $lowerframe=$r->path_info;
+   my $type='file';
+   if ($lowerframe =~ /\/$/) {
+       $type = 'dir';
+   }
    &Debug($r, "Initial URL for lower frame: ".$lowerframe);
    $lowerframe=~s/^\//\/\~/;
    &Debug($r, "Lower frame URL afer ~ subst: ".$lowerframe);
@@ -125,7 +129,7 @@
    my $topsrc = '';
    if ($ENV{'environment.remote'} ne 'off') {
        $toprows = '110';
-       $topsrc = '/adm/localize/adm/publisher.html';
+       $topsrc = '/adm/pubmenu?disp='.$type;
    }
    $r->print(<<ENDPAGE);
 <html>

Index: loncom/publisher/lonpubmenu.pm
+++ loncom/publisher/lonpubmenu.pm
# The LearningOnline Network with CAPA
# Construction Space Buttons for Top Frame 
#
# Copyright Michigan State University Board of Trustees
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
###

package Apache::lonpubmenu;
use Apache::lonlocal;
use Apache::loncommon;

sub handler {
    my $r = shift;
    my %lt=&Apache::lonlocal::texthash(
                                       cnpd => 'Cannot publish directory',
                                       cnrd => 'Cannot retrieve directory',
                                       mcdi => 'Must create new subdirectory inside a directory',
                                       pubr => 'Publish this Resource',
                                       pubd => 'Publish this Directory',
                                       rtrv => 'Retrieve Old Version',
                                       pubs => 'Publish with Subdirectories',
                                       list => 'List Directory',
                                       uplo => 'Upload file',  
                                       dele => 'Delete',
                                       edit => 'Edit Catalog Information', 
                                       sela => 'Select Action',
                                       nfil => 'New file',
                                       nhtm => 'New HTML file',
                                       nprb => 'New problem',
                                       npag => 'New assembled page',
                                       nseq => 'New assembled sequence',
                                       ncrf => 'New custom rights file',
                                       nsty => 'New style file',
                                       nsub => 'New subdirectory',
                                       renm => 'Rename current file to',
                                       move => 'Move current file to',
                                       copy => 'Copy current file to',
                                       type => 'Type Name Here',
                                       go => 'Go',
                                       prnt => 'Print'
                                      );
    &Apache::loncommon::get_unprocessed_cgi($ENV{'QUERY_STRING'},['disp']);
    my $disp = $ENV{'form.disp'};
# set defaults for parent directory in case frameloc is unable to determine directory
    my $defaultdir = '/priv/'.$ENV{'user.name'}.'/'; 
    if ($ENV{'request.role'} =~ m#^ca\./[^/]+/([^/]+)#) {
        $defaultdir = '/priv/'.$1.'/';
    }
    $r->print(<<"ENDONE");
<html>
<head>
<title>LON-CAPA Publishing Frame</title>
<script type="text/javascript">
//<!--
function frameloc() {
    if (parent.LONCAPAToBePublished.location.pathname.indexOf("/~")!=-1) {
       parent.lastknownpriv=parent.LONCAPAToBePublished.location.pathname;
    }
// alert ('We are at '+parent.lastknownpriv);
    return unescape(parent.lastknownpriv);
}

function getdfilename() {
    var currloc = frameloc();
    var currdir;
    if (currloc.indexOf("/") != -1) {   
        var loclength = currloc.length;
        var lastslash = currloc.lastIndexOf("/");
        if (loclength == lastslash+1) {
            return;
        }
        else {
            currdir = currloc.substring(0,lastslash+1);
            if (currdir.indexOf("~") != -1) {
                currdir = currdir.substring(currdir.indexOf("~")+1,currdir.length);
                currdir = "/priv/"+currdir
                top.location=currdir
                return;
            }
        }
    }
    top.location="$defaultdir";
}

function getufilename() {
  document.upublisher.filename.value=frameloc();
  if (document.upublisher.filename.value.indexOf('/adm/pubdir')!=-1) {
      document.upublisher.filename.value=document.dpublisher.filename.value;
  }
  document.upublisher.submit();
}

function getactionfilename() {
  document.fileaction.filename.value=frameloc();
  var test=document.fileaction.action.selectedIndex;
  if (test == 8) { // trying to create a directory
      if (document.fileaction.filename.value.indexOf('/adm/pubdir')!=-1) {
          document.fileaction.filename.value=document.dpublisher.filename.value;
      }
      if ((document.fileaction.filename.value.charAt(
           document.fileaction.filename.value.length-1)!='/') &&
           (document.fileaction.filename.value.indexOf('/adm/pubdir')==-1)) {
          alert('$lt{'mcdi'}');
          return;
      }
   }
   document.fileaction.submit();
}

function getcurseed() {
  if (parent.LONCAPAToBePublished.document.lonhomework
       &&
      parent.LONCAPAToBePublished.document.lonhomework.rndseed
       &&
      parent.LONCAPAToBePublished.document.lonhomework.rndseed.value) {
    return parent.LONCAPAToBePublished.document.lonhomework.rndseed.value;
  }
  return 0;
}

function getproblemtype() {
  if (parent.LONCAPAToBePublished.document.lonhomework) {
     var optionelement;
     var valueIndex=0;
     for (var optionIndex=0;
          optionIndex < parent.LONCAPAToBePublished.document.lonhomework.problemtype.options.length;
	  optionIndex++)
     {
         optionElement=parent.LONCAPAToBePublished.document.lonhomework.problemtype.options[optionIndex];
	 if (optionElement.selected) {
	    return optionElement.value;
         }	  
     } 	  
  }
  return 0;
}

function getpostdata() {
  document.printout.postdata.value=frameloc();
  document.printout.curseed.value=getcurseed();
  document.printout.problemtype.value=getproblemtype();
  document.printout.submit();
}
ENDONE

    if ($disp eq 'dir') {
        $r->print(<<"ENDDIR");
function getdirname() {
    document.publishdir.filename.value=frameloc();
    pubdir(document.publishdir)
}

function getsubdirname() {
    document.publishsubdir.filename.value=frameloc();
    pubrecdir(document.publishsubdir)
}

function geteditcat() {
    top.location=frameloc()+'default.meta'
}

function pubdir(theform) {
    if (confirm('Publish complete directory?')) {
        forcepub(theform)
        theform.submit();
    }
}
function pubrecdir(theform) {
    if (confirm('Publish directory and all subdirectories?')) {
        forcepub(theform);
        theform.submit();
    }
}

function forcepub(theform) {
    if (confirm('Force publication of unmodified files? - OK=yes; Cancel=No.')) {
        theform.forcerepub.value="ON";
    }
}
ENDDIR
    } else {
        $r->print(<<"ENDRES");
function getfilename() {
    document.publisher.filename.value=frameloc();
    if ((document.publisher.filename.value.charAt(
      document.publisher.filename.value.length-1)!='/') &&
      (document.publisher.filename.value.indexOf('/adm/pubdir')==-1)) {
        document.publisher.submit();
    } else {
        alert('$lt{'cnpd'}');
    }
}

function getrfilename() {
  document.rpublisher.filename.value=frameloc();
   if ((document.rpublisher.filename.value.charAt(
        document.rpublisher.filename.value.length-1)!='/') &&
       (document.rpublisher.filename.value.indexOf('/adm/pubdir')==-1)) {
        document.rpublisher.submit();
   } else {
      alert('$lt{'cnrd'}');
   }
}

function getdelfilename() {
  document.del.filename.value=frameloc();
  document.del.submit();
}
ENDRES
    }
    $r->print(<<"END");
//-->
</script>
    </head>
    <body bgcolor="#ccffdd" text='#002200' link='#003333' vlink='#006666'>
	<table border="0" align="center"><tr><th bgcolor="#004400" height="20">
	      <table border="0" cellspacing="2" cellpadding="2"><tr valign="middle">
		  <td bgcolor="#ccddaa" align="center">
END
    if ($disp eq 'dir') {
        $r->print('
                    <form name="publishdir" action="/adm/publish" target="_parent" method="post">
                      <input type="hidden" name="filename" value="" />
                      <input type="hidden" name="forcerepub" value="NO" />
                      <input type="button" value="'.$lt{'pubd'}.'" onclick="getdirname();" />
                    </form>
                 ');
    } else {
        $r->print('
                    <form name="publisher" action="/adm/publish" target="_parent" method="post">
                      <input type="hidden" name="filename" value="" />
	              <input type="button" value="'.$lt{'pubr'}.'" onclick="getfilename();" />
                    </form>
                   ');
    }
    $r->print(<<"ENDTWO");
		    </form>
		  </td>
		  <td bgcolor="#ccddaa" align="center">
		    <form name="dpublisher" action="/adm/pubdir" target="LONCAPAToBePublished" method="post">
		      <input type="hidden" name="filename" value="" />
		      <input type="button" value="$lt{'list'}" onclick="getdfilename();" />
		    </form>
		  </td>
		  <td bgcolor="#ccddaa" valign="top" align="center">
		    <form name="upublisher" action="/adm/upload" target="_parent"
			method="post" enctype="multipart/form-data">
		      <input type="hidden" name="filename" value="" />
		      <input type="file" name="upfile" size="20" />
		      <input type="button" value="$lt{'uplo'}"  onclick="getufilename();" />
		    </form>
		  </td>
		  <td rowspan="2" bgcolor="#ccddaa" align="center">
		    <form name="printout" target="_parent" action="/adm/printout" method="post" onsubmit="getpostdata();">
		      <input type="hidden" name="postdata" value="" />
		      <input type="hidden" name="curseed" value="" />
		      <input type="hidden" name="problemtype" value="" />
		      <input type="button" value="$lt{'prnt'}" onclick="getpostdata();" />
		    </form>
		  </td>
		</tr>
                <tr valign="middle">
ENDTWO
    if ($disp eq 'dir') {
        $r->print(<<"ENDDIR");
                  <td bgcolor="#ccddaa" align="center">
                    <form name="publishsubdir" action="/adm/publish" target="_parent" method="post">
                      <input type="hidden" name="filename" value="" />
                      <input type="hidden" name="forcerepub" value="NO" />
                      <input type="hidden" name="pubrec" value="1" />
                      <input type="button" value="$lt{'pubs'}" onclick="getsubdirname();" />
                    </form>
                  </td>
                  <td bgcolor="#ccddaa">
                    <form name="editcat" action="/adm/cfile" target="_parent" method="post">
                      <input type="hidden" name="filename" value="" />
                      <input type="button" value="$lt{'edit'}" onclick="geteditcat();" />
                    </form>
                  </td>
ENDDIR
    } else {
        $r->print(<<"ENDFILE"); 
		  <td bgcolor="#ccddaa" align="center">
		    <form name="rpublisher" action="/adm/retrieve" target="_parent" method="post">
		      <input type="hidden" name="filename" value="" />
		      <input type="button" value="$lt{'rtrv'}" onclick="getrfilename();" />
		    </form>
		  </td>
		  <td bgcolor="#ccddaa">
		    <form name="del" action="/adm/cfile" target="_parent" method="post">
		      <input type="hidden" name="filename" value="" />
		      <input type="hidden" name="action" value="delete" />
	              <input type="button" value="$lt{'dele'}" onclick="getdelfilename();" />
		    </form>
		  </td>
ENDFILE
    }
    $r->print(<<"ENDOPTIONS");
		  <td bgcolor="#ccddaa" align="center">
		    <form name="fileaction" action="/adm/cfile" target="_parent" method="post" onsubmit="getactionfilename();">
		      <nobr>
			<input type="hidden" name="filename" value="" />
			  <select name="action">
			    <option value="Select Action">$lt{'sela'}</option>
			    <option value="newfile">$lt{'nfil'}:</option>
			    <option value="newhtmlfile">$lt{'nhtm'}:</option>
			    <option value="newproblemfile">$lt{'nprb'}:</option>
                            <option value="newpagefile">$lt{'npag'}:</option>
                            <option value="newsequencefile">$lt{'nseq'}:</option>
                            <option value="newrightsfile">$lt{'ncrf'}:</option>
                            <option value="newstyfile">$lt{'nsty'}:</option>
			    <option value="newdir">$lt{'nsub'}:</option>
ENDOPTIONS
    if ($disp ne 'dir') {
        $r->print(<<"ENDPROBOPS");
			    <option value="rename">$lt{'renm'}:</option>
			    <option value="move">$lt{'move'}:</option>
			    <option value="copy">$lt{'copy'}:</option>
ENDPROBOPS
    }
    $r->print(<<"ENDPAGE");
			  </select>&nbsp;<input type="text" name="newfilename" value="$lt{'type'}" onfocus="if (this.value == '$lt{'type'}') this.value=''" />&nbsp;<input type="button" value="$lt{'go'}" onclick="getactionfilename();" />
		      </nobr>
		    </form>
		   </td>
		</tr>
	      </table>
	    </th>
	  </tr>
	</table>
    </body>
  </html>
ENDPAGE
}

1;

--raeburn1102690668--