[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /publisher lonpubdir.pm

raeburn raeburn at source.lon-capa.org
Wed Jul 3 17:05:49 EDT 2024


raeburn		Wed Jul  3 21:05:49 2024 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/publisher	lonpubdir.pm 
  Log:
  - For 2.11
    Backport 1.174, 1.175, 1.182
  
  
-------------- next part --------------
Index: loncom/publisher/lonpubdir.pm
diff -u loncom/publisher/lonpubdir.pm:1.160.2.5 loncom/publisher/lonpubdir.pm:1.160.2.6
--- loncom/publisher/lonpubdir.pm:1.160.2.5	Tue Aug 13 19:27:43 2019
+++ loncom/publisher/lonpubdir.pm	Wed Jul  3 21:05:49 2024
@@ -1,7 +1,7 @@
 # The LearningOnline Network with CAPA
 # Authoring Space Directory Lister
 #
-# $Id: lonpubdir.pm,v 1.160.2.5 2019/08/13 19:27:43 raeburn Exp $
+# $Id: lonpubdir.pm,v 1.160.2.6 2024/07/03 21:05:49 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -507,7 +507,14 @@
 				       acti => 'Actions for current directory',
 				       updc => 'Upload a new document',
 				       pick => 'Please select an action to perform using the new filename',
+                                       shcu => 'Shortcuts',
                                       );
+    my %js_lt = &Apache::lonlocal::texthash(
+                                       nanf => 'Name of New File',
+                                       nans => 'Name of New Subdirectory',
+                                       psfn => 'Please specify file name',
+    );
+    &js_escape(\%js_lt);
     my $mytype = $lt{'type'}; # avoid conflict with " and ' in javascript
     # Calculate free space in bytes.
     # $disk_quota is in MB and $current_disk_usage is in kB
@@ -528,21 +535,21 @@
         <input type="hidden" name="filename" value="/priv$thisdisfn/" />
       </fieldset>
     </form>
-    <form name="publishdir" method="post" action="/adm/publish" target="_parent">
+    <form name="publishdir" method="post" action="/adm/publish">
       <input type="hidden" name="pubrec" value="" />
       <input type="hidden" name="filename" value="" />
     </form>
-    <form name="printdir" method="post" action="/adm/printout" target="_parent">
+    <form name="printdir" method="post" action="/adm/printout">
       <input type="hidden" name="postdata" value="" />
     </form>
   </div>
 
   <div style="padding-bottom: 2px">
-    <form name="upublisher" enctype="multipart/form-data" method="post" action="/adm/upload" target="_parent">
+    <form name="upublisher" enctype="multipart/form-data" method="post" action="/adm/upload">
       <fieldset>
         <legend>$lt{'updc'}</legend>
         <input type="hidden" name="filename" value="/priv$thisdisfn/" />
-        <input type="file" name="upfile" class="LC_flUpload" size="20" />
+        <input type="file" name="upfile" class="LC_flUpload" />
         <input type="hidden" id="LC_free_space" value="$free_space" />
         <input type="button" value="$lt{'uplo'}"  onclick="checkUpload(this.form)" />
       </fieldset>
@@ -550,7 +557,7 @@
   </div>
 
   <div>
-    <form name="fileaction" method="post" action="/adm/cfile" target="_parent">
+    <form name="fileaction" method="post" action="/adm/cfile">
       <fieldset>
               <legend>$lt{'crea'}</legend>
 	      <span class="LC_nobreak">
@@ -577,9 +584,9 @@
                     <option value="newtaskfile">$lt{'nbt'}:</option>
                     <option value="newlibraryfile">$lt{'nlib'}:</option>
 	            <option value="newdir">$lt{'nsub'}:</option>
-		  </select> <input type="text" name="newfilename" placeholder="$lt{'type'}" value="" onfocus="if (this.value == is.empty()) this.value=''" /> <input type="button" value="Go" onclick="validate_go();" />
+		  </select> <input type="text" id="newnameid" name="newfilename" placeholder="$lt{'type'}" value="" onfocus="if (this.value == is.empty()) this.value=''" /> <input type="button" value="Go" onclick="validate_go();" />
                 <br />
