--- loncom/interface/londocs.pm	2013/12/18 23:03:43	1.572
+++ loncom/interface/londocs.pm	2014/03/09 15:49:48	1.578
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # Documents
 #
-# $Id: londocs.pm,v 1.572 2013/12/18 23:03:43 raeburn Exp $
+# $Id: londocs.pm,v 1.578 2014/03/09 15:49:48 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -46,6 +46,7 @@ use Apache::lonsimplepage();
 use HTML::Entities;
 use HTML::TokeParser;
 use GDBM_File;
+use File::MMagic;
 use Apache::lonlocal;
 use Cwd;
 use LONCAPA qw(:DEFAULT :match);
@@ -301,14 +302,14 @@ ENDJS
                 if ($contents{content}) {
                     $content .= '
 <div class="LC_Box">
-<h4 class="LC_hcell">Content</h4>'.
+<h4 class="LC_hcell">'.&mt('Content').'</h4>'.
 $contents{content}.'
 </div>';
                 }
                 if ($contents{webreferences}) {
                     $content .= ' 
 <div class="LC_Box">
-<h4 class="LC_hcell">Web References</h4>'.
+<h4 class="LC_hcell">'.&mt('Web References').'</h4>'.
 $contents{webreferences}.'
 </div>';
                 }
@@ -1087,6 +1088,7 @@ sub update_paste_buffer {
     }
     &Apache::lonnet::appenv(\%addtoenv);
     delete($env{'form.markcopy'});
