[LON-CAPA-cvs] cvs: loncom(version_2_11_X) /interface londocs.pm
raeburn
raeburn at source.lon-capa.org
Wed Dec 12 19:51:34 EST 2012
raeburn Thu Dec 13 00:51:34 2012 EDT
Modified files: (Branch: version_2_11_X)
/loncom/interface londocs.pm
Log:
- For 2.11
- Backport 1.501
-------------- next part --------------
Index: loncom/interface/londocs.pm
diff -u loncom/interface/londocs.pm:1.484.2.11 loncom/interface/londocs.pm:1.484.2.12
--- loncom/interface/londocs.pm:1.484.2.11 Wed Dec 12 23:12:27 2012
+++ loncom/interface/londocs.pm Thu Dec 13 00:51:34 2012
@@ -1,7 +1,7 @@
# The LearningOnline Network
# Documents
#
-# $Id: londocs.pm,v 1.484.2.11 2012/12/12 23:12:27 raeburn Exp $
+# $Id: londocs.pm,v 1.484.2.12 2012/12/13 00:51:34 raeburn Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -1743,7 +1743,7 @@
sub editor {
my ($r,$coursenum,$coursedom,$folder,$allowed,$upload_output,$crstype,
- $supplementalflag,$orderhash,$iconpath)=@_;
+ $supplementalflag,$orderhash,$iconpath,$uploadtag)=@_;
my $container= ($env{'form.pagepath'}) ? 'page'
: 'sequence';
@@ -1899,7 +1899,8 @@
unless ($name) { $name=(split(/\//,$url))[-1]; }
unless ($name) { $idx++; next; }
$output .= &entryline($idx,$name,$url,$folder,$allowed,$res,
- $coursenum,$crstype);
+ $coursenum,$coursedom,$crstype,
+ $uploadtag,$supplementalflag);
$idx++;
$shown++;
}
@@ -2116,7 +2117,8 @@
# --------------------------------------------------------------- An entry line
sub entryline {
- my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$crstype)=@_;
+ my ($index,$title,$url,$folder,$allowed,$residx,$coursenum,$coursedom,
+ $crstype,$uploadtag,$supplementalflag)=@_;
my ($foldertitle,$pagetitle,$renametitle);
if (&is_supplemental_title($title)) {
($title,$foldertitle,$renametitle) = &Apache::loncommon::parse_supplemental_title($title);
@@ -2130,7 +2132,6 @@
my $orderidx=$LONCAPA::map::order[$index];
-
$renametitle=~s/\\/\\\\/g;
$renametitle=~s/\"\;/\\\"/g;
$renametitle=~s/ /%20/g;
@@ -2149,8 +2150,18 @@
$type = $container = 'page';
$esc_path=&escape($env{'form.pagepath'});
$path = &HTML::Entities::encode($env{'form.pagepath'},'<>&"');
- $symb=&escape($env{'form.pagesymb'});
}
+ if (!$supplementalflag && $residx) {
+ my $currurl = $url;
+ $currurl =~ s{^http(|s)(:|:)//}{/adm/wrapper/ext/};
+ my $path = 'uploaded/'.
+ $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
+ $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
+ $symb = &Apache::lonnet::encode_symb($path.$folder.".$container",
+ $residx,
+ &Apache::lonnet::declutter($currurl));
+ }
+ my %lt;
if ($allowed) {
my $incindex=$index+1;
my $selectbox='';
@@ -2173,13 +2184,20 @@
}
$selectbox.='</select>';
}
- my %lt=&Apache::lonlocal::texthash(
+ %lt=&Apache::lonlocal::texthash(
'up' => 'Move Up',
'dw' => 'Move Down',
'rm' => 'Remove',
'ct' => 'Cut',
'rn' => 'Rename',
- 'cp' => 'Copy');
+ 'cp' => 'Copy',
+ 'ex' => 'External Resource',
+ 'ed' => 'Edit',
+ 'pr' => 'Preview',
+ 'sv' => 'Save',
+ 'ul' => 'URL',
+ 'ti' => 'Title',
+ );
my $nocopy=0;
my $nocut=0;
my $noremove=0;
@@ -2285,12 +2303,12 @@
<td>
<div class="LC_docs_entry_move">
<a href='/adm/coursedocs?cmd=up_$index&${type}path=$esc_path&${type}symb=$symb'>
- <img src="${iconpath}move_up.gif" alt='$lt{'up'}' class="LC_icon" />
+ <img src="${iconpath}move_up.gif" alt="$lt{'up'}" class="LC_icon" />
</a>
</div>
<div class="LC_docs_entry_move">
<a href='/adm/coursedocs?cmd=down_$index&${type}path=$esc_path&${type}symb=$symb'>
- <img src="${iconpath}move_down.gif" alt='$lt{'dw'}' class="LC_icon" />
+ <img src="${iconpath}move_down.gif" alt="$lt{'dw'}" class="LC_icon" />
</a>
</div>
</td>
@@ -2341,44 +2359,38 @@
}
}
+ my $editlink;
my $orig_url = $url;
$orig_url=~s{http(:|:)//https(:|:)//}{https$2//};
my $external = ($url=~s{^http(|s)(:|:)//}{/adm/wrapper/ext/});
- if ((!$isfolder) && ($residx) && ($folder!~/supplemental/) && (!$ispage)) {
- my $symb=&Apache::lonnet::symbclean(
- &Apache::lonnet::declutter('uploaded/'.
- $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
- $env{'course.'.$env{'request.course.id'}.'.num'}.'/'.$folder.
- '.sequence').
- '___'.$residx.'___'.
- &Apache::lonnet::declutter($url));
- (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
- $url=&Apache::lonnet::clutter($url);
- if ($url=~/^\/*uploaded\//) {
- $url=~/\.(\w+)$/;
- my $embstyle=&Apache::loncommon::fileembstyle($1);
- if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
- $url='/adm/wrapper'.$url;
- } elsif ($embstyle eq 'ssi') {
- #do nothing with these
- } elsif ($url!~/\.(sequence|page)$/) {
- $url='/adm/coursedocs/showdoc'.$url;
- }
- } elsif ($url=~m|^/ext/|) {
- $url='/adm/wrapper'.$url;
- $external = 1;
- }
- if (&Apache::lonnet::symbverify($symb,$url)) {
- $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
- } else {
- $url='';
+ if (!$supplementalflag && $residx && $symb) {
+ if ($container eq 'page') {
+ $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
+ $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
+ }
+ if ((!$isfolder) && (!$ispage)) {
+ (undef,undef,$url)=&Apache::lonnet::decode_symb($symb);
+ $url=&Apache::lonnet::clutter($url);
+ if ($url=~/^\/*uploaded\//) {
+ $url=~/\.(\w+)$/;
+ my $embstyle=&Apache::loncommon::fileembstyle($1);
+ if (($embstyle eq 'img') || ($embstyle eq 'emb')) {
+ $url='/adm/wrapper'.$url;
+ } elsif ($embstyle eq 'ssi') {
+ #do nothing with these
+ } elsif ($url!~/\.(sequence|page)$/) {
+ $url='/adm/coursedocs/showdoc'.$url;
+ }
+ } elsif ($url=~m|^/ext/|) {
+ $url='/adm/wrapper'.$url;
+ $external = 1;
+ }
+ if (&Apache::lonnet::symbverify($symb,$url)) {
+ $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
+ } else {
+ $url='';
+ }
}
- if ($container eq 'page') {
- my $symb=$env{'form.pagesymb'};
-
- $url=&Apache::lonnet::clutter((&Apache::lonnet::decode_symb($symb))[2]);
- $url.=(($url=~/\?/)?'&':'?').'symb='.&escape($symb);
- }
}
my ($rand_pick_text,$rand_order_text);
if ($isfolder || $extension eq 'sequence') {
@@ -2424,23 +2436,50 @@
my $folderpath=$env{'form.folderpath'};
if ($folderpath) { $pagepath = $folderpath.'&' };
$pagepath.=$pagearg.'&'.$pagename;
- my $symb=$env{'form.pagesymb'};
- if (!$symb) {
- my $path='uploaded/'.
- $env{'course.'.$env{'request.course.id'}.'.domain'}.'/'.
- $env{'course.'.$env{'request.course.id'}.'.num'}.'/';
- $symb=&Apache::lonnet::encode_symb($path.$folder.'.sequence',
- $residx,
- $path.$pagearg.'.page');
- }
$url.='pagepath='.&escape($pagepath).
'&pagesymb='.&escape($symb);
}
- if (($external) && ($allowed)) {
- my $form = ($folder =~ /^default/)? 'newext' : 'supnewext';
- $external = ' <a class="LC_docs_ext_edit" href="javascript:edittext(\''.$form.'\',\''.$residx.'\',\''.&escape($title).'\',\''.&escape($orig_url).'\');" >'.&mt('Edit').'</a>';
- } else {
- undef($external);
+ if ($allowed) {
+ my $fileloc =
+ &Apache::lonnet::declutter(&Apache::lonnet::filelocation('',$orig_url));
+
+ if ($external) {
+ $editlink = <<"EXTLNK";
+
+ <a class="LC_docs_ext_edit" href="javascript:editext('$residx');">
+ $lt{'ed'}</a>
+ <form action="/adm/coursedocs" method="post" name="editext_$residx">
+ <fieldset id="uploadext$residx" style="display: none;" />
+ <input type="hidden" name="active" value="aa" />
+ <span class="LC_nobreak">
+ <span class="LC_docs_ext_edit">$lt{'ul'} </span>
+ <input type="text" size="40" name="exturl" id="exturl_$residx" value="$orig_url" />
+ <a class="LC_docs_ext_edit" href="javascript:extUrlPreview('exturl_$residx');">$lt{'pr'}</a></span>
+ </span><br />
+ <span class="LC_nobreak">
+ <span class="LC_docs_ext_edit">$lt{'ti'} </span>
+ <input type="text" size="40" name="exttitle" value="$title" />
+ $uploadtag
+ <input type="hidden" name="importdetail" value="" />
+ <input type="button" value="$lt{'sv'}" onclick="javascript:setExternal(this.form,'$residx')" />
+ </span>
+ </fieldset>
+ </form>
+EXTLNK
+ } else {
+ my ($cfile,$home,$switchserver,$uploaded) =
+ &Apache::lonnet::can_edit_resource($fileloc,$coursenum,$coursedom);
+ if (($cfile ne '') && ($symb ne '')) {
+ my $jscall =
+ &Apache::lonhtmlcommon::jump_to_editres($cfile,$home,
+ $switchserver,
+ $uploaded,$symb);
+ if ($jscall) {
+ $editlink = ' <a class="LC_docs_ext_edit" href="javascript:'.
+ $jscall.'" >'.&mt('Edit').'</a>';
+ }
+ }
+ }
}
my $reinit;
if ($crstype eq 'Community') {
@@ -2466,7 +2505,7 @@
} else {
$line.=$title.' <span class="LC_docs_reinit_warn">'.$reinit.'</span>';
}
- $line.=$external."</td>";
+ $line.=$editlink."</td>";
$rand_pick_text = ' ' if ($rand_pick_text eq '');
$rand_order_text = ' ' if ($rand_order_text eq '');
if (($allowed) && ($folder!~/^supplemental/)) {
@@ -3029,9 +3068,9 @@
sub create_list_elements {
my @formarr = @_;
my $list = '';
- for my $button (@formarr){
- for my $picture(keys %$button) {
- $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text'});
+ foreach my $button (@formarr){
+ foreach my $picture (keys(%{$button})) {
+ $list .= &Apache::lonhtmlcommon::htmltag('li', $picture.' '.$button->{$picture}, {class => 'LC_menubuttons_inline_text', id => ''});
}
}
return $list;
@@ -3100,7 +3139,8 @@
'Adding_External_Resource','Navigate_Content',
'Adding_Folders','Docs_Overview', 'Load_Map',
'Supplemental','Score_Upload_Form','Adding_Pages',
- 'Importing_LON-CAPA_Resource','Uploading_From_Harddrive',
+ 'Importing_LON-CAPA_Resource','Importing_IMS_Course',
+ 'Uploading_From_Harddrive',
'Check_Resource_Versions','Verify_Content') {
$help{$topic}=&Apache::loncommon::help_open_topic('Docs_'.$topic);
}
@@ -3394,6 +3434,8 @@
if ($env{'docs.markedcopy_url'}) {
$script .= &paste_popup_js();
}
+ my $confirm_switch = &mt("Editing requires switching to the resource's home server.").'\n'.
+ &mt('Switch server?');
}
# -------------------------------------------------------------------- Body tag
$script = '<script type="text/javascript">'."\n"
@@ -3486,7 +3528,8 @@
'upls' => 'Upload a new supplemental '.lc($crstype).' document',
'impp' => 'Import a document',
'copm' => 'All documents out of a published map into this folder',
- 'upld' => 'Import Document',
+ 'upfi' => 'Upload File',
+ 'upld' => 'Import Content',
'srch' => 'Search',
'impo' => 'Import',
'lnks' => 'Import from Stored Links',
@@ -3509,9 +3552,14 @@
'abou' => 'Personal Information Page for a User',
'imsf' => 'IMS Import',
'imsl' => 'Import IMS package',
+ 'cms' => 'Origin of IMS package',
'file' => 'File',
+ 'se' => 'Select',
'title' => 'Title',
'comment' => 'Comment',
+ 'url' => 'URL',
+ 'prev' => 'Preview',
+ 'lnk' => 'Add Link',
'parse' => 'Upload embedded images/multimedia files if HTML file',
'nd' => 'Upload Document',
'pm' => 'Published Map',
@@ -3532,10 +3580,41 @@
<input type="checkbox" name="parserflag" checked="checked" /> $lt{'parse'}
</label>
CHBO
-
- my $fileuploada = "<br clear='all' /><input type='submit' value='".$lt{'upld'}."' /> $help{'Uploading_From_Harddrive'}";
- my $fileuploadform=(<<FUFORM);
- <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
+ my $imsfolder = $env{'form.folder'};
+ if ($imsfolder eq '') {
+ $imsfolder = 'default';
+ }
+ my $imspform=(<<IMSFORM);
+ <a class="LC_menubuttons_link" href="javascript:toggleUpload('ims');">
+ $lt{'imsf'}</a> $help{'Importing_IMS_Course'}
+ <form name="uploadims" action="/adm/imsimportdocs" method="post" enctype="multipart/form-data" target="IMSimport">
+ <fieldset id="uploadimsform" style="display: none;" />
+ <legend>$lt{'imsf'}</legend>
+ $fileupload
+ <br />
+ <p>
+ $lt{'cms'}:
+ <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>
+ </select>
+ <input type="hidden" name="folder" value="$imsfolder" />
+ </p>
+ <input type="hidden" name="phase" value="one" />
+ <input type="button" value="$lt{'imsl'}" onclick="makeims(this.form);" />
+ </fieldset>
+ </form>
+IMSFORM
+
+ my $fileuploadform=(<<FUFORM);
+ <a class="LC_menubuttons_link" href="javascript:toggleUpload('doc');">
+ $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
+ <form name="uploaddocument" action="/adm/coursedocs" method="post" enctype="multipart/form-data">
+ <fieldset id="uploaddocform" style="display: none;" />
+ <legend>$lt{'upfi'}</legend>
<input type="hidden" name="active" value="aa" />
$fileupload
<br />
@@ -3547,8 +3626,11 @@
<span class="LC_nobreak" style="float:left">
$checkbox
</span>
+ <br clear="all" />
+ <input type="submit" value="$lt{'upld'}" />
+ </fieldset>
+ </form>
FUFORM
- $fileuploadform .= $fileuploada.'</form>';
my $simpleeditdefaultform=(<<SEDFFORM);
<form action="/adm/coursedocs" method="post" name="simpleeditdefault">
@@ -3572,10 +3654,21 @@
SEDFFORM
my $extresourcesform=(<<ERFORM);
+ <a class="LC_menubuttons_link" href="javascript:toggleUpload('ext');">$lt{'extr'}</a>$help{'Adding_External_Resource'}
<form action="/adm/coursedocs" method="post" name="newext">
+ <fieldset id="uploadextform" style="display: none;" />
+ <legend>$lt{'extr'}</legend>
+ <input type="hidden" name="active" value="aa" />
+ $lt{'url'}:<br />
+ <input type="text" size="60" name="exturl" id="exturl" value="http://" />
+ <input type="button" name="view" value="$lt{'prev'}" onclick="javascript:extUrlPreview('exturl');" /><br />
+ $lt{'title'}:<br />
+ <input type="text" size="60" name="exttitle" value="$lt{'extr'}" />
$uploadtag
+ <br />
<input type="hidden" name="importdetail" value="" />
- <a class="LC_menubuttons_link" href="javascript:makenewext('newext');">$lt{'extr'}</a>$help{'Adding_External_Resource'}
+ <input type="button" value="$lt{'lnk'}" onclick="javascript:setExternal(this.form,0)" />
+ </fieldset>
</form>
ERFORM
@@ -3644,13 +3737,6 @@
}
my $readfile='/uploaded/'.$coursedom.'/'.$coursenum.'/'.$folder.'.'.$container;
- my $imspform=(<<IMSPFORM);
- <form action="/adm/imsimportdocs" method="post" name="ims">
- <input type="hidden" name="folder" value="$folder" />
- <a class="LC_menubuttons_link" href="javascript:makeims();">$lt{'imsf'}</a>
- </form>
-IMSPFORM
-
my $newnavform=(<<NNFORM);
<form action="/adm/coursedocs" method="post" name="newnav">
<input type="hidden" name="active" value="cc" />
@@ -3805,10 +3891,13 @@
$specialdocumentsform = &create_form_ul(&create_list_elements(@specialdocumentsforma));
+
my @importdoc = (
- {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'newext\');" />'=>$extresourcesform},
- {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:makeims();" />'=>$imspform},);
- $fileuploadform = &create_form_ul(&create_list_elements(@importdoc)) . '<hr id="cc_hrule" style="width:0px;text-align:left;margin-left:0" />' . $fileuploadform;
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="toggleUpload(\'ext\');" />'=>$extresourcesform},
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/ims.png" alt="'.$lt{imsf}.'" onclick="javascript:toggleUpload(\'ims\');" />'=>$imspform},
+ {'<img class="LC_noBorder_LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'doc\');" />'=>$fileuploadform,
+ });
+ $fileuploadform = &create_form_ul(&create_list_elements(@importdoc));
@gradingforma=(
{'<img class="LC_noBorder LC_middle" src="/res/adm/pages/simpprob.png" alt="'.$lt{sipr}.'" onclick="javascript:makesmpproblem();" />'=>$newsmpproblemform},
@@ -3841,7 +3930,7 @@
$hadchanges=0;
unless (($supplementalflag || $toolsflag)) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
- $supplementalflag,\%orderhash,$iconpath);
+ $supplementalflag,\%orderhash,$iconpath,$uploadtag);
if ($error) {
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
}
@@ -3873,9 +3962,12 @@
my $path = &HTML::Entities::encode($env{'form.folderpath'},'<>&"');
- my $supupdocformbtn = "<input type='submit' value='".$lt{'upld'}."' />$help{'Uploading_From_Harddrive'}";
my $supupdocform=(<<SUPDOCFORM);
+ <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppdoc');">
+ $lt{'upfi'}</a> $help{'Uploading_From_Harddrive'}
<form action="/adm/coursedocs" method="post" name="supuploaddocument" enctype="multipart/form-data">
+ <fieldset id="uploadsuppdocform" style="display: none;" />
+ <legend>$lt{'upfi'}</legend>
<input type="hidden" name="active" value="ee" />
$fileupload
<br />
@@ -3889,8 +3981,8 @@
<br />
<input type="hidden" name="folderpath" value="$path" />
<input type="hidden" name="cmd" value="upload_supplemental" />
-SUPDOCFORM
- $supupdocform .= &create_form_ul(&Apache::lonhtmlcommon::htmltag('li',$supupdocformbtn,{class => 'LC_menubuttons_inline_text'}))."</form>";
+ <input type='submit' value="$lt{'upld'}" />
+ </form>
my $supnewfolderform=(<<SNFFORM);
<form action="/adm/coursedocs" method="post" name="supnewfolder">
@@ -3902,15 +3994,24 @@
</form>
SNFFORM
-
- my $supnewextform=(<<SNEFORM);
- <form action="/adm/coursedocs" method="post" name="supnewext">
- <input type="hidden" name="active" value="ff" />
- <input type="hidden" name="folderpath" value="$path" />
- <input type="hidden" name="importdetail" value="" />
- <a class="LC_menubuttons_link" href="javascript:makenewext('supnewext');">$lt{'extr'}</a> $help{'Adding_External_Resource'}
- </form>
-SNEFORM
+ my $supextform=(<<ERFORM);
+ <a class="LC_menubuttons_link" href="javascript:toggleUpload('suppext');">$lt{'extr'}</a>$help{'Adding_External_Resource'}
+ <form action="/adm/coursedocs" method="post" name="newsuppext">
+ <fieldset id="uploadsuppextform" style="display: none;" />
+ <legend>$lt{'extr'}</legend>
+ <input type="hidden" name="active" value="ee" />
+ $lt{'url'}:<br />
+ <input type="text" size="60" name="exturl" id="exturl" value="http://" />
+ <input type="button" name="view" value="$lt{'prev'}" onclick="javascript:extUrlPreview('exturl');" /><br />
+ $lt{'title'}:<br />
+ <input type="text" size="60" name="exttitle" value="$lt{'extr'}" />
+ $uploadtag
+ <br />
+ <input type="hidden" name="importdetail" value="" />
+ <input type="button" value="$lt{'lnk'}" onclick="javascript:setExternal(this.form,0)" />
+ </fieldset>
+ </form>
+ERFORM
my $supnewsylform=(<<SNSFORM);
<form action="/adm/coursedocs" method="post" name="supnewsyl">
@@ -3942,10 +4043,12 @@
=>$supnewaboutmeform},
);
my @supimportdoc = (
- {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supnewext\');" />'
- =>$supnewextform},
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/extres.png" alt="'.$lt{extr}.'" onclick="javascript:makenewext(\'supext\');" />'
+ =>$supextform},
+ {'<img class="LC_noBorder LC_middle" src="/res/adm/pages/pdfupload.png" alt="'.$lt{upl}.'" onclick="javascript:toggleUpload(\'suppdoc\');" />'
+ =>$supupdocform},
);
-$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc)) . '<hr id="ee_hrule" style="width:0px;text-align:left;margin-left:0" />' . $supupdocform;
+$supupdocform = &create_form_ul(&create_list_elements(@supimportdoc));
my %suporderhash = (
'00' => ['Supnewfolder', $supnewfolderform],
'ee' => ['Import Content',$supupdocform],
@@ -3953,14 +4056,14 @@
);
if ($supplementalflag) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
- $supplementalflag,\%suporderhash,$iconpath);
+ $supplementalflag,\%suporderhash,$iconpath,$uploadtag);
if ($error) {
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
}
}
} elsif ($supplementalflag) {
my $error = &editor($r,$coursenum,$coursedom,$folder,$allowed,'',$crstype,
- $supplementalflag,'',$iconpath);
+ $supplementalflag,'',$iconpath,$uploadtag);
if ($error) {
$r->print('<p><span class="LC_error">'.$error.'</span></p>');
}
@@ -4316,6 +4419,10 @@
p_ctr2a => 'Cut[_98]',
p_ctr2b => '?[_98]',
rpck => 'Enter number to pick (e.g., 3)',
+ imsfile => 'You must choose an IMS package for import',
+ imscms => 'You must select which Course Management System was the source of the IMS package',
+ invurl => 'Invalid URL',
+ titbl => 'Title is blank',
);
my $crstype = &Apache::loncommon::course_type();
@@ -4335,6 +4442,15 @@
$backtourl = '/adm/supplemental';
}
+ my $fieldsets = "'ext','doc','ims'";
+ if ($supplementalflag) {
+ $fieldsets = "'suppext','suppdoc'";
+ }
+
+ my $urlregexp = <<'ENDREGEXP';
+/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|!
@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
+ENDREGEXP
+
return <<ENDNEWSCRIPT;
function makenewfolder(targetform,folderseq) {
var foldername=prompt('$lt{"p_mnf"}','$lt{"t_mnf"}');
@@ -4352,20 +4468,18 @@
}
}
-function makenewext(targetname) {
- this.document.forms.extimport.useform.value=targetname;
- this.document.forms.extimport.title.value='';
- this.document.forms.extimport.url.value='';
- this.document.forms.extimport.residx.value='';
- window.open('/adm/rat/extpickframe.html');
-}
-
-function edittext(targetname,residx,title,url) {
- this.document.forms.extimport.useform.value=targetname;
- this.document.forms.extimport.residx.value=residx;
- this.document.forms.extimport.url.value=url;
- this.document.forms.extimport.title.value=title;
- window.open('/adm/rat/extpickframe.html');
+function editext(residx) {
+ if (document.getElementById('uploadext'+residx)) {
+ var curr = document.getElementById('uploadext'+residx).style.display;
+ if (curr == 'none') {
+ disp = 'block';
+ } else {
+ disp = 'none';
+ }
+ document.getElementById('uploadext'+residx).style.display=disp;
+ }
+ resize_scrollbox('contentscroll','1','1');
+ return;
}
function makeexamupload() {
@@ -4432,19 +4546,54 @@
}
}
-function makeims() {
-var caller = document.forms.ims.folder.value;
-var newlocation = "/adm/imsimportdocs?folder="+caller+"&phase=one";
-newWindow = window.open("","IMSimport","HEIGHT=700,WIDTH=750,scrollbars=yes");
-newWindow.location.href = newlocation;
+function extUrlPreview(caller) {
+ if (document.getElementById(caller)) {
+ var url = document.getElementById(caller).value;
+ var regexp = $urlregexp;
+ if (regexp.test(url)) {
+ openMyModal(url,500,400,'yes');
+ } else {
+ alert("$lt{'invurl'}");
+ }
+ }
}
-function finishpick() {
-var title=this.document.forms.extimport.title.value;
-var url=this.document.forms.extimport.url.value;
-var form=this.document.forms.extimport.useform.value;
-var residx=this.document.forms.extimport.residx.value;
-eval('this.document.forms.'+form+'.importdetail.value="'+title+'='+url+'='+residx+'";this.document.forms.'+form+'.submit();');
+function makeims(imsform) {
+ if ((imsform.uploaddoc.value == '') || (!imsform.uploaddoc.value)) {
+ alert("$lt{'imsfile'}");
+ return;
+ }
+ if (imsform.source.selectedIndex == 0) {
+ alert("$lt{'imscms'}");
+ return;
+ }
+ newWindow = window.open('', 'IMSimport',"HEIGHT=700,WIDTH=750,scrollbars=yes");
+ imsform.submit();
+}
+
+function setExternal(extform,residx) {
+ var title=extform.exttitle.value;
+ if (!String.trim) {
+ String.prototype.trim = function() {return this.replace(\/^\\s+|\\s+$\/g, "");}; }
+ var url=extform.exturl.value;
+ var regexp = $urlregexp;
+ if (title == null || title.trim()=="") {
+ alert("$lt{'titbl'}");
+ extform.exttitle.focus();
+ return;
+ }
+ if (regexp.test(url)) {
+ url = escape(url);
+ if (residx > 0) {
+ eval("extform.importdetail.value=title+'='+url+'='+residx;extform.submit();");
+ } else {
+ eval("extform.importdetail.value=title+'='+url;extform.submit();");
+ }
+ } else {
+ alert("$lt{'invurl'}");
+ extform.exturl.focus();
+ return;
+ }
}
function changename(folderpath,index,oldtitle,container,pagesymb) {
@@ -4598,6 +4747,7 @@
currentData = document.getElementById(pageId);
currentData.style.display = 'block';
activeTab = pageId;
+ toggleUpload();
if (nav == 'mainnav') {
var storedpath = "$docs_folderpath";
if (storedpath == '') {
More information about the LON-CAPA-cvs
mailing list