-                <span>Quickactions:
+                <span>$lt{'shcu'}:
                  <input type="hidden" name="mode"/>
                  <a href="javascript:void(0)" onclick="javascript:validate_action('blank')">
                     <img src="/adm/lonIcons/unknown.gif" title="Create blank problem file"></a>
@@ -592,26 +599,36 @@
                 </span>
                  <script type="text/javascript">
                      function validate_action(action){
-
-                         if (document.getElementsByName(\'newfilename\')[0].value != \'\'){
-                             if (action == "blank") {
-                                                                 document.fileaction.action.value=\'newproblemfile\';
-                                                                 document.fileaction.mode.value=\'blank\';
-                                                         } else if (action == "problemtempl") {
-                                                                 document.fileaction.action.value=\'newproblemfile\';
-                                 validate_go();
-                             } else if (action == "blankhtml") {
-                                 document.fileaction.action.value=\'newhtmlfile\';
-                                 validate_go();
-                             } else if (action == "folder") {
-                                 document.fileaction.action.value=\'newdir\';
-                                 document.fileaction.mode.value=\'folder\';
+                         if (document.getElementById('newnameid')) {
+                             if (document.getElementById('newnameid').value == '') {
+                                 var newname;
+                                 var prompttext = "$js_lt{'nanf'}";
+                                 if (action == 'folder') {
+                                     prompttext = "$js_lt{'nans'}";
+                                 }
+                                 newname=prompt(prompttext);
+                                 if (newname != '') {
+                                     document.getElementById('newnameid').value = newname;
+                                 }
+                             }
+                             if (document.getElementById('newnameid').value != '') {
+                                 if (action == 'blank') {
+                                     document.fileaction.action.value='newproblemfile';
+                                     document.fileaction.mode.value='blank';
+                                 } else if (action == 'problemtempl') {
+                                     document.fileaction.action.value='newproblemfile';
+                                     validate_go();
+                                 } else if (action == 'blankhtml') {
+                                     document.fileaction.action.value='newhtmlfile';
+                                     validate_go();
+                                 } else if (action == 'folder') {
+                                     document.fileaction.action.value='newdir';
+                                     document.fileaction.mode.value='folder';
+                                 }
+                                 fileaction.submit();
+                             } else {
+                                 alert("$js_lt{'psfn'}");
                              }
-                             fileaction.submit();
-                         } else {
-                             alert(\'Please specify file name.\');
-                             // TODO: ask for filename? if so, do some refactoring
-
                          }
                      }
                  </script>
@@ -626,26 +643,26 @@
 sub resourceactions {
     my ($r,$uname,$udom,$thisdisfn) = @_;
     $r->print(<<END);
-       <form name="moveresource" action="/adm/cfile" target="_parent" method="post">
+       <form name="moveresource" action="/adm/cfile" method="post">
          <input type="hidden" name="filename" value="" />
          <input type="hidden" name="newfilename" value="" />
          <input type="hidden" name="action" value="" />
        </form>
-       <form name="delresource" action="/adm/cfile" target="_parent" method="post">
+       <form name="delresource" action="/adm/cfile" method="post">
          <input type="hidden" name="filename" value="" />
          <input type="hidden" name="action" value="delete" />
        </form>
-       <form name="pubresource" action="/adm/publish" target="_parent" method="post">
+       <form name="pubresource" action="/adm/publish" method="post">
          <input type="hidden" name="filename" value="" />
          <input type="hidden" name="makeobsolete" value="0" />
        </form>
-       <form name="printresource" action="/adm/printout" target="_parent" method="post">
+       <form name="printresource" action="/adm/printout" method="post">
            <input type="hidden" name="postdata" value="" />
        </form>
-       <form name="retrieveres" action="/adm/retrieve" target="_parent" method="post">
+       <form name="retrieveres" action="/adm/retrieve" method="post">
            <input type="hidden" name="filename" value="" />
        </form>
-       <form name="cleanup" action="/adm/cleanup" target="_parent" method="post">
+       <form name="cleanup" action="/adm/cleanup" method="post">
            <input type="hidden" name="filename" value="" />
        </form>
 END
@@ -722,8 +739,7 @@
             $disfilename = '<i>'.&mt('Parent Directory').'</i>';
         } else {
             $actionitem = 
-                    '<form name="dirselect_'.$$numdir.
-                    '" action="/adm/publish" target="_parent">'.
+                    '<form name="dirselect_'.$$numdir.'" action="/adm/publish">'. 
                     '<select name="diraction" onchange="SetPubDir(this.form,document)">'.
                       '<option selected="selected">'.&mt('Select action').'</option>'.
                       '<option value="open">'.&mt('Open').'</option>'.
@@ -742,7 +758,7 @@
 		  '<td><img src="'.
 		  $Apache::lonnet::perlvar{'lonIconsURL'}.'/navmap.folder.closed.gif" alt="folder" /></td>'.
 		  '<td>'.$actionitem.'</td>'.
-		  '<td><span class="LC_filename"><a href="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/" target="_parent">'.
+		  '<td><span class="LC_filename"><a href="'.&HTML::Entities::encode($here.'/'.$dirname,'<>&"').'/">'.
 		  $disfilename.'</a></span></td>'.
 		        '<td colspan="3">'.($kaputt?&Apache::lonhtmlcommon::authorbombs($targetdir.'/'.$disfilename.'/'):'').$Apache::lonpublisher::metadatafields{'title'});
 	if ($Apache::lonpublisher::metadatafields{'subject'} ne '') {
@@ -873,7 +889,7 @@
 
     my $editlink='';
     my $editlink2='';
-    if ($filename=~/\.(xml|html|htm|xhtml|xhtm|sty)$/) {
+    if ($filename=~/\.(xml|html|htm|xhtml|xhtm|sty|txt|css|js)$/) {
 	$editlink=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
     }
     if ($filename=~/$LONCAPA::assess_re/) {
@@ -881,10 +897,10 @@
 	$editlink2=' <br />(<a href="'.$linkdir.'/'.$filename.'?editmode=Edit&problemmode=edit">'.&mt('Edit').'</a>)';
     }
     if ($filename=~/\.(problem|exam|quiz|assess|survey|form|library|xml|html|htm|xhtml|xhtm|sty)$/) {
-	$editlink.=' (<a href="/adm/cleanup?filename='.$linkfilename.'" target="_parent">'.&mt('Clean Up').')</a>';
+	$editlink.=' (<a href="/adm/cleanup?filename='.$linkfilename.'">'.&mt('Clean Up').')</a>';
     }
     if ($filename=~/\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/) {
-	$editlink=' (<a target="_parent" href="/adm/cfile?decompress='.$linkfilename.'">'.&mt('Decompress').'</a>)';
+	$editlink=' (<a href="/adm/cfile?decompress='.$linkfilename.'">'.&mt('Decompress').'</a>)';
     }
     my $publish_button = (-e $resdir.'/'.$filename) ? &mt('Re-publish') : &mt('Publish');
     my $pub_select = '';
@@ -894,7 +910,7 @@
 		      '<img src="'.&Apache::loncommon::icon($filename).'" alt="" />').'</td>'.
               '<td>'.$pub_select.'</td>'.
 	      '<td><span class="LC_filename">'.
-	      '<a href="'.$linkdir.'/'.$filename.'" target="_parent">'.
+	      '<a href="'.$linkdir.'/'.$filename.'">'.
                $filename.'</a></span>'.$editlink2.$editlink.
 	      '</td>'.
 	      '<td>'.$title.'</td>'.


More information about the LON-CAPA-cvs mailing list