+    return;
 }
 
 sub recurse_uploaded_maps {
@@ -1124,6 +1126,7 @@ sub print_paste_buffer {
 
     my @currpaste = split(/,/,$env{'docs.markedcopies'});
     my ($pasteitems,@pasteable);
+    my $clipboardcount = 0;
 
 # Construct identifiers for current contents of user's paste buffer
     foreach my $suffix (@currpaste) {
@@ -1132,6 +1135,7 @@ sub print_paste_buffer {
         my $url = $env{'docs.markedcopy_url_'.$suffix};
         if (($cid =~ /^$match_domain\_$match_courseid$/) &&
             ($url ne '')) {
+            $clipboardcount ++;
             my ($is_external,$othercourse,$fromsupp,$is_uploaded_map,$parent,
                 $canpaste,$nopaste,$othercrs,$areachange);
             my $extension = (split(/\./,$env{'docs.markedcopy_url_'.$suffix}))[-1];
@@ -1225,11 +1229,23 @@ sub print_paste_buffer {
         $pasteitems .= '<div style="padding:0;clear:both;margin:0;border:0"></div>';
         $form_start = '<form name="pasteform" action="/adm/coursedocs" method="post" onsubmit="return validateClipboard();">';
         if (@pasteable) {
-            $buttons = '<input type="submit" name="pastemarked" value="'.&mt('Paste selected').'" />'.('&nbsp;'x2);
+            my $value = &mt('Paste to current folder');
+            if ($container eq 'page') {
+                $value = &mt('Paste to current page');
+            } 
+            $buttons = '<input type="submit" name="pastemarked" value="'.$value.'" />'.('&nbsp;'x2);
         }
-        $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Clear selected').'" />'.
-                    '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />';
-        $form_end = '</form>';
+        $buttons .= '<input type="submit" name="clearmarked" value="'.&mt('Remove from clipboard').'" />'.('&nbsp;'x2);
+        if ($clipboardcount > 1) {
+            $buttons .=
+                '<span style="text-decoration:line-through">'.('&nbsp;'x20).'</span>'.('&nbsp;'x2).
+                '<input type="button" name="checkallclip" value="'.&mt('Check all').'" style="height:20px;" onclick="checkClipboard();" />'.
+                ('&nbsp;'x2).
+                '<input type="button" name="uncheckallclip" value="'.&mt('Uncheck all').'" style="height:20px;" onclick="uncheckClipboard();" />'.
+                ('&nbsp;'x2);
+        }
+        $form_end = '<input type="hidden" name="folderpath" value="'.&HTML::Entities::encode($env{'form.folderpath'},'<>&"').'" />'.
+                    '</form>';
     } else {
         $pasteitems = &mt('Clipboard is empty');
     }
@@ -1383,6 +1399,24 @@ function validateClipboard() {
     }
 }
 
+function checkClipboard() {
+    if (document.pasteform.pasting.length > 1) {
+        for (var i=0; i<document.pasteform.pasting.length; i++) {
+            document.pasteform.pasting[i].checked = true;
+        } 
+    }
+    return;
+}
+
+function uncheckClipboard() {
+    if (document.pasteform.pasting.length >1) {
+        for (var i=0; i<document.pasteform.pasting.length; i++) {
+            document.pasteform.pasting[i].checked = false;
+        }
+    }
+    return;
+}
+
 END
 
 }
@@ -3143,6 +3177,8 @@ sub process_file_upload {
         $quotatype = 'community';    
     } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.instcode'}) {
         $quotatype = 'official';
+    } elsif ($env{'course.'.$coursedom.'_'.$coursenum.'.internal.textbook'}) {
+        $quotatype = 'textbook';
     }
     if (&Apache::loncommon::get_user_quota($coursenum,$coursedom,'course',$quotatype)) {
         $filesize = int($filesize/1000); #expressed in kb
@@ -3245,7 +3281,8 @@ sub process_file_upload {
                     $$upload_output .= &mt('No embedded items identified').'<br />';
                 }
                 $$upload_output = '<div id="uploadfileresult">'.$$upload_output.'</div>';
-            } elsif (&Apache::loncommon::is_archive_file($mimetype)) {
+            } elsif ((&Apache::loncommon::is_archive_file($mimetype)) &&
+                     ($env{'form.uploaddoc.filename'} =~ /\.(zip|tar|bz2|gz|tar.gz|tar.bz2|tgz)$/i)) {
                 $nextphase = 'decompress_uploaded';
                 my $position = scalar(@LONCAPA::map::order)-1;
                 my $noextract = &return_to_editor();
@@ -3320,6 +3357,7 @@ sub entryline {
 
     $renametitle=~s/\\/\\\\/g;
     $renametitle=~s/\&quot\;/\\\"/g;
+    $renametitle=~s/\&#39;/\\\'/g;
     $renametitle=~s/ /%20/g;
     my $line=&Apache::loncommon::start_data_table_row();
     my ($form_start,$form_end,$form_common,$form_param);
@@ -4813,7 +4851,11 @@ sub handler {
                 'title' => 'Title',
                 'comment' => 'Comment',
                 'parse' => 'Upload embedded images/multimedia files if HTML file',
-					  );
+                'bb5'      => 'Blackboard 5',
+                'bb6'      => 'Blackboard 6',
+                'angel5'   => 'ANGEL 5.5',
+                'webctce4' => 'WebCT 4 Campus Edition',
+        );
 # -----------------------------------------------------------------------------
 	my $fileupload=(<<FIUP);
 	$lt{'file'}:<br />
@@ -4844,10 +4886,10 @@ CHBO
         $lt{'cms'}:&nbsp; 
         <select name="source">
         <option value="-1" selected="selected">$lt{'se'}</option>
-        <option value="bb5">Blackboard 5</option>
-        <option value="bb6">Blackboard 6</option>
-        <option value="angel5">ANGEL 5.5</option>
-        <option value="webctce4">WebCT 4 Campus Edition</option>
+        <option value="bb5">$lt{'bb5'}</option>
+        <option value="bb6">$lt{'bb6'}</option>
+        <option value="angel5">$lt{'angel5'}</option>
+        <option value="webctce4">$lt{'webctce4'}</option>
         </select>
         <input type="hidden" name="folder" value="$imsfolder" />
         </p>
@@ -6652,7 +6694,7 @@ ENDINJECT
 sub dump_switchserver_js {
     my @hosts = @_;
     my %lt = &Apache::lonlocal::texthash(
-        dump => 'Copying Content to Authoring Space requires switching server.',
+        dump => 'Copying content to Authoring Space requires switching server.',
         swit => 'Switch server?',
         duco => 'Copying Content to Authoring Space',
         yone => 'You need to switch to a server housing an Authoring Space for which you are author or co-author